diff options
| author | Tres Seaver <tseaver@palladion.com> | 2024-02-07 12:24:11 -0500 |
|---|---|---|
| committer | Tres Seaver <tseaver@palladion.com> | 2024-02-07 12:24:11 -0500 |
| commit | 94d5ce60c783eed483d2fff49a6470b066430bfb (patch) | |
| tree | ac81f7577d873d1f667c34148cb6764865290720 | |
| parent | 13909fa1c603028109039e48af096ac4676a0010 (diff) | |
| download | pyramid-94d5ce60c783eed483d2fff49a6470b066430bfb.tar.gz pyramid-94d5ce60c783eed483d2fff49a6470b066430bfb.tar.bz2 pyramid-94d5ce60c783eed483d2fff49a6470b066430bfb.zip | |
docs: update ZODB wiki tutorial to cookiecutter
- Describe 'pyproject.toml' usage (replacing 'setup.py', 'pytest.ini',
'.coveragerc').
- Document the new PyPA-blessed build process.
| -rw-r--r-- | docs/tutorials/wiki/authorization.rst | 8 | ||||
| -rw-r--r-- | docs/tutorials/wiki/basiclayout.rst | 2 | ||||
| -rw-r--r-- | docs/tutorials/wiki/definingviews.rst | 14 | ||||
| -rw-r--r-- | docs/tutorials/wiki/distributing.rst | 30 | ||||
| -rw-r--r-- | docs/tutorials/wiki/installation.rst | 29 | ||||
| -rw-r--r-- | docs/tutorials/wiki/tests.rst | 2 |
6 files changed, 48 insertions, 37 deletions
diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst index 2b700ee5b..f7f1be8d0 100644 --- a/docs/tutorials/wiki/authorization.rst +++ b/docs/tutorials/wiki/authorization.rst @@ -38,12 +38,12 @@ Add dependencies ~~~~~~~~~~~~~~~~ Just like in :ref:`wiki_defining_views`, we need a new dependency. -We need to add the `bcrypt <https://pypi.org/project/bcrypt/>`_ package to our tutorial package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. +We need to add the `bcrypt <https://pypi.org/project/bcrypt/>`_ package to our tutorial package's ``pyproject.toml`` file by assigning this dependency to the ``dependencies`` stanza. -Open ``setup.py`` and edit it to look like the following: +Open ``pyproject.toml`` and edit it to look like the following: -.. literalinclude:: src/authorization/setup.py - :lines: 11-30 +.. literalinclude:: src/authorization/pyproject.toml + :lines: 20-33 :lineno-match: :emphasize-lines: 2 :language: python diff --git a/docs/tutorials/wiki/basiclayout.rst b/docs/tutorials/wiki/basiclayout.rst index c1c762ae4..01d366e7b 100644 --- a/docs/tutorials/wiki/basiclayout.rst +++ b/docs/tutorials/wiki/basiclayout.rst @@ -15,7 +15,7 @@ Even if empty, this marks a directory as a Python package. We use ``__init__.py`` both as a marker, indicating the directory in which it is contained is a package, and to contain application configuration code. When you run the application using the ``pserve`` command using the ``development.ini`` generated configuration file, the application configuration points at a :term:`Setuptools` :term:`entry point` described as ``egg:tutorial``. -In our application, because the application's ``setup.py`` file says so, this entry point happens to be the ``main`` function within the file named ``__init__.py``. +In our application, because the application's ``pyproject.toml`` file says so, this entry point happens to be the ``main`` function within the file named ``__init__.py``. Open ``tutorial/__init__.py``. It should already contain the following: diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst index 02d7bde9a..41d8c13a1 100644 --- a/docs/tutorials/wiki/definingviews.rst +++ b/docs/tutorials/wiki/definingviews.rst @@ -27,19 +27,19 @@ We will define several :term:`view callable` functions, then wire them into :app See also the chapter :ref:`resources_chapter` for a complete description of resources and the chapter :ref:`traversal_chapter` for the technical details of how traversal works in Pyramid. -Declaring Dependencies in Our ``setup.py`` File -=============================================== +Declaring Dependencies in Our ``pyproject.toml`` File +===================================================== The view code in our application will depend on a package which is not a dependency of the original "tutorial" application. The original "tutorial" application was generated by the cookiecutter. It does not know about our custom application requirements. -We need to add a dependency on the ``docutils`` package to our ``tutorial`` package's ``setup.py`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. +We need to add a dependency on the ``docutils`` package to our ``tutorial`` package's ``pyproject.toml`` file by assigning this dependency to the ``requires`` parameter in the ``setup()`` function. -Open ``setup.py`` and edit it to look like the following: +Open ``pyproject.toml`` and edit it to look like the following: -.. literalinclude:: src/views/setup.py - :lines: 11-29 +.. literalinclude:: src/views/pyproject.toml + :lines: 20-32 :lineno-match: :emphasize-lines: 2 :language: python @@ -54,7 +54,7 @@ Running ``pip install -e .`` Since a new software dependency was added, you need to run ``pip install -e .`` again inside the root of the ``tutorial`` package to obtain and register the newly added dependency distribution. -Make sure your current working directory is the root of the project (the directory in which ``setup.py`` lives) and execute the following command. +Make sure your current working directory is the root of the project (the directory in which ``pyproject.toml`` lives) and execute the following command. On Unix: diff --git a/docs/tutorials/wiki/distributing.rst b/docs/tutorials/wiki/distributing.rst index c23f79b5a..a423e8b96 100644 --- a/docs/tutorials/wiki/distributing.rst +++ b/docs/tutorials/wiki/distributing.rst @@ -4,33 +4,37 @@ Distributing Your Application ============================= -Once your application works properly, you can create a :term:`distribution` from it by using the ``setup.py sdist`` command. -The following commands assume your current working directory contains the ``tutorial`` package and the ``setup.py`` file. +Once your application works properly, you can create a :term:`distribution` from it by using the PyPA ``build`` command. +The following commands assume your current working directory contains the ``tutorial`` package and its ``pyproject.toml`` file. On Unix: .. code-block:: bash - $VENV/bin/python setup.py sdist + $VENV/bin/pip install build + $VENV/bin/python -m build On Windows: .. code-block:: doscon - %VENV%\Scripts\python setup.py sdist + %VENV%\Scripts\pip install build + %VENV%\Scripts\python -m build The output of such a command will be something like: .. code-block:: text - running sdist - # more output - creating dist - Creating tar archive - removing 'tutorial-0.0' (and everything under it) + * Creating venv isolated environment... + * Installing packages in isolated environment... (setuptools) + * Getting build dependencies for sdist... + ... + removing build/bdist.linux-x86_64/wheel + Successfully built tutorial-0.0.tar.gz and tutorial-0.0-py3-none-any.whl + This command creates a subdirectory named ``dist``. -Inside that is a tarball named ``tutorial-0.0.tar.gz``, which is the :term:`distribution` of your application. -You can send this file to your friends to show them your cool new application. -They should be able to install it by pointing the ``pip install`` command directly at it. -Or you can upload it to `PyPI <https://pypi.org/>`_ and share it with the rest of the world, where it can be downloaded via ``pip install`` remotely like any other package people download from PyPI. +Inside that is a tarball named ``tutorial-0.0.tar.gz`` (the source :term:`distribution` of your application), as well ass ``tutorial-0.0-py3-none-any.whl`` (the binary :term:`distribution`). +You can send these files to your friends to show them your cool new application. +They should be able to install the app by pointing the ``pip install`` command directly at one of them. +Or you can upload them to `PyPI <https://pypi.org/>`_ and share them with the rest of the world, where it can be downloaded via ``pip install`` remotely like any other package people download from PyPI. diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst index ce15bff0e..e83e83861 100644 --- a/docs/tutorials/wiki/installation.rst +++ b/docs/tutorials/wiki/installation.rst @@ -187,17 +187,12 @@ The console will show ``pip`` checking for packages and installing missing packa Successfully installed BTrees-4.7.2 Chameleon-3.8.1 Mako-1.1.3 MarkupSafe-1.1.1 PasteDeploy-2.1.1 Pygments-2.7.3 WebTest-2.0.35 ZConfig-3.5.0 ZEO-5.2.2 ZODB-5.6.0 attrs-20.3.0 beautifulsoup4-4.9.3 cffi-1.14.4 coverage-5.3.1 hupper-1.10.2 iniconfig-1.1.1 packaging-20.8 persistent-4.6.4 plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 py-1.10.0 pycparser-2.20 pyparsing-2.4.7 pyramid-1.10.5 pyramid-chameleon-0.3 pyramid-debugtoolbar-4.9 pyramid-mako-1.1.0 pyramid-retry-2.1.1 pyramid-tm-2.4 pyramid-zodbconn-0.8.1 pytest-6.2.1 pytest-cov-2.10.1 repoze.lru-0.7 six-1.15.0 soupsieve-2.1 toml-0.10.2 transaction-3.0.1 translationstring-1.4 tutorial venusian-3.0.0 waitress-1.4.4 webob-1.8.6 zc.lockfile-2.0 zdaemon-4.3 zodbpickle-2.0.0 zodburi-2.4.0 zope.deprecation-4.4.0 zope.interface-5.2.0 -Testing requirements are defined in our project's ``setup.py`` file, in the ``tests_require`` and ``extras_require`` stanzas. +Testing requirements are defined in our project's ``pyproject.toml`` file, in the ``project:optional-dependencies`` stanza: -.. literalinclude:: src/installation/setup.py +.. literalinclude:: src/installation/pyproject.toml :language: python :lineno-match: - :lines: 24-28 - -.. literalinclude:: src/installation/setup.py - :language: python - :lineno-match: - :lines: 48-50 + :lines: 33-38 .. _running_tests: @@ -295,10 +290,22 @@ Test and coverage cookiecutter defaults --------------------------------------- The Pyramid cookiecutter includes configuration defaults for ``pytest`` and test coverage. -These configuration files are ``pytest.ini`` and ``.coveragerc``, located at the root of your package. +These configuration optionas are defined in stanzas of the ``pyroject.toml`` file. + +The ``tool.pytest.ini_options`` stanza follows :ref:`conventions for Python test discovery <pytest:test discovery>`. +The configuration defaults from the cookiecutter tell ``pytest`` where to find the module on which we want to run tests: + +.. literalinclude:: src/installation/pyproject.toml + :language: python + :lineno-match: + :lines: 51-56 + +The ``tool.coverage.run`` stanza defines the code for which we want to collect and report coverage: -``pytest`` follows :ref:`conventions for Python test discovery <pytest:test discovery>`. -The configuration defaults from the cookiecutter tell ``pytest`` where to find the module on which we want to run tests and coverage. +.. literalinclude:: src/installation/pyproject.toml + :language: python + :lineno-match: + :lines: 46-49 .. seealso:: See ``pytest``'s documentation for :ref:`pytest:usage` or invoke ``pytest -h`` to see its full set of options. diff --git a/docs/tutorials/wiki/tests.rst b/docs/tutorials/wiki/tests.rst index 231945c9a..f9359dd38 100644 --- a/docs/tutorials/wiki/tests.rst +++ b/docs/tutorials/wiki/tests.rst @@ -28,7 +28,7 @@ The harness consists of the following setup: - ``testing.ini`` - a mirror of ``development.ini`` and ``production.ini`` that contains settings used for executing the test suite. Most importantly, it contains the database connection information used by tests that require the database. -- ``tests_require`` in ``setup.py`` - controls the dependencies installed when testing. +- ``project.optional-dependencies`` in ``pyproject.toml`` - controls the dependencies installed when testing. When the list is changed, it is necessary to re-run ``$VENV/bin/pip install -e ".[testing]"`` to ensure the new dependencies are installed. - ``tests/conftest.py`` - the core fixtures available throughout our tests. |
