Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move to flit backend #501

Merged
merged 10 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
agronholm marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload packages
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 4 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
agronholm marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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
agronholm marked this conversation as resolved.
Show resolved Hide resolved
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

151 changes: 151 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
agronholm marked this conversation as resolved.
Show resolved Hide resolved
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 = "[email protected]"}]
maintainers = [{name = "Alex Grönholm", email = "[email protected]"}]
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/*/*.rst",
"docs/Makefile",
"docs/make.bat",
"manpages/*.rst",
"tests/*.py",
"tests/cli/*.py",
"tests/cli/*.txt",
"tests/testdata/*.dist/*.py",
"tests/testdata/*.py",
"tests/testdata/abi3extension.dist/extension.c",
"tests/testdata/abi3extension.dist/setup.cfg",
"tests/testdata/commasinfilenames.dist/mypackage/*.py",
"tests/testdata/commasinfilenames.dist/mypackage/data/*.py",
"tests/testdata/commasinfilenames.dist/mypackage/data/*.txt",
"tests/testdata/commasinfilenames.dist/testrepo-0.1.0/mypackage/*.py",
"tests/testdata/complex-dist/*.py",
"tests/testdata/complex-dist/complexdist/*.py",
"tests/testdata/extension.dist/*.c",
"tests/testdata/headers.dist/header.h",
"tests/testdata/headers.dist/setup.cfg",
"tests/testdata/macosx_minimal_system_version/*.c",
"tests/testdata/macosx_minimal_system_version/*.dylib",
"tests/testdata/simple.dist/simpledist/*.py",
"tests/testdata/test-1.0-py2.py3-none-any.whl",
"tests/testdata/unicode.dist/unicodedist/*.py",
"tox.ini",
agronholm marked this conversation as resolved.
Show resolved Hide resolved
agronholm marked this conversation as resolved.
Show resolved Hide resolved
]
exclude = [
".cirrus.yml",
".github/*",
".github/*/*",
".gitignore",
".pre-commit-config.yaml",
".readthedocs.yml",
"__pycache__",
"*/__pycache__",
"*/*/__pycache__",
"*/*/*/__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
commands = {envpython} -b -m pytest tests/test_sdist.py {posargs}
'''
67 changes: 0 additions & 67 deletions setup.cfg

This file was deleted.

5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

47 changes: 47 additions & 0 deletions tests/test_sdist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import subprocess
agronholm marked this conversation as resolved.
Show resolved Hide resolved
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"})
21 changes: 0 additions & 21 deletions tox.ini

This file was deleted.