diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f5a5312da..d03f16fd6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,10 +3,10 @@ name: Linting on: pull_request: paths: - - '**.py' + - "**.py" push: paths: - - '**.py' + - "**.py" jobs: lint: @@ -14,20 +14,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v1 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.9' + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: "3.9" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --upgrade nox + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade nox - - name: Run `nox -s lint` - run: python -m nox -s lint + - name: Run `nox -s lint` + run: python -m nox -s lint build: name: Build sdist and wheel @@ -39,21 +39,21 @@ jobs: needs: lint steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v1 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.9' + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: "3.9" - - name: Install dependencies - run: python -m pip install --upgrade setuptools wheel + - name: Install dependencies + run: python -m pip install --upgrade build - - name: Build - run: python setup.py sdist bdist_wheel + - name: Build + run: python -m build - - name: Archive files - uses: actions/upload-artifact@v1 - with: - name: dist - path: dist + - name: Archive files + uses: actions/upload-artifact@v1 + with: + name: dist + path: dist diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3dd1dd1a..ec7765edd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,37 +1,32 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 - hooks: - - id: check-toml - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.790 - hooks: - - id: mypy - exclude: '^(docs|tasks|tests)|setup\.py' - args: [] - - id: mypy - name: mypy for Python 2 - exclude: '^(docs|tasks|tests)|setup\.py|noxfile\.py' - args: ['--py2'] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.790 + hooks: + - id: mypy + exclude: '^(docs|tasks|tests)|setup\.py' + args: [] + - id: mypy + name: mypy for Python 2 + exclude: '^(docs|tasks|tests)|setup\.py|noxfile\.py' + args: ["--py2"] -- repo: https://github.com/psf/black - rev: 19.3b0 - hooks: - - id: black + - repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black -- repo: https://gitlab.com/PyCQA/flake8 - rev: '3.7.8' - hooks: - - id: flake8 - additional_dependencies: ['pep8-naming'] - # Ignore all format-related checks as Black takes care of those. - args: ['--ignore', 'E2,W5', '--select', 'E,W,F,N'] - -- repo: https://github.com/mgedmin/check-manifest - rev: '0.39' - hooks: - - id: check-manifest + - repo: https://gitlab.com/PyCQA/flake8 + rev: "3.7.8" + hooks: + - id: flake8 + additional_dependencies: ["pep8-naming"] + # Ignore all format-related checks as Black takes care of those. + args: ["--ignore", "E2,W5", "--select", "E,W,F,N"] diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1c85a81f6..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,20 +0,0 @@ -include CHANGELOG.rst CONTRIBUTING.rst README.rst -include LICENSE LICENSE.APACHE LICENSE.BSD - -include .coveragerc -include .flake8 -include .pre-commit-config.yaml - -recursive-include docs * -recursive-include tests *.py -recursive-include tests hello-world-* - -exclude noxfile.py -exclude .readthedocs.yml -exclude .travis.yml -exclude dev-requirements.txt -exclude tests/build-hello-world.sh -exclude tests/hello-world.c - -prune docs/_build -prune tasks diff --git a/docs/conf.py b/docs/conf.py index cdd1ac119..3bd4b13aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -43,11 +43,11 @@ base_dir = os.path.join(os.path.dirname(__file__), os.pardir) about = {} -with open(os.path.join(base_dir, "packaging", "__about__.py")) as f: +with open(os.path.join(base_dir, "packaging", "__init__.py")) as f: exec(f.read(), about) version = release = about["__version__"] -copyright = about["__copyright__"] +copyright = "2014-2019 Donald Stufft and individual contributors" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/setup.cfg b/mypy.ini similarity index 95% rename from setup.cfg rename to mypy.ini index c67cd2261..e19734855 100644 --- a/setup.cfg +++ b/mypy.ini @@ -1,6 +1,3 @@ -[bdist_wheel] -universal=1 - [mypy] ignore_missing_imports = True diff --git a/noxfile.py b/noxfile.py index fb6ff0420..b99656051 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,6 +25,7 @@ def tests(session): def coverage(*args): session.run("python", "-m", "coverage", *args) + # Once coverage 5 is used then `.coverage` can move into `pyproject.toml`. session.install("coverage<5.0.0", "pretend", "pytest", "pip>=9.0.2") if "pypy" not in session.python: @@ -52,8 +53,8 @@ def lint(session): session.run("pre-commit", "run", "--all-files") # Check the distribution - session.install("setuptools", "twine", "wheel") - session.run("python", "setup.py", "--quiet", "sdist", "bdist_wheel") + session.install("build", "twine") + session.run("python", "-m", "build") session.run("twine", "check", *glob.glob("dist/*")) @@ -123,10 +124,10 @@ def release(session): # Checkout the git tag. session.run("git", "checkout", "-q", release_version, external=True) - session.install("twine", "setuptools", "wheel") + session.install("build", "twine") # Build the distribution. - session.run("python", "setup.py", "sdist", "bdist_wheel") + session.run("python", "-m", "build") # Check what files are in dist/ for upload. files = sorted(glob.glob("dist/*")) diff --git a/packaging/__about__.py b/packaging/__about__.py deleted file mode 100644 index eec7ebe16..000000000 --- a/packaging/__about__.py +++ /dev/null @@ -1,27 +0,0 @@ -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. -from __future__ import absolute_import, division, print_function - -__all__ = [ - "__title__", - "__summary__", - "__uri__", - "__version__", - "__author__", - "__email__", - "__license__", - "__copyright__", -] - -__title__ = "packaging" -__summary__ = "Core utilities for Python packages" -__uri__ = "https://github.com/pypa/packaging" - -__version__ = "20.5.dev0" - -__author__ = "Donald Stufft and individual contributors" -__email__ = "donald@stufft.io" - -__license__ = "BSD-2-Clause or Apache-2.0" -__copyright__ = "2014-2019 %s" % __author__ diff --git a/packaging/__init__.py b/packaging/__init__.py index a0cf67df5..7220d31ed 100644 --- a/packaging/__init__.py +++ b/packaging/__init__.py @@ -1,26 +1,5 @@ # This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -from __future__ import absolute_import, division, print_function - -from .__about__ import ( - __author__, - __copyright__, - __email__, - __license__, - __summary__, - __title__, - __uri__, - __version__, -) - -__all__ = [ - "__title__", - "__summary__", - "__uri__", - "__version__", - "__author__", - "__email__", - "__license__", - "__copyright__", -] +"""Core utilities for Python packages""" +__version__ = "20.5.dev0" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..4397392f0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = ["flit_core >=2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.metadata] +module = "packaging" +author = "Donald Stufft and individual contributors" +author-email = "donald@stufft.io" +home-page = "https://github.com/pypa/packaging" +description-file = "README.rst" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +requires = ["pyparsing>=2.0.2"] + +[tool.flit.metadata.urls] +Documentation = "https://packaging.pypa.io/" +Changelog = "https://packaging.pypa.io/en/latest/changelog.html" diff --git a/setup.py b/setup.py deleted file mode 100644 index fd8562067..000000000 --- a/setup.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. -from __future__ import absolute_import, division, print_function - -import os -import re - -# While I generally consider it an antipattern to try and support both -# setuptools and distutils with a single setup.py, in this specific instance -# where packaging is a dependency of setuptools, it can create a circular -# dependency when projects attempt to unbundle stuff from setuptools and pip. -# Though we don't really support that, it makes things easier if we do this and -# should hopefully cause less issues for end users. -try: - from setuptools import setup -except ImportError: - from distutils.core import setup - - -base_dir = os.path.dirname(__file__) - -about = {} -with open(os.path.join(base_dir, "packaging", "__about__.py")) as f: - exec(f.read(), about) - -with open(os.path.join(base_dir, "README.rst")) as f: - long_description = f.read() - -with open(os.path.join(base_dir, "CHANGELOG.rst")) as f: - # Remove :issue:`ddd` tags that breaks the description rendering - changelog = re.sub( - r":issue:`(\d+)`", - r"`#\1 `__", - f.read(), - ) - long_description = "\n".join([long_description, changelog]) - - -setup( - name=about["__title__"], - version=about["__version__"], - description=about["__summary__"], - long_description=long_description, - long_description_content_type="text/x-rst", - license=about["__license__"], - url=about["__uri__"], - author=about["__author__"], - author_email=about["__email__"], - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", - install_requires=["pyparsing>=2.0.2"], # Needed to avoid issue #91 - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - packages=["packaging"], - package_data={"packaging": ["py.typed"]}, -)