From 486d003829f00bb7be43ed4a05188e52466895f8 Mon Sep 17 00:00:00 2001 From: kalebmckale Date: Fri, 1 Sep 2023 08:54:39 -0400 Subject: [PATCH 1/2] Update build to use exclusively pyproject.toml - consolidates all of `setuptools` metadata and configuration as well as `coverage` configuration within `pyproject.toml`. - removes deprecated `setup.cfg` and `setup.py`. - updates `run-tests.sh` to use `pyproject.toml` instead of `setup.cfg` for `coverage` configuration. --- news/5837.feature.rst | 4 + pyproject.toml | 221 ++++++++++++++++++++++++++++++------------ run-tests.sh | 4 +- setup.cfg | 7 -- setup.py | 90 ----------------- 5 files changed, 165 insertions(+), 161 deletions(-) create mode 100644 news/5837.feature.rst delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/news/5837.feature.rst b/news/5837.feature.rst new file mode 100644 index 00000000..ff58f4a6 --- /dev/null +++ b/news/5837.feature.rst @@ -0,0 +1,4 @@ +Updates build to use exclusively ``pyproject.toml`` +--------------------------------------------------- + +Modernizes the build process by consolidating all of ``setuptools`` metadata within ``pyproject.toml`` and removing deprecated ``setup.cfg`` and ``setup.py``. diff --git a/pyproject.toml b/pyproject.toml index 448b4f2a..79824c85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,92 @@ [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools>=67.0.0"] build-backend = "setuptools.build_meta" + +[project] +name = "pipenv" +authors = [ + {name = "Pipenv maintainer team", email = "distutils-sig@python.org"}, +] +description = "Python Development Workflow for Humans." +readme = "README.md" +requires-python = ">=3.7" +license = {file = "LICENSE"} +classifiers=[ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + "certifi", + "setuptools>=67.0.0", + "virtualenv>=20.24.2", +] +dynamic = ["version"] + + +[project.optional-dependencies] +dev = [ + "towncrier", + "beautifulsoup4", + "sphinx", + "flake8>=3.3.0,<4.0", + "black==23.3.0", + "parver", + "invoke", +] +tests = [ + "pytest>=5.0", + "pytest-timeout", + "pytest-xdist", + "flaky", + "mock", +] + + +[project.scripts] +pipenv = "pipenv:cli" +pipenv-resolver = "pipenv.resolver:main" + + +[project.urls] +Homepage = "https://github.com/pypa/pipenv" +Documentation = "https://pipenv.pypa.io/en/latest/" +Source = "https://github.com/pypa/pipenv.git" + + +[tool.setuptools.packages.find] +where = ["."] +exclude = ["tests*", "tests.*", "tasks*", "tasks.*"] + + +[tool.setuptools.package-data] +"*" = ["LICENSE", "NOTICES"] +"pipenv.patched.safety" = ["VERSION", "safety-policy-template.yml"] +"pipenv.patched.pip._vendor.certifi" = ["*.pem"] +"pipenv.patched.pip._vendor.requests" = ["*.pem"] +"pipenv.patched.pip._vendor.distlib" = [ + "t32.exe", + "t64.exe", + "w32.exe", + "w64.exe", +] +"pipenv.vendor.ruamel" = ["yaml"] + + +[tool.setuptools.dynamic] +version = {attr = "pipenv.__version__"} + + +## TESTING AND DEVELOPER CONFIGURATION BELOW ## + [tool.black] line-length = 90 include = '\.pyi?$' @@ -28,6 +113,11 @@ exclude = ''' ) ''' + +[tool.coverage.run] +parallel = true + + [tool.mypy] ignore_missing_imports = true follow_imports = "skip" @@ -35,6 +125,7 @@ html_report = "mypyhtml" python_version = "3.7" mypy_path = "typeshed/pyi:typeshed/imports" + [tool.pytest.ini_options] addopts = "-ra" plugins = "xdist" @@ -42,87 +133,91 @@ testpaths = ["tests"] # Add vendor and patched in addition to the default list of ignored dirs # Additionally, ignore tasks, news, test subdirectories and peeps directory norecursedirs = [ - ".*", "build", - "dist", - "CVS", - "_darcs", - "{arch}", - "*.egg", - "vendor", - "patched", - "news", - "tasks", - "docs", - "tests/test_artifacts", - "tests/pypi", - "peeps", + ".*", + "build", + "dist", + "CVS", + "_darcs", + "{arch}", + "*.egg", + "vendor", + "patched", + "news", + "tasks", + "docs", + "tests/test_artifacts", + "tests/pypi", + "peeps", ] filterwarnings = [] # These are not all the custom markers, but most of the ones with repeat uses # `pipenv run pytest --markers` will list all markers including these markers = [ - "install: tests having to do with `pipenv install`", - "update: tests having to do with `pipenv update`", - "needs_internet: integration tests that require internet to pass", - "basic: basic pipenv tests grouping", - "dev: tests having to do with dev and dev packages", - "system: related or interacting with the os", - "utils: grouping of pipenv utility functions", - "cli: test grouping that relate to command line like `pipenv --flag args`", - "requirements: tests that save and alter pip requirements", - "run: tests that run or execute python through pipenv", - "script: grouping of tests that execute scripts", - "keep_outdated: when an activity is supposed to keep something out of date", - "lock: tests that interact with pipenv lock", - "markers: pipenv environment markers", - "vcs: tests integration with pipenv and vertsion control systems", - "project: tests with the project object", - "sync: related to `pipenv sync`", - "rrule: relating to rrules (as in recurring time)", - "tzoffset: timezone offset", - "gettz: tests with gettz (get timezone) from dateutil lib", - "tzstr: timezone string", - "extras", - "extended", - "ext: extra non-categorized tests", + "install: tests having to do with `pipenv install`", + "update: tests having to do with `pipenv update`", + "needs_internet: integration tests that require internet to pass", + "basic: basic pipenv tests grouping", + "dev: tests having to do with dev and dev packages", + "system: related or interacting with the os", + "utils: grouping of pipenv utility functions", + "cli: test grouping that relate to command line like `pipenv --flag args`", + "requirements: tests that save and alter pip requirements", + "run: tests that run or execute python through pipenv", + "script: grouping of tests that execute scripts", + "keep_outdated: when an activity is supposed to keep something out of date", + "lock: tests that interact with pipenv lock", + "markers: pipenv environment markers", + "vcs: tests integration with pipenv and vertsion control systems", + "project: tests with the project object", + "sync: related to `pipenv sync`", + "rrule: relating to rrules (as in recurring time)", + "tzoffset: timezone offset", + "gettz: tests with gettz (get timezone) from dateutil lib", + "tzstr: timezone string", + "extras", + "extended", + "ext: extra non-categorized tests", ] + [tool.ruff] exclude = [ - "pipenv/patched/*", - "pipenv/vendor/*", + "pipenv/patched/*", + "pipenv/vendor/*", ] select = [ - "ASYNC", - "B", - "C4", - "C90", - "E", - "F", - "FLY", - "G", - "I", - "ISC", - "PERF", - "PIE", - "PL", - "TID", - "UP", - "W", - "YTT" + "ASYNC", + "B", + "C4", + "C90", + "E", + "F", + "FLY", + "G", + "I", + "ISC", + "PERF", + "PIE", + "PL", + "TID", + "UP", + "W", + "YTT" ] ignore = [ - "B904", - "PIE790", - "PLR5501", - "PLW2901", + "B904", + "PIE790", + "PLR5501", + "PLW2901", ] line-length = 137 target-version = "py37" + [tool.ruff.mccabe] max-complexity = 44 + [tool.ruff.pylint] allow-magic-value-types = ["int", "str"] max-args = 20 @@ -130,6 +225,7 @@ max-branches = 38 max-returns = 9 max-statements = 155 + [tool.ruff.per-file-ignores] "docs/conf.py" = ["E402", "E501"] "get-pipenv.py" = ["E402"] @@ -144,6 +240,7 @@ max-statements = 155 "tests/unit/test_funktools.py" = ["B015"] "tests/unit/test_utils.py" = ["F811"] + [tool.towncrier] package = "pipenv" filename = "CHANGELOG.rst" diff --git a/run-tests.sh b/run-tests.sh index c192760a..8d589726 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -55,6 +55,6 @@ echo "pipenv run pypi-server run -v --host=0.0.0.0 --port=8080 --hash-algo=sha25 pipenv run pypi-server run -v --host=0.0.0.0 --port=8080 --hash-algo=sha256 --disable-fallback ./tests/pypi/ ./tests/fixtures & -echo "$pipenv run pytest -v -ra -n auto --cov-config setup.cfg --fulltrace tests" +echo "$pipenv run pytest -v -ra -n auto --cov-config pyproject.toml --fulltrace tests" -PIPENV_PYTHON=${PIPENV_PYTHON} ${PYTHON} -m pipenv run pytest -v -ra -n auto --cov-config setup.cfg --fulltrace tests +PIPENV_PYTHON=${PIPENV_PYTHON} ${PYTHON} -m pipenv run pytest -v -ra -n auto --cov-config pyproject.toml --fulltrace tests diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 69c33cd6..00000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[metadata] -long_description = file: README.md -license = MIT -license_files = LICENSE - -[coverage:run] -parallel = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 2a9b40f1..00000000 --- a/setup.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env python -import codecs -import os -import sys - -from setuptools import find_packages, setup - -here = os.path.abspath(os.path.dirname(__file__)) - -with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as f: - long_description = "\n" + f.read() - -about = {} - -with open(os.path.join(here, "pipenv", "__version__.py")) as f: - exec(f.read(), about) - -if sys.argv[-1] == "publish": - os.system("python setup.py sdist bdist_wheel upload") - sys.exit() - -required = [ - "certifi", - "setuptools>=67.0.0", - "virtualenv>=20.24.2", -] -extras = { - "dev": [ - "towncrier", - "beautifulsoup4", - "sphinx", - "flake8>=3.3.0,<4.0", - "black==23.3.0", - "parver", - "invoke", - ], - "tests": ["pytest>=5.0", "pytest-timeout", "pytest-xdist", "flaky", "mock"], -} - - -setup( - name="pipenv", - version=about["__version__"], - description="Python Development Workflow for Humans.", - long_description=long_description, - long_description_content_type="text/markdown", - author="Pipenv maintainer team", - author_email="distutils-sig@python.org", - url="https://github.com/pypa/pipenv", - packages=find_packages(exclude=["tests", "tests.*", "tasks", "tasks.*"]), - entry_points={ - "console_scripts": [ - "pipenv=pipenv:cli", - "pipenv-resolver=pipenv.resolver:main", - ] - }, - package_data={ - "": ["LICENSE", "NOTICES"], - "pipenv.patched.safety": ["VERSION", "safety-policy-template.yml"], - "pipenv.patched.pip._vendor.certifi": ["*.pem"], - "pipenv.patched.pip._vendor.requests": ["*.pem"], - "pipenv.patched.pip._vendor.distlib._backport": ["sysconfig.cfg"], - "pipenv.patched.pip._vendor.distlib": [ - "t32.exe", - "t64.exe", - "w32.exe", - "w64.exe", - ], - "pipenv.vendor.ruamel": ["yaml"], - }, - python_requires=">=3.7", - zip_safe=True, - setup_requires=[], - install_requires=required, - extras_require=extras, - include_package_data=True, - license="MIT", - classifiers=[ - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], -) From 5f220a0a360983abcb3e7a6d6d1e220dc3948a2f Mon Sep 17 00:00:00 2001 From: kalebmckale Date: Fri, 1 Sep 2023 08:57:17 -0400 Subject: [PATCH 2/2] Replace "python setup.py" builds with "python -m build" Found left-over remnants of `setup.py` install and updated with current build method using `build` package. --- .github/workflows/pypi_upload.yml | 4 ++-- Makefile | 4 ++-- tasks/release.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index ca19f431..cbbb4d31 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade --upgrade-strategy=eager pip setuptools wheel twine + python -m pip install --upgrade --upgrade-strategy=eager pip setuptools build wheel twine python -m pip install -e . --upgrade python -m pipenv install --dev env: @@ -47,7 +47,7 @@ jobs: - name: Build wheels run: | - python -m pipenv run python setup.py sdist bdist_wheel + python -m pipenv run python -m build # to upload to test pypi, pass repository_url: https://test.pypi.org/legacy/ and use secrets.TEST_PYPI_TOKEN - name: Publish a Python distribution to PyPI diff --git a/Makefile b/Makefile index 44498ac9..fe5f4932 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ venv_dir := $(get_venv_dir)/pipenv_venv venv_file := $(CURDIR)/.test_venv get_venv_path =$(file < $(venv_file)) # This is how we will build tag-specific wheels, e.g. py36 or py37 -PY_VERSIONS:= 3.7 3.8 3.9 3.10 +PY_VERSIONS:= 3.7 3.8 3.9 3.10 3.11 BACKSLASH = '\\' # This is how we will build generic wheels, e.g. py2 or py3 INSTALL_TARGETS := $(addprefix install-py,$(PY_VERSIONS)) @@ -96,7 +96,7 @@ retest: virtualenv submodules test-install .PHONY: build build: install-virtualenvs.stamp install.stamp - PIPENV_PYTHON=3.7 pipenv run python setup.py sdist bdist_wheel + PIPENV_PYTHON=3.7 pipenv run python -m build .PHONY: update-version update-version: diff --git a/tasks/release.py b/tasks/release.py index f828849c..c941c940 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -165,7 +165,7 @@ def build_dists(ctx): ctx.run("pipenv install --dev", env=env) ctx.run("pipenv run pip install -e . --upgrade --upgrade-strategy=eager", env=env) log("Building wheel using python %s ...." % py_version) - ctx.run("pipenv run python setup.py sdist bdist_wheel", env=env) + ctx.run("pipenv run python -m build", env=env) @invoke.task(build_dists)