diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b3e521d7..54106395 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,9 +15,9 @@ jobs: with: python-version: 3.x - name: Install dependencies - run: pip install build -e . + run: pip install flit - name: Create packages - run: python -m build -n -s -w . + run: flit build --setup-py - name: Upload packages uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1bca612..790a0784 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,9 +40,12 @@ jobs: path: ~/.cache/pip key: pip-test-${{ matrix.python-version }}-${{ matrix.os }} - name: Install the project - run: "pip install --no-binary=:all: ." + run: pip install --no-binary=wheel . - name: Install test dependencies run: pip install .[test] coverage[toml] + - name: Include SDist check dependencies + if: matrix.python-version == '3.11' + run: pip install build flit - name: Test with pytest run: | coverage run -m pytest -W always diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21e13b02..22244554 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,29 +17,16 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace -- repo: https://github.com/pycqa/isort - rev: 5.12.0 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.254 hooks: - - id: isort - args: ["-a", "from __future__ import annotations"] - -- repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: ["--py37-plus"] + - id: ruff + args: [--fix, --show-fixes] - repo: https://github.com/psf/black rev: 23.1.0 hooks: - id: black - args: [--target-version=py37] - -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - additional_dependencies: [flake8-bugbear] - repo: https://github.com/codespell-project/codespell rev: v2.2.2 @@ -49,10 +36,6 @@ repos: - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - - id: python-no-eval - - id: python-use-type-annotations - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d5d5b3e2..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,11 +0,0 @@ -recursive-include src *.py -recursive-include tests *.py *.h *.txt *.c *.dylib -recursive-include docs *.py *.rst make.bat Makefile -include tests/testdata/test-1.0-py2.py3-none-any.whl -include tox.ini -include manpages/*.rst -include LICENSE.txt -include src/wheel/vendored/vendor.txt -prune tests/testdata/*/build -prune tests/testdata/*/dist -prune tests/testdata/*/*.egg-info diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..13715634 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,131 @@ +[build-system] +requires = ["flit_core >=3.8,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "wheel" +description = "A built-package format for Python" +readme = "README.rst" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: System :: Archiving :: Packaging", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "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", +] +authors = [{name = "Daniel Holth", email = "dholth@fastmail.fm"}] +maintainers = [{name = "Alex Grönholm", email = "alex.gronholm@nextday.fi"}] +keywords = ["wheel", "packaging"] +license = {file = "LICENSE.txt"} +requires-python = ">=3.7" +dynamic = ["version"] + +[project.urls] +Documentation = "https://wheel.readthedocs.io/" +Changelog = "https://wheel.readthedocs.io/en/stable/news.html" +"Issue Tracker" = "https://github.com/pypa/wheel/issues" + +[project.scripts] +wheel = "wheel.cli:main" + +[project.entry-points."distutils.commands"] +bdist_wheel = "wheel.bdist_wheel:bdist_wheel" + +[project.optional-dependencies] +test = [ + "pytest >= 6.0.0" +] + +[tool.flit.sdist] +include = [ + "LICENSE*", + "docs/**/*.py", + "docs/**/*.rst", + "docs/Makefile", + "docs/make.bat", + "manpages/*.rst", + "tests/**/*.py", + "tests/**/*.txt", + "tests/**/*.c", + "tests/**/*.h", + "tests/**/*.cfg", + "tests/testdata/macosx_minimal_system_version/*.dylib", + "tests/testdata/test-1.0-py2.py3-none-any.whl", +] +exclude = [ + ".cirrus.yml", + ".github/**", + ".gitignore", + ".pre-commit-config.yaml", + ".readthedocs.yml", + "**/__pycache__", +] + +[tool.black] +target-version = ['py37'] +extend-exclude = ''' +^/src/wheel/vendored/ +''' + +[tool.pytest.ini_options] +testpaths = "tests" + +[tool.coverage.run] +source = ["wheel"] +omit = ["*/vendored/*"] + +[tool.coverage.report] +show_missing = true + +[tool.ruff] +line-length = 88 +select = [ + "E", "F", "W", # default flake-8 + "I", # isort + "PGH", # pygrep-hooks + "UP", # pyupgrade + "B0", # flake8-bugbear +] +ignore = [ + "E501", # Line too long +] +target-version = "py37" +src = ["src"] + +[tool.tox] +legacy_tox_ini = ''' +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py37, py38, py39, py310, py311, pypy3, lint, pkg +minversion = 4.0.0 +skip_missing_interpreters = true + +[testenv] +depends = lint +commands = {envpython} -b -m pytest -W always {posargs} +extras = test + +[testenv:lint] +depends = +basepython = python3 +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure +skip_install = true + +[testenv:pkg] +basepython = python3 +deps = + build + flit>=3.8 +commands = {envpython} -b -m pytest tests/test_sdist.py {posargs} +''' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e6a9d5a3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,67 +0,0 @@ -[metadata] -name = wheel -version = attr: wheel.__version__ -description = A built-package format for Python -long_description = file: README.rst -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Topic :: System :: Archiving :: Packaging - License :: OSI Approved :: MIT License - Programming Language :: Python - Programming Language :: Python :: 3 :: Only - 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 -author = Daniel Holth -author_email = dholth@fastmail.fm -maintainer = Alex Grönholm -maintainer_email = alex.gronholm@nextday.fi -url = https://github.com/pypa/wheel -project_urls = - Documentation = https://wheel.readthedocs.io/ - Changelog = https://wheel.readthedocs.io/en/stable/news.html - Issue Tracker = https://github.com/pypa/wheel/issues -keywords = wheel, packaging -license = MIT - -[options] -package_dir= - = src -packages = find: -python_requires = >=3.7 -zip_safe = False - -[options.packages.find] -where = src - -[options.extras_require] -test = - pytest >= 3.0.0 - -[options.entry_points] -console_scripts = - wheel = wheel.cli:main -distutils.commands = - bdist_wheel = wheel.bdist_wheel:bdist_wheel - -[tool:isort] -src_paths = src -profile = black -skip_gitignore = true - -[flake8] -max-line-length = 88 -extend-ignore = B028 - -[tool:pytest] -testpaths = tests - -[coverage:run] -source = wheel -omit = */vendored/* - -[coverage:report] -show_missing = true diff --git a/setup.py b/setup.py deleted file mode 100644 index a03590f5..00000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - -setup() diff --git a/tests/test_sdist.py b/tests/test_sdist.py new file mode 100644 index 00000000..413e3207 --- /dev/null +++ b/tests/test_sdist.py @@ -0,0 +1,47 @@ +import subprocess +import sys +import tarfile +from pathlib import Path + +import pytest + +pytest.importorskip("flit") +pytest.importorskip("build") + +# This test must be run from the source directory - okay to skip if not +DIR = Path(__file__).parent.resolve() +MAIN_DIR = DIR.parent + + +def test_compare_sdists(monkeypatch, tmp_path): + monkeypatch.chdir(MAIN_DIR) + + sdist_build_dir = tmp_path / "bdir" + + subprocess.run( + [ + sys.executable, + "-m", + "build", + "--sdist", + "--no-isolation", + f"--outdir={sdist_build_dir}", + ], + check=True, + ) + + (sdist_build,) = sdist_build_dir.glob("*.tar.gz") + + # Flit doesn't allow targeting directories, as far as I can tell + subprocess.run( + [sys.executable, "-m", "flit", "build", "--format=sdist"], check=True + ) + + (sdist_flit,) = Path("dist").glob("*.tar.gz") + + out = [set(), set()] + for i, sdist in enumerate([sdist_build, sdist_flit]): + with tarfile.open(str(sdist), "r:gz") as tar: + out[i] = set(tar.getnames()) + + assert out[0] == (out[1] - {"setup.py"}) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1d170e60..00000000 --- a/tox.ini +++ /dev/null @@ -1,21 +0,0 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - -[tox] -envlist = py37, py38, py39, py310, py311, pypy3, lint -minversion = 3.3.0 -skip_missing_interpreters = true - -[testenv] -depends = lint -commands = {envpython} -b -m pytest -W always {posargs} -extras = test - -[testenv:lint] -depends = -basepython = python3 -deps = pre-commit -commands = pre-commit run --all-files --show-diff-on-failure -skip_install = true