Skip to content

Commit 0de0c1a

Browse files
authored
feat: move to flit backend (#501)
1 parent 182efc0 commit 0de0c1a

File tree

9 files changed

+188
-128
lines changed

9 files changed

+188
-128
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
with:
1616
python-version: 3.x
1717
- name: Install dependencies
18-
run: pip install build -e .
18+
run: pip install flit
1919
- name: Create packages
20-
run: python -m build -n -s -w .
20+
run: flit build --setup-py
2121
- name: Upload packages
2222
uses: pypa/gh-action-pypi-publish@release/v1
2323
with:

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ jobs:
4040
path: ~/.cache/pip
4141
key: pip-test-${{ matrix.python-version }}-${{ matrix.os }}
4242
- name: Install the project
43-
run: "pip install --no-binary=:all: ."
43+
run: pip install --no-binary=wheel .
4444
- name: Install test dependencies
4545
run: pip install .[test] coverage[toml]
46+
- name: Include SDist check dependencies
47+
if: matrix.python-version == '3.11'
48+
run: pip install build flit
4649
- name: Test with pytest
4750
run: |
4851
coverage run -m pytest -W always

.pre-commit-config.yaml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,16 @@ repos:
1717
- id: requirements-txt-fixer
1818
- id: trailing-whitespace
1919

20-
- repo: https://github.com/pycqa/isort
21-
rev: 5.12.0
20+
- repo: https://github.com/charliermarsh/ruff-pre-commit
21+
rev: v0.0.254
2222
hooks:
23-
- id: isort
24-
args: ["-a", "from __future__ import annotations"]
25-
26-
- repo: https://github.com/asottile/pyupgrade
27-
rev: v3.3.1
28-
hooks:
29-
- id: pyupgrade
30-
args: ["--py37-plus"]
23+
- id: ruff
24+
args: [--fix, --show-fixes]
3125

3226
- repo: https://github.com/psf/black
3327
rev: 23.1.0
3428
hooks:
3529
- id: black
36-
args: [--target-version=py37]
37-
38-
- repo: https://github.com/PyCQA/flake8
39-
rev: 6.0.0
40-
hooks:
41-
- id: flake8
42-
additional_dependencies: [flake8-bugbear]
4330

4431
- repo: https://github.com/codespell-project/codespell
4532
rev: v2.2.2
@@ -49,10 +36,6 @@ repos:
4936
- repo: https://github.com/pre-commit/pygrep-hooks
5037
rev: v1.10.0
5138
hooks:
52-
- id: python-check-blanket-noqa
53-
- id: python-check-blanket-type-ignore
54-
- id: python-no-eval
55-
- id: python-use-type-annotations
5639
- id: rst-backticks
5740
- id: rst-directive-colons
5841
- id: rst-inline-touching-normal

MANIFEST.in

Lines changed: 0 additions & 11 deletions
This file was deleted.

pyproject.toml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
[build-system]
2+
requires = ["flit_core >=3.8,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "wheel"
7+
description = "A built-package format for Python"
8+
readme = "README.rst"
9+
classifiers = [
10+
"Development Status :: 5 - Production/Stable",
11+
"Intended Audience :: Developers",
12+
"Topic :: System :: Archiving :: Packaging",
13+
"License :: OSI Approved :: MIT License",
14+
"Programming Language :: Python",
15+
"Programming Language :: Python :: 3 :: Only",
16+
"Programming Language :: Python :: 3.7",
17+
"Programming Language :: Python :: 3.8",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
]
22+
authors = [{name = "Daniel Holth", email = "[email protected]"}]
23+
maintainers = [{name = "Alex Grönholm", email = "[email protected]"}]
24+
keywords = ["wheel", "packaging"]
25+
license = {file = "LICENSE.txt"}
26+
requires-python = ">=3.7"
27+
dynamic = ["version"]
28+
29+
[project.urls]
30+
Documentation = "https://wheel.readthedocs.io/"
31+
Changelog = "https://wheel.readthedocs.io/en/stable/news.html"
32+
"Issue Tracker" = "https://github.com/pypa/wheel/issues"
33+
34+
[project.scripts]
35+
wheel = "wheel.cli:main"
36+
37+
[project.entry-points."distutils.commands"]
38+
bdist_wheel = "wheel.bdist_wheel:bdist_wheel"
39+
40+
[project.optional-dependencies]
41+
test = [
42+
"pytest >= 6.0.0"
43+
]
44+
45+
[tool.flit.sdist]
46+
include = [
47+
"LICENSE*",
48+
"docs/**/*.py",
49+
"docs/**/*.rst",
50+
"docs/Makefile",
51+
"docs/make.bat",
52+
"manpages/*.rst",
53+
"tests/**/*.py",
54+
"tests/**/*.txt",
55+
"tests/**/*.c",
56+
"tests/**/*.h",
57+
"tests/**/*.cfg",
58+
"tests/testdata/macosx_minimal_system_version/*.dylib",
59+
"tests/testdata/test-1.0-py2.py3-none-any.whl",
60+
]
61+
exclude = [
62+
".cirrus.yml",
63+
".github/**",
64+
".gitignore",
65+
".pre-commit-config.yaml",
66+
".readthedocs.yml",
67+
"**/__pycache__",
68+
]
69+
70+
[tool.black]
71+
target-version = ['py37']
72+
extend-exclude = '''
73+
^/src/wheel/vendored/
74+
'''
75+
76+
[tool.pytest.ini_options]
77+
testpaths = "tests"
78+
79+
[tool.coverage.run]
80+
source = ["wheel"]
81+
omit = ["*/vendored/*"]
82+
83+
[tool.coverage.report]
84+
show_missing = true
85+
86+
[tool.ruff]
87+
line-length = 88
88+
select = [
89+
"E", "F", "W", # default flake-8
90+
"I", # isort
91+
"PGH", # pygrep-hooks
92+
"UP", # pyupgrade
93+
"B0", # flake8-bugbear
94+
]
95+
ignore = [
96+
"E501", # Line too long
97+
]
98+
target-version = "py37"
99+
src = ["src"]
100+
101+
[tool.tox]
102+
legacy_tox_ini = '''
103+
# Tox (http://tox.testrun.org/) is a tool for running tests
104+
# in multiple virtualenvs. This configuration file will run the
105+
# test suite on all supported python versions. To use it, "pip install tox"
106+
# and then run "tox" from this directory.
107+
108+
[tox]
109+
envlist = py37, py38, py39, py310, py311, pypy3, lint, pkg
110+
minversion = 4.0.0
111+
skip_missing_interpreters = true
112+
113+
[testenv]
114+
depends = lint
115+
commands = {envpython} -b -m pytest -W always {posargs}
116+
extras = test
117+
118+
[testenv:lint]
119+
depends =
120+
basepython = python3
121+
deps = pre-commit
122+
commands = pre-commit run --all-files --show-diff-on-failure
123+
skip_install = true
124+
125+
[testenv:pkg]
126+
basepython = python3
127+
deps =
128+
build
129+
flit>=3.8
130+
commands = {envpython} -b -m pytest tests/test_sdist.py {posargs}
131+
'''

setup.cfg

Lines changed: 0 additions & 67 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/test_sdist.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import subprocess
2+
import sys
3+
import tarfile
4+
from pathlib import Path
5+
6+
import pytest
7+
8+
pytest.importorskip("flit")
9+
pytest.importorskip("build")
10+
11+
# This test must be run from the source directory - okay to skip if not
12+
DIR = Path(__file__).parent.resolve()
13+
MAIN_DIR = DIR.parent
14+
15+
16+
def test_compare_sdists(monkeypatch, tmp_path):
17+
monkeypatch.chdir(MAIN_DIR)
18+
19+
sdist_build_dir = tmp_path / "bdir"
20+
21+
subprocess.run(
22+
[
23+
sys.executable,
24+
"-m",
25+
"build",
26+
"--sdist",
27+
"--no-isolation",
28+
f"--outdir={sdist_build_dir}",
29+
],
30+
check=True,
31+
)
32+
33+
(sdist_build,) = sdist_build_dir.glob("*.tar.gz")
34+
35+
# Flit doesn't allow targeting directories, as far as I can tell
36+
subprocess.run(
37+
[sys.executable, "-m", "flit", "build", "--format=sdist"], check=True
38+
)
39+
40+
(sdist_flit,) = Path("dist").glob("*.tar.gz")
41+
42+
out = [set(), set()]
43+
for i, sdist in enumerate([sdist_build, sdist_flit]):
44+
with tarfile.open(str(sdist), "r:gz") as tar:
45+
out[i] = set(tar.getnames())
46+
47+
assert out[0] == (out[1] - {"setup.py"})

tox.ini

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)