From 9018670357f840007528e8f1cdbb22a48c120d6c Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 19 Oct 2022 13:31:15 +0300 Subject: [PATCH 1/2] Migrated the metadata into `setup.cfg` from `setup.py`. Added a section to `pyproject.toml` according to `PEP 517`. Version is now fetched automatically from git tags using `setuptools_scm`. --- .gitignore | 2 +- ci.sh | 8 ++++---- pyproject.toml | 8 ++++++++ setup.cfg | 30 ++++++++++++++++++++++++++++++ setup.py | 39 --------------------------------------- sniffio/_version.py | 3 --- 6 files changed, 43 insertions(+), 47 deletions(-) create mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 sniffio/_version.py diff --git a/.gitignore b/.gitignore index 47ad4b1..fcbb5dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Add any project-specific files here: - +sniffio/_version.py # Sphinx docs docs/build/ diff --git a/ci.sh b/ci.sh index bab85fc..afa8a5a 100755 --- a/ci.sh +++ b/ci.sh @@ -10,7 +10,7 @@ pip install -U pip setuptools wheel if [ "$CHECK_FORMATTING" = "1" ]; then pip install yapf==${YAPF_VERSION} - if ! yapf -rpd setup.py sniffio; then + if ! yapf -rpd sniffio; then cat <=42.2", "setuptools_scm[toml]>=3.4.3"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "sniffio/_version.py" +write_to_template = "__version__ = \"{version}\"\n" + [tool.towncrier] package = "sniffio" filename = "docs/source/history.rst" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..757d144 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,30 @@ +[metadata] +name = sniffio +author = Nathaniel J. Smith +author_email = njs@pobox.com +license = MIT OR Apache-2.0 +description = Sniff out which async library your code is running under +long_description = file: README.rst +keywords = async, trio, asyncio +url = https://github.com/python-trio/sniffio +classifiers = + License :: OSI Approved :: MIT License + License :: OSI Approved :: Apache Software License + Framework :: Trio + Framework :: AsyncIO + Operating System :: POSIX :: Linux + Operating System :: MacOS :: MacOS X + Operating System :: Microsoft :: Windows + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: PyPy + Intended Audience :: Developers + Development Status :: 5 - Production/Stable + +[options] +packages = find: +python_requires = >=3.7 +tests_require = curio + +[options.package_data] +sniffio = py.typed diff --git a/setup.py b/setup.py deleted file mode 100644 index 374839c..0000000 --- a/setup.py +++ /dev/null @@ -1,39 +0,0 @@ -from setuptools import setup, find_packages - -exec(open("sniffio/_version.py", encoding="utf-8").read()) - -LONG_DESC = open("README.rst", encoding="utf-8").read() - -setup( - name="sniffio", - version=__version__, - description="Sniff out which async library your code is running under", - url="https://github.com/python-trio/sniffio", - long_description=LONG_DESC, - author="Nathaniel J. Smith", - author_email="njs@pobox.com", - license="MIT OR Apache-2.0", - packages=find_packages(), - package_data={"sniffio": ["py.typed"]}, - keywords=[ - "async", - "trio", - "asyncio", - ], - python_requires=">=3.7", - tests_require=['curio'], - classifiers=[ - "License :: OSI Approved :: MIT License", - "License :: OSI Approved :: Apache Software License", - "Framework :: Trio", - "Framework :: AsyncIO", - "Operating System :: POSIX :: Linux", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Intended Audience :: Developers", - "Development Status :: 5 - Production/Stable", - ], -) diff --git a/sniffio/_version.py b/sniffio/_version.py deleted file mode 100644 index 0de77e3..0000000 --- a/sniffio/_version.py +++ /dev/null @@ -1,3 +0,0 @@ -# This file is imported from __init__.py and exec'd from setup.py - -__version__ = "1.3.0+dev" From 11e9ada18eb633ab408ae185f0ed1fc5535c0d9d Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 19 Oct 2022 13:31:15 +0300 Subject: [PATCH 2/2] Migrated the metadata from `setup.cfg` into `PEP 621`-compliant `pyproject.toml`. --- newsfragments/33.feature.rst | 1 + pyproject.toml | 39 +++++++++++++++++++++++++++++++++++- setup.cfg | 30 --------------------------- 3 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 newsfragments/33.feature.rst delete mode 100644 setup.cfg diff --git a/newsfragments/33.feature.rst b/newsfragments/33.feature.rst new file mode 100644 index 0000000..508e13b --- /dev/null +++ b/newsfragments/33.feature.rst @@ -0,0 +1 @@ +Moved the metadata into ``PEP 621``-compliant ``pyproject.toml``. diff --git a/pyproject.toml b/pyproject.toml index ecd1160..64cf62a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,44 @@ [build-system] -requires = ["setuptools>=42.2", "setuptools_scm[toml]>=3.4.3"] +requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.3"] build-backend = "setuptools.build_meta" +[project] +name = "sniffio" +authors = [{name = "Nathaniel J. Smith", email = "njs@pobox.com"}] +license = {text = "MIT OR Apache-2.0"} +description = "Sniff out which async library your code is running under" +readme = "README.rst" +keywords = ["async", "trio", "asyncio"] +classifiers = [ + "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: Apache Software License", + "Framework :: Trio", + "Framework :: AsyncIO", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Intended Audience :: Developers", + "Development Status :: 5 - Production/Stable", +] +urls = {Homepage = "https://github.com/python-trio/sniffio"} +requires-python = ">=3.7" +dynamic = ["version"] + +[project.optional-dependencies] +testing = ["curio"] + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.setuptools.package-data] +sniffio = ["py.typed"] + [tool.setuptools_scm] write_to = "sniffio/_version.py" write_to_template = "__version__ = \"{version}\"\n" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 757d144..0000000 --- a/setup.cfg +++ /dev/null @@ -1,30 +0,0 @@ -[metadata] -name = sniffio -author = Nathaniel J. Smith -author_email = njs@pobox.com -license = MIT OR Apache-2.0 -description = Sniff out which async library your code is running under -long_description = file: README.rst -keywords = async, trio, asyncio -url = https://github.com/python-trio/sniffio -classifiers = - License :: OSI Approved :: MIT License - License :: OSI Approved :: Apache Software License - Framework :: Trio - Framework :: AsyncIO - Operating System :: POSIX :: Linux - Operating System :: MacOS :: MacOS X - Operating System :: Microsoft :: Windows - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Intended Audience :: Developers - Development Status :: 5 - Production/Stable - -[options] -packages = find: -python_requires = >=3.7 -tests_require = curio - -[options.package_data] -sniffio = py.typed