|
2 | 2 | Feature Details
|
3 | 3 | ====================
|
4 | 4 |
|
5 |
| - |
6 |
| -.. contents:: :local: |
7 |
| - :depth: 3 |
8 |
| - |
9 |
| -Poetry |
10 |
| ---------------- |
11 |
| - |
12 |
| -This is a `cookiecutter <https://github.com/cookiecutter/cookiecutter>`_ repository to generate the file structure for a Python project that uses `Poetry <https://python-poetry.org/>`_ for its dependency management. |
13 |
| -When you have created your repository using this cookiecutter template, a poetry environment is pre-configured in ``pyproject.toml`` and ``poetry.toml``. All you need to do is |
14 |
| -add your project-specific dependencies with |
15 |
| - |
16 |
| -.. code-block:: bash |
17 |
| -
|
18 |
| - poetry add <package> |
19 |
| -
|
20 |
| -and then install the environment with |
21 |
| - |
22 |
| -.. code-block:: bash |
23 |
| -
|
24 |
| - make install |
25 |
| -
|
26 |
| -By default, the environment is created in a `.venv` folder, so you can easily start a interactive shell within the environment with ``poetry shell`` |
27 |
| - |
28 |
| -Makefile |
29 |
| ------------ |
30 |
| - |
31 |
| -A ``Makefile`` is available with the following commands: |
32 |
| - |
33 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
34 |
| -| Command | Description | |
35 |
| -+========================+===========================================================================================================+ |
36 |
| -| ``install`` | Install the poetry environment | |
37 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
38 |
| -| ``format`` | Format code using isort and black. | |
39 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
40 |
| -| ``lint`` | Check code formatting using isort, black, and flake8. | |
41 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
42 |
| -| ``test`` | Test the code with pytest | |
43 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
44 |
| -| ``build`` | Build wheel file using poetry | |
45 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
46 |
| -| ``clean-build`` | clean build artifacts | |
47 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
48 |
| -| ``publish`` | Available if ``publish_to`` is set to ``"pypi"`` or ``"artifactory"``. Publishes to the specified index. | |
49 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
50 |
| -| ``build-and-publish`` | Available if ``publish_to`` is set to ``"pypi"`` or ``"artifactory"``. Build and publish. | |
51 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
52 |
| -| ``docs-generate`` | Convert docstrings to ``rst``-files to prepare for building documentation with Sphinx. | |
53 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
54 |
| -| ``docs-build`` | Build documentation with sphinx. | |
55 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
56 |
| -| ``docs`` | Generate and build documentation with Sphinx, and directly open the documentation in the browser. | |
57 |
| -+------------------------+-----------------------------------------------------------------------------------------------------------+ |
58 |
| - |
59 |
| -Pytest |
60 |
| ----------- |
61 |
| - |
62 |
| -`pytest <https://docs.pytest.org/en/7.1.x/>`_ is automatically added to the environment, there is a template unittests in the ``tests`` directory and |
63 |
| -the tests can be run with |
64 |
| - |
65 |
| -.. code-block:: bash |
66 |
| -
|
67 |
| - make test |
68 |
| -
|
69 |
| -
|
70 |
| -If ``include_github_actions`` is set to ``"y"``, the tests are automatically run for every merge request, |
71 |
| -every merge to main, and every release. |
72 |
| - |
73 |
| -Formatting |
74 |
| ----------- |
75 |
| - |
76 |
| -`isort <https://pycqa.github.io/isort/index.html>`_, `black <https://pypi.org/project/black/>`_ and `flake8 <https://flake8.pycqa.org/en/latest/>`_ are added |
77 |
| -as development dependencies. ``black`` and ``isort`` can be used to format the code with |
78 |
| - |
79 |
| -.. code-block:: bash |
80 |
| -
|
81 |
| - make format |
82 |
| -
|
83 |
| -All three packages can be used to verify the code formatting with |
84 |
| - |
85 |
| -.. code-block:: bash |
86 |
| -
|
87 |
| - make lint |
88 |
| -
|
89 |
| -If ``include_github_actions`` is set to ``"y"``, code formatting is checked for every merge request, every merge to main, and every release. |
90 |
| - |
91 |
| -Pyenv |
92 |
| -------- |
93 |
| - |
94 |
| -A `.python-version` file is added with the specified ``python_version`` from the ``cookiecutter`` command, so that the right python version is used when ``make install`` is run. |
95 |
| - |
96 |
| -CI/CD with Github actions (Optional) |
97 |
| ---------------------------------------- |
98 |
| - |
99 |
| -when ``include_github_actions`` is set to ``"y"``, a ``.github`` directory is added with the following structure: |
100 |
| - |
101 |
| -:: |
102 |
| - |
103 |
| - .github |
104 |
| - ├── workflows |
105 |
| - ├─── run-checks |
106 |
| - │ └── action.yml |
107 |
| - ├─── setup-poetry-env |
108 |
| - │ └── action.yml |
109 |
| - ├── on-merge-to-main.yml |
110 |
| - ├── on-pull-request.yml |
111 |
| - └── on-release-main.yml |
112 |
| - |
113 |
| -``on-merge-to-main.yml`` and ``on-pull-request.tml`` are identical except for their trigger conditions; the first is run whenever a new commit is made to ``main`` |
114 |
| -(which should only happen through merge requests, hence the name), and the latter is run whenever a pull request is opened or updated. They call the ``action.yml`` files |
115 |
| -to set-up the environment, run the tests, and check the code formatting. |
116 |
| - |
117 |
| -``on-release-main.yml`` does all of the former whenever a new release is made on the ``main`` branch. To learn more about releasing, |
118 |
| -see :doc:`Releasing to Pypi or Artifactory <./releasing>`. |
119 |
| - |
120 |
| - |
121 |
| -Release to Pypi (Optional) |
122 |
| ----------------------------- |
123 |
| - |
124 |
| -See :doc:`Releasing to Pypi or Artifactory <./releasing>` |
125 |
| - |
126 |
| -Release to Artifactory (Optional) |
127 |
| ----------------------------------- |
128 |
| - |
129 |
| -See :doc:`Releasing to Pypi or Artifactory <./releasing>` |
130 |
| - |
131 |
| -Documentation with Sphinx (Optional) |
132 |
| ------------------------------------- |
133 |
| - |
| 5 | +.. toctree:: |
| 6 | + :maxdepth: 2 |
| 7 | + |
| 8 | + features/poetry |
| 9 | + features/makefile |
| 10 | + features/pytest |
| 11 | + features/formatting |
| 12 | + features/pyenv |
| 13 | + features/cicd |
| 14 | + features/releasing |
| 15 | + features/sphinx |
0 commit comments