summaryrefslogtreecommitdiff
path: root/python-py-qs-example.spec
blob: 50dc89a87f4949f798968219a7d1055f0f4492bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
%global _empty_manifest_terminate_build 0
Name:		python-py-qs-example
Version:	0.2.11
Release:	1
Summary:	Python package PyPi Sphinx quickstart example app
License:	MIT
URL:		https://github.com/nickderobertis/pypi-sphinx-quickstart
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/c5/95/b185bb874d32d6fbb8e9c34f2d75e57f95b2fe2089877983d3d6f27abbbd/py_qs_example-0.2.11.tar.gz
BuildArch:	noarch

Requires:	python3-matplotlib

%description

[![](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart/branch/master/graph/badge.svg)](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart)

# pypi-sphinx-quickstart

## Overview

This repo is a template to use for starting a new Python package
which is hosted on PyPi and uses Sphinx for documentation
hosted on Github pages. It has a built-in CI/CD system using Github Actions,
all you need to do for that is hook up the secrets. The CI system has
the following features:
- Runs any tests in `tests` with `pytest`
- Lints code using `flake8`
- Static code checks with `mypy`
- Deploys PyPI package
- Deploys Sphinx documentation on Github Pages
    - Autodoc/autosummary already set up
    - Automatic sitemap.xml generated
    - Just add Google Analytics ID to enable tracking
    - Read the Docs Theme with Custom CSS
    - Notebook-style examples with Sphinx Gallery complete with download and Binder links
        - Auto-converts Jupyter notebooks in `nbexamples`
- Auto-merges pull requests by maintainers
- Auto-drafts release notes based on merged pull requests
- Syncs new changes from the cookiecutter template using `cruft`
on a cron workflow. Creates a PR with the changes to be merged
manually. Creates an issue if it is not possible to commit the changes (when there are
changes to workflow files).
- Collects TODO comments and converts them into issues (optional)
- Closes TODO issues once comments are removed (optional)

## Getting Started

### Required Steps

Follow the steps in one of the two ways to start, then the following steps.

#### Two Ways to Start

##### Cookiecutter

