docs: Update to use pyproject.toml

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I67c397713d8da2079a4b076472d681874f19e4b1
This commit is contained in:
Stephen Finucane
2025-11-10 17:27:31 +00:00
parent f85619d544
commit 25b7b757da
5 changed files with 100 additions and 80 deletions

View File

@@ -72,9 +72,9 @@ plugins are formatters from the stevedore examples, so I will use the
namespace "stevedore.example.formatter". Now it is possible to provide
all of the necessary information in the packaging instructions:
.. literalinclude:: ../../../../stevedore/example/setup.py
:language: python
:prepend: # stevedore/example/setup.py
.. literalinclude:: ../../../../stevedore/example/pyproject.toml
:language: toml
:prepend: # stevedore/example/pyproject.toml
The important lines are near the bottom where the ``entry_points``
argument to :func:`setup` is set. The value is a dictionary mapping
@@ -84,9 +84,9 @@ where *name* is the user-visible name for the plugin, *module* is the
Python import reference for the module, and *importable* is the name
of something that can be imported from inside the module.
.. literalinclude:: ../../../../stevedore/example/setup.py
:language: python
:lines: 37-43
.. literalinclude:: ../../../../stevedore/example/pyproject.toml
:language: toml
:lines: 33-35
In this case, there are two plugins registered. The "simple" plugin
defined above, and a "plain" plugin, which is just an alias for the
@@ -112,7 +112,7 @@ for stevedore is located in ``stevedore.egg-info/entry_points.txt``:
:mod:`importlib.metadata` uses the ``entry_points.txt`` file from all of
the installed packages on the import path to find plugins. You should
not modify these files, except by changing the list of entry points in
``setup.py``.
``pyproject.toml`` (or ``setup.py`` or ``setup.cfg``).
.. _abc module: http://docs.python.org/2/library/abc.html
.. _field list: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists
@@ -135,24 +135,24 @@ plugin that produces a reStructuredText `field list`_.
:language: python
:prepend: # stevedore/example2/fields.py
The new plugin can then be packaged using a ``setup.py`` containing
The new plugin can then be packaged using a ``pyproject.toml`` containing
.. literalinclude:: ../../../../stevedore/example2/setup.py
:language: python
:prepend: # stevedore/example2/setup.py
.. literalinclude:: ../../../../stevedore/example2/pyproject.toml
:language: toml
:prepend: # stevedore/example2/pyproject.toml
The new plugin is in a separate ``stevedore-examples2`` package.
.. literalinclude:: ../../../../stevedore/example2/setup.py
:language: python
:lines: 3-4
.. literalinclude:: ../../../../stevedore/example2/pyproject.toml
:language: toml
:lines: 37-39
However, the plugin is registered as part of the
``stevedore.example.formatter`` namespace.
.. literalinclude:: ../../../../stevedore/example2/setup.py
:language: python
:lines: 36-40
.. literalinclude:: ../../../../stevedore/example2/pyproject.toml
:language: toml
:lines: 33
When the plugin namespace is scanned, all packages on the current
``PYTHONPATH`` are examined and the entry point from the second

View File

@@ -0,0 +1,40 @@
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"
[project]
name = "stevedore-examples"
description = "Demonstration package for stevedore"
authors = [
{name = "Doug Hellmann", email = "doug@doughellmann.com"},
]
readme = {file = "README.rst", content-type = "text/x-rst"}
license = {text = "Apache-2.0"}
version = "0.1"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
[project.urls]
Homepage = "https://docs.openstack.org/stevedore"
Repository = "https://opendev.org/openstack/stevedore"
[project.entry-points."stevedore.example.formatter"]
simple = "stevedore.example.simple:Simple"
plain = "stevedore.example.simple:Simple"
[tool.setuptools]
packages = [
"stevedore.examples"
]

View File

@@ -12,37 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from setuptools import find_packages
from setuptools import setup
setup(
name='stevedore-examples',
version='1.0',
description='Demonstration package for stevedore',
author='Doug Hellmann',
author_email='doug@doughellmann.com',
url='http://opendev.org/openstack/stevedore',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Intended Audience :: Developers',
'Environment :: Console',
],
platforms=['Any'],
scripts=[],
provides=['stevedore.examples'],
packages=find_packages(),
include_package_data=True,
entry_points={
'stevedore.example.formatter': [
'simple = stevedore.example.simple:Simple',
'plain = stevedore.example.simple:Simple',
]
},
zip_safe=False,
)
setup()

View File

@@ -0,0 +1,39 @@
[build-system]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"
[project]
name = "stevedore-examples2"
description = "Demonstration package for stevedore"
authors = [
{name = "Doug Hellmann", email = "doug@doughellmann.com"},
]
readme = {file = "README.rst", content-type = "text/x-rst"}
license = {text = "Apache-2.0"}
version = "0.1"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
[project.urls]
Homepage = "https://docs.openstack.org/stevedore"
Repository = "https://opendev.org/openstack/stevedore"
[project.entry-points."stevedore.example.formatter"]
field = "stevedore.example2.fields:FieldList"
[tool.setuptools]
packages = [
"stevedore.examples2"
]

View File

@@ -12,36 +12,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from setuptools import find_packages
from setuptools import setup
setup(
name='stevedore-examples2',
version='1.0',
description='Demonstration package for stevedore',
author='Doug Hellmann',
author_email='doug@doughellmann.com',
url='http://opendev.org/openstack/stevedore',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Intended Audience :: Developers',
'Environment :: Console',
],
platforms=['Any'],
scripts=[],
provides=['stevedore.examples2'],
packages=find_packages(),
include_package_data=True,
entry_points={
'stevedore.example.formatter': [
'field = stevedore.example2.fields:FieldList'
]
},
zip_safe=False,
)
setup()