This template is available as a [cookiecutter](https://github.com/cookiecutter/cookiecutter).
Find [the cookiecutter for this template here](https://github.com/nickderobertis/cookiecutter-pypi-sphinx).
This is the recommended way to get started if you are already familiar with how
everything works. No example files will be included.

##### Repo Template

Click the "Use this template" button at the top of the repo page, then
fill out the name and description your new repo. This is the recommended way to get
started if you are figuring out how everything works as it gives you a fully
working demo with example files.

#### Adding Secrets

Go into the repo settings, under Secrets, and add the following secrets:
- `pypi_password`: Personal token for PyPI
- `gh_token`: Github personal access token
- `CODECOV_TOKEN` (optional): [codecov.io](https://codecov.io) token for this project
- `TODO_ACTIONS_MONGO_URL` (optional): MongoDB connection url, complete with
username and password. See [Setup MongoDB](#setup-mongodb-optional-for-todo-integration).

#### `conf.py`

Edit `conf.py` in the main repo directory. This contains the main
settings for the PyPi package. If you used the repo template, you will need to change
all the settings. Otherwise, the `cookiecutter` will have filled out most of the settings,
but specific package details such as dependencies
still need to be added.

#### Adding Project Source

Delete the folder `py_qs_example`, and add your own package
with the name you set in `conf.PACKAGE_NAME`.

#### Adding Global Requirements to Build

If you do not already have `pipenv` installed, you will need to run:
```
pip install pipenv
```
Then regardless of whether you already had `pipenv` installed, you will
need to navigate to the repo folder and run:
```
pipenv update
```

#### Setting up Documentation

If you used the repo template, edit `docsrc/Makefile` to change `SPHINXPROJ` to set it to the name
you set in `conf.PACKAGE_NAME` (with `cookiecutter` this step is not necessary.)

Edit `docsrc/source/index.rst` to remove the example included files. Replace
with your own if you wish or entirely delete the My Module and
My Package sections if don't wish to use the autosummary directive.

Edit `docsrc/source/tutorial.rst` to put your own tutorial, or remove it
and remove it from the `toctree` directive in `docsrc/source/index.rst`.

You may further modify Sphinx configuration in `docsrc/source/conf.py`
if you wish.

Add [Sphinx Gallery](https://sphinx-gallery.github.io/stable/index.html) examples
in the `examples` folder. You can also add Jupyter notebook examples in the
`nbexamples` folder, and they will automatically be converted to
Sphinx Gallery-style examples and included with `examples` in the
build of the documentation.

#### Adding Labels

The following labels are used in the CI/CD. They should be added in Labels in the
repo settings:
- `no auto merge`: added to prevent automatic merging of
pull requests by maintainers
- `maintenance`: one of the output categories for release notes
- `automated pr`: Used by automated template update cron workflow which
uses `cruft` to check for changes in the template and opens a PR
automatically if so.
- `automated issue`: Due to limitations in Github Actions, the template update
cron workflow is not able to commit to the repo if the changes include changes to
workflow files. It instead raises an issue to update the template in this case. This
label is applied to these issues as well as the `maintenance` label.


#### Commit and Push

After the preceding steps, now commit your changes and push to `master`
if not done already. After a few minutes, Github Actions should create
a `gh-pages` branch which has the documentation HTML in it.

#### Github Pages Setup

Note: This should happen automatically after Github Actions creates
the `gh-pages` branch. But follow these steps if your docs still do
not work.

Go to repo settings, Github Pages section. For the Source dropdown,
select "gh-pages branch". The settings page should reload,
and in the Github Pages section it should show the URL of your
documentation. You should be able to see the documentation at the URL
after a few seconds, but it will still be the example documentation.

If "gh-pages branch" is not shown in the dropdown, you need to make one
release commit and push it, so that the `gh-pages` branch will be added
to your repo. After doing that, you can go into the repo settings
and select "gh-pages branch" as described.

### Optional Steps

#### Set Master to Protected Branch

It is recommended to make master a protected branch so that nobody can
delete it.

#### Setup Codecov

Go to [codecov.io](https://codecov.io), log in via Github, click Repositories then
"Add new repository" and select this repository from the list. Copy the
token for Codecov to use in the next step.

#### Setup MongoDB (optional, for TODO integration)

For the TODO integration to work, you need a MongoDB instance. You can
get one for free at [mlab.com](https://mlab.com). After creating the database,
create a database user. The MLab interface will show you the format
of the connection url string, which you will fill in the database user's
username and password and use that as the `TODO_ACTIONS_MONGO_URL` secret,
as the [Adding Secrets](#adding-secrets) section shows.

## Built-in CI/CD

### On Every Push

Github Actions are used to automatically run the following steps on every push:
- Check Python syntax with `flake8`
- Run `pytest`
- Static typing checks with `mypy`

### When Branch is `master`

If the branch is the `master` branch, then it will also:
- Upload `pytest` results to `codecov`

#### If there is a change in `docsrc`

If the branch is the master branch, and there was a change in `docsrc`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation

#### If there is a change in the package version
If the branch is the master branch, and there was a change in the package version
in `conf.py`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation
- Build Python package
- Upload Python package to PyPI

### If a Pull Request is Opened
The CI/CD system will check whether the pull request was opened by a maintainer
(configured in conf.py). If so, it will auto-merge the pull request after
it has passed CI checks. It will then run the deployment pipeline. To avoid
this auto-merge behavior, add the label "no auto merge" to the pull request.

## Regular Usage

Once everything is set up, just commit your changes. The built-in
CI/CD will take care of testing, build, and deployment of PyPI package
and documentation. If you use pull requests on Github then it will
show you whether it passes the CI tests.

### Releases

If you want to create Github releases notes for your package, they
will already be drafted, just edit them as desired before posting.

## Local Usage

Building the documentation locally makes sense if you are
updating it but don't want to make it live yet. You can view
the HTML files in the `docs` folder via a browser after building them.

### Building Documentation

Navigate into the `docsrc` folder and run:
```
pipenv run make github
```

This should generate documentation HTML in the `docs` folder.

### Uploading to PyPi

Navigate to the repo base folder and run:
```
pipenv run python upload.py
```

### Updating Build Requirements

The Github Actions CI/CD uses `Pipfile.lock` to install its
requirements. Run `pipenv update` locally to update the
`Pipfile.lock` with the newest dependencies and push into
the `master` branch to get the dependencies updated
on the CI/CD system.

### Syncing with the `cookiecutter` template

There is a built-in workflow which runs daily to check for
updates in the `cookiecutter` template. If it finds an update,
it will use `cruft` to apply the update and raise a PR with the
changes. Manually review the changes, adjusting if needed, then
merge the PR to keep updated with the template.

## Links

See the example
[generated documentation here.](
https://nickderobertis.github.io/pypi-sphinx-quickstart/
)




%package -n python3-py-qs-example
Summary:	Python package PyPi Sphinx quickstart example app
Provides:	python-py-qs-example
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-py-qs-example

[![](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart/branch/master/graph/badge.svg)](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart)

# pypi-sphinx-quickstart

## Overview

This repo is a template to use for starting a new Python package
which is hosted on PyPi and uses Sphinx for documentation
hosted on Github pages. It has a built-in CI/CD system using Github Actions,
all you need to do for that is hook up the secrets. The CI system has
the following features:
- Runs any tests in `tests` with `pytest`
- Lints code using `flake8`
- Static code checks with `mypy`
- Deploys PyPI package
- Deploys Sphinx documentation on Github Pages
    - Autodoc/autosummary already set up
    - Automatic sitemap.xml generated
    - Just add Google Analytics ID to enable tracking
    - Read the Docs Theme with Custom CSS
    - Notebook-style examples with Sphinx Gallery complete with download and Binder links
        - Auto-converts Jupyter notebooks in `nbexamples`
- Auto-merges pull requests by maintainers
- Auto-drafts release notes based on merged pull requests
- Syncs new changes from the cookiecutter template using `cruft`
on a cron workflow. Creates a PR with the changes to be merged
manually. Creates an issue if it is not possible to commit the changes (when there are
changes to workflow files).
- Collects TODO comments and converts them into issues (optional)
- Closes TODO issues once comments are removed (optional)

## Getting Started

### Required Steps

Follow the steps in one of the two ways to start, then the following steps.

#### Two Ways to Start

##### Cookiecutter

This template is available as a [cookiecutter](https://github.com/cookiecutter/cookiecutter).
Find [the cookiecutter for this template here](https://github.com/nickderobertis/cookiecutter-pypi-sphinx).
This is the recommended way to get started if you are already familiar with how
everything works. No example files will be included.

##### Repo Template

Click the "Use this template" button at the top of the repo page, then
fill out the name and description your new repo. This is the recommended way to get
started if you are figuring out how everything works as it gives you a fully
working demo with example files.

#### Adding Secrets

Go into the repo settings, under Secrets, and add the following secrets:
- `pypi_password`: Personal token for PyPI
- `gh_token`: Github personal access token
- `CODECOV_TOKEN` (optional): [codecov.io](https://codecov.io) token for this project
- `TODO_ACTIONS_MONGO_URL` (optional): MongoDB connection url, complete with
username and password. See [Setup MongoDB](#setup-mongodb-optional-for-todo-integration).

#### `conf.py`

Edit `conf.py` in the main repo directory. This contains the main
settings for the PyPi package. If you used the repo template, you will need to change
all the settings. Otherwise, the `cookiecutter` will have filled out most of the settings,
but specific package details such as dependencies
still need to be added.

#### Adding Project Source

Delete the folder `py_qs_example`, and add your own package
with the name you set in `conf.PACKAGE_NAME`.

#### Adding Global Requirements to Build

If you do not already have `pipenv` installed, you will need to run:
```
pip install pipenv
```
Then regardless of whether you already had `pipenv` installed, you will
need to navigate to the repo folder and run:
```
pipenv update
```

#### Setting up Documentation

If you used the repo template, edit `docsrc/Makefile` to change `SPHINXPROJ` to set it to the name
you set in `conf.PACKAGE_NAME` (with `cookiecutter` this step is not necessary.)

Edit `docsrc/source/index.rst` to remove the example included files. Replace
with your own if you wish or entirely delete the My Module and
My Package sections if don't wish to use the autosummary directive.

Edit `docsrc/source/tutorial.rst` to put your own tutorial, or remove it
and remove it from the `toctree` directive in `docsrc/source/index.rst`.

You may further modify Sphinx configuration in `docsrc/source/conf.py`
if you wish.

Add [Sphinx Gallery](https://sphinx-gallery.github.io/stable/index.html) examples
in the `examples` folder. You can also add Jupyter notebook examples in the
`nbexamples` folder, and they will automatically be converted to
Sphinx Gallery-style examples and included with `examples` in the
build of the documentation.

#### Adding Labels

The following labels are used in the CI/CD. They should be added in Labels in the
repo settings:
- `no auto merge`: added to prevent automatic merging of
pull requests by maintainers
- `maintenance`: one of the output categories for release notes
- `automated pr`: Used by automated template update cron workflow which
uses `cruft` to check for changes in the template and opens a PR
automatically if so.
- `automated issue`: Due to limitations in Github Actions, the template update
cron workflow is not able to commit to the repo if the changes include changes to
workflow files. It instead raises an issue to update the template in this case. This
label is applied to these issues as well as the `maintenance` label.


#### Commit and Push

After the preceding steps, now commit your changes and push to `master`
if not done already. After a few minutes, Github Actions should create
a `gh-pages` branch which has the documentation HTML in it.

#### Github Pages Setup

Note: This should happen automatically after Github Actions creates
the `gh-pages` branch. But follow these steps if your docs still do
not work.

Go to repo settings, Github Pages section. For the Source dropdown,
select "gh-pages branch". The settings page should reload,
and in the Github Pages section it should show the URL of your
documentation. You should be able to see the documentation at the URL
after a few seconds, but it will still be the example documentation.

If "gh-pages branch" is not shown in the dropdown, you need to make one
release commit and push it, so that the `gh-pages` branch will be added
to your repo. After doing that, you can go into the repo settings
and select "gh-pages branch" as described.

### Optional Steps

#### Set Master to Protected Branch

It is recommended to make master a protected branch so that nobody can
delete it.

#### Setup Codecov

Go to [codecov.io](https://codecov.io), log in via Github, click Repositories then
"Add new repository" and select this repository from the list. Copy the
token for Codecov to use in the next step.

#### Setup MongoDB (optional, for TODO integration)

For the TODO integration to work, you need a MongoDB instance. You can
get one for free at [mlab.com](https://mlab.com). After creating the database,
create a database user. The MLab interface will show you the format
of the connection url string, which you will fill in the database user's
username and password and use that as the `TODO_ACTIONS_MONGO_URL` secret,
as the [Adding Secrets](#adding-secrets) section shows.

## Built-in CI/CD

### On Every Push

Github Actions are used to automatically run the following steps on every push:
- Check Python syntax with `flake8`
- Run `pytest`
- Static typing checks with `mypy`

### When Branch is `master`

If the branch is the `master` branch, then it will also:
- Upload `pytest` results to `codecov`

#### If there is a change in `docsrc`

If the branch is the master branch, and there was a change in `docsrc`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation

#### If there is a change in the package version
If the branch is the master branch, and there was a change in the package version
in `conf.py`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation
- Build Python package
- Upload Python package to PyPI

### If a Pull Request is Opened
The CI/CD system will check whether the pull request was opened by a maintainer
(configured in conf.py). If so, it will auto-merge the pull request after
it has passed CI checks. It will then run the deployment pipeline. To avoid
this auto-merge behavior, add the label "no auto merge" to the pull request.

## Regular Usage

Once everything is set up, just commit your changes. The built-in
CI/CD will take care of testing, build, and deployment of PyPI package
and documentation. If you use pull requests on Github then it will
show you whether it passes the CI tests.

### Releases

If you want to create Github releases notes for your package, they
will already be drafted, just edit them as desired before posting.

## Local Usage

Building the documentation locally makes sense if you are
updating it but don't want to make it live yet. You can view
the HTML files in the `docs` folder via a browser after building them.

### Building Documentation

Navigate into the `docsrc` folder and run:
```
pipenv run make github
```

This should generate documentation HTML in the `docs` folder.

### Uploading to PyPi

Navigate to the repo base folder and run:
```
pipenv run python upload.py
```

### Updating Build Requirements

The Github Actions CI/CD uses `Pipfile.lock` to install its
requirements. Run `pipenv update` locally to update the
`Pipfile.lock` with the newest dependencies and push into
the `master` branch to get the dependencies updated
on the CI/CD system.

### Syncing with the `cookiecutter` template

There is a built-in workflow which runs daily to check for
updates in the `cookiecutter` template. If it finds an update,
it will use `cruft` to apply the update and raise a PR with the
changes. Manually review the changes, adjusting if needed, then
merge the PR to keep updated with the template.

## Links

See the example
[generated documentation here.](
https://nickderobertis.github.io/pypi-sphinx-quickstart/
)




%package help
Summary:	Development documents and examples for py-qs-example
Provides:	python3-py-qs-example-doc
%description help

[![](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart/branch/master/graph/badge.svg)](https://codecov.io/gh/nickderobertis/pypi-sphinx-quickstart)

# pypi-sphinx-quickstart

## Overview

This repo is a template to use for starting a new Python package
which is hosted on PyPi and uses Sphinx for documentation
hosted on Github pages. It has a built-in CI/CD system using Github Actions,
all you need to do for that is hook up the secrets. The CI system has
the following features:
- Runs any tests in `tests` with `pytest`
- Lints code using `flake8`
- Static code checks with `mypy`
- Deploys PyPI package
- Deploys Sphinx documentation on Github Pages
    - Autodoc/autosummary already set up
    - Automatic sitemap.xml generated
    - Just add Google Analytics ID to enable tracking
    - Read the Docs Theme with Custom CSS
    - Notebook-style examples with Sphinx Gallery complete with download and Binder links
        - Auto-converts Jupyter notebooks in `nbexamples`
- Auto-merges pull requests by maintainers
- Auto-drafts release notes based on merged pull requests
- Syncs new changes from the cookiecutter template using `cruft`
on a cron workflow. Creates a PR with the changes to be merged
manually. Creates an issue if it is not possible to commit the changes (when there are
changes to workflow files).
- Collects TODO comments and converts them into issues (optional)
- Closes TODO issues once comments are removed (optional)

## Getting Started

### Required Steps

Follow the steps in one of the two ways to start, then the following steps.

#### Two Ways to Start

##### Cookiecutter

This template is available as a [cookiecutter](https://github.com/cookiecutter/cookiecutter).
Find [the cookiecutter for this template here](https://github.com/nickderobertis/cookiecutter-pypi-sphinx).
This is the recommended way to get started if you are already familiar with how
everything works. No example files will be included.

##### Repo Template

Click the "Use this template" button at the top of the repo page, then
fill out the name and description your new repo. This is the recommended way to get
started if you are figuring out how everything works as it gives you a fully
working demo with example files.

#### Adding Secrets

Go into the repo settings, under Secrets, and add the following secrets:
- `pypi_password`: Personal token for PyPI
- `gh_token`: Github personal access token
- `CODECOV_TOKEN` (optional): [codecov.io](https://codecov.io) token for this project
- `TODO_ACTIONS_MONGO_URL` (optional): MongoDB connection url, complete with
username and password. See [Setup MongoDB](#setup-mongodb-optional-for-todo-integration).

#### `conf.py`

Edit `conf.py` in the main repo directory. This contains the main
settings for the PyPi package. If you used the repo template, you will need to change
all the settings. Otherwise, the `cookiecutter` will have filled out most of the settings,
but specific package details such as dependencies
still need to be added.

#### Adding Project Source

Delete the folder `py_qs_example`, and add your own package
with the name you set in `conf.PACKAGE_NAME`.

#### Adding Global Requirements to Build

If you do not already have `pipenv` installed, you will need to run:
```
pip install pipenv
```
Then regardless of whether you already had `pipenv` installed, you will
need to navigate to the repo folder and run:
```
pipenv update
```

#### Setting up Documentation

If you used the repo template, edit `docsrc/Makefile` to change `SPHINXPROJ` to set it to the name
you set in `conf.PACKAGE_NAME` (with `cookiecutter` this step is not necessary.)

Edit `docsrc/source/index.rst` to remove the example included files. Replace
with your own if you wish or entirely delete the My Module and
My Package sections if don't wish to use the autosummary directive.

Edit `docsrc/source/tutorial.rst` to put your own tutorial, or remove it
and remove it from the `toctree` directive in `docsrc/source/index.rst`.

You may further modify Sphinx configuration in `docsrc/source/conf.py`
if you wish.

Add [Sphinx Gallery](https://sphinx-gallery.github.io/stable/index.html) examples
in the `examples` folder. You can also add Jupyter notebook examples in the
`nbexamples` folder, and they will automatically be converted to
Sphinx Gallery-style examples and included with `examples` in the
build of the documentation.

#### Adding Labels

The following labels are used in the CI/CD. They should be added in Labels in the
repo settings:
- `no auto merge`: added to prevent automatic merging of
pull requests by maintainers
- `maintenance`: one of the output categories for release notes
- `automated pr`: Used by automated template update cron workflow which
uses `cruft` to check for changes in the template and opens a PR
automatically if so.
- `automated issue`: Due to limitations in Github Actions, the template update
cron workflow is not able to commit to the repo if the changes include changes to
workflow files. It instead raises an issue to update the template in this case. This
label is applied to these issues as well as the `maintenance` label.


#### Commit and Push

After the preceding steps, now commit your changes and push to `master`
if not done already. After a few minutes, Github Actions should create
a `gh-pages` branch which has the documentation HTML in it.

#### Github Pages Setup

Note: This should happen automatically after Github Actions creates
the `gh-pages` branch. But follow these steps if your docs still do
not work.

Go to repo settings, Github Pages section. For the Source dropdown,
select "gh-pages branch". The settings page should reload,
and in the Github Pages section it should show the URL of your
documentation. You should be able to see the documentation at the URL
after a few seconds, but it will still be the example documentation.

If "gh-pages branch" is not shown in the dropdown, you need to make one
release commit and push it, so that the `gh-pages` branch will be added
to your repo. After doing that, you can go into the repo settings
and select "gh-pages branch" as described.

### Optional Steps

#### Set Master to Protected Branch

It is recommended to make master a protected branch so that nobody can
delete it.

#### Setup Codecov

Go to [codecov.io](https://codecov.io), log in via Github, click Repositories then
"Add new repository" and select this repository from the list. Copy the
token for Codecov to use in the next step.

#### Setup MongoDB (optional, for TODO integration)

For the TODO integration to work, you need a MongoDB instance. You can
get one for free at [mlab.com](https://mlab.com). After creating the database,
create a database user. The MLab interface will show you the format
of the connection url string, which you will fill in the database user's
username and password and use that as the `TODO_ACTIONS_MONGO_URL` secret,
as the [Adding Secrets](#adding-secrets) section shows.

## Built-in CI/CD

### On Every Push

Github Actions are used to automatically run the following steps on every push:
- Check Python syntax with `flake8`
- Run `pytest`
- Static typing checks with `mypy`

### When Branch is `master`

If the branch is the `master` branch, then it will also:
- Upload `pytest` results to `codecov`

#### If there is a change in `docsrc`

If the branch is the master branch, and there was a change in `docsrc`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation

#### If there is a change in the package version
If the branch is the master branch, and there was a change in the package version
in `conf.py`, it will do
all the steps in On Every Push and When Branch is `master`, then it will:
- Build documentation HTML using Sphinx
- Create `gh-pages` branch and copy HTML there
- Push to `gh-pages` branch, which will update the hosted documentation
- Build Python package
- Upload Python package to PyPI

### If a Pull Request is Opened
The CI/CD system will check whether the pull request was opened by a maintainer
(configured in conf.py). If so, it will auto-merge the pull request after
it has passed CI checks. It will then run the deployment pipeline. To avoid
this auto-merge behavior, add the label "no auto merge" to the pull request.

## Regular Usage

Once everything is set up, just commit your changes. The built-in
CI/CD will take care of testing, build, and deployment of PyPI package
and documentation. If you use pull requests on Github then it will
show you whether it passes the CI tests.

### Releases

If you want to create Github releases notes for your package, they
will already be drafted, just edit them as desired before posting.

## Local Usage

Building the documentation locally makes sense if you are
updating it but don't want to make it live yet. You can view
the HTML files in the `docs` folder via a browser after building them.

### Building Documentation

Navigate into the `docsrc` folder and run:
```
pipenv run make github
```

This should generate documentation HTML in the `docs` folder.

### Uploading to PyPi

Navigate to the repo base folder and run:
```
pipenv run python upload.py
```

### Updating Build Requirements

The Github Actions CI/CD uses `Pipfile.lock` to install its
requirements. Run `pipenv update` locally to update the
`Pipfile.lock` with the newest dependencies and push into
the `master` branch to get the dependencies updated
on the CI/CD system.

### Syncing with the `cookiecutter` template

There is a built-in workflow which runs daily to check for
updates in the `cookiecutter` template. If it finds an update,
it will use `cruft` to apply the update and raise a PR with the
changes. Manually review the changes, adjusting if needed, then
merge the PR to keep updated with the template.

## Links

See the example
[generated documentation here.](
https://nickderobertis.github.io/pypi-sphinx-quickstart/
)




%prep
%autosetup -n py-qs-example-0.2.11

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-py-qs-example -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.11-1
- Package Spec generated