Skip to content

Commit 7184de2

Browse files
gaborbernatchrysle
andauthored
Add 3.12 support and bump linters (#1118)
Co-authored-by: chrysle <[email protected]>
1 parent f130306 commit 7184de2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+482
-976
lines changed

.github/workflows/create_tests_package_lists.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
name: Create tests package lists for offline tests
22
on:
33
workflow_dispatch:
4-
4+
concurrency:
5+
group: check-${{ github.ref }}
6+
cancel-in-progress: true
57
jobs:
68
create_package_lists:
79
name: Create package lists
810
runs-on: ${{ matrix.os }}
911
strategy:
1012
matrix:
1113
os: [ubuntu-latest, macos-latest, windows-latest]
12-
python-version: ["3.8", "3.9", "3.10", "3.11"]
14+
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
1315

1416
steps:
1517
- uses: actions/checkout@v4

.github/workflows/exhaustive_package_test.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Exhaustive Package Test (slow)
22
on:
33
workflow_dispatch:
4-
4+
concurrency:
5+
group: check-${{ github.ref }}
6+
cancel-in-progress: true
57
jobs:
68
test_all_packages:
79
name: Exhaustive Package Test
@@ -10,7 +12,7 @@ jobs:
1012
strategy:
1113
matrix:
1214
os: [ubuntu-latest, macos-latest, windows-latest]
13-
python-version: ["3.8", "3.9", "3.10", "3.11"]
15+
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
1416

1517
steps:
1618
- uses: actions/checkout@v4

.github/workflows/publish-testpypi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212

1313
env:
14-
default-python: "3.11"
14+
default-python: "3.12"
1515

1616
jobs:
1717
testpypi-publish:

.github/workflows/tests.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99
name: tests
1010

1111
on:
12-
pull_request:
1312
push:
13+
tags-ignore: ["**"]
14+
pull_request:
15+
schedule:
16+
- cron: "0 8 * * *"
17+
concurrency:
18+
group: check-${{ github.ref }}
19+
cancel-in-progress: true
1420

1521
# If changing default-python be sure to change job "tests" matrix: include: also
1622
env:
17-
default-python: "3.11"
23+
default-python: "3.12"
1824

1925
jobs:
2026
lint:
@@ -55,12 +61,12 @@ jobs:
5561
fail-fast: false
5662
matrix:
5763
os: [ubuntu-latest]
58-
python-version: ["3.8", "3.9", "3.10", "3.11"]
64+
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
5965
include:
6066
- os: windows-latest
61-
python-version: "3.11"
67+
python-version: "3.12"
6268
- os: macos-latest
63-
python-version: "3.11"
69+
python-version: "3.12"
6470

6571
steps:
6672
- uses: actions/checkout@v4

.pre-commit-config.yaml

+10-8
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ repos:
1212
- id: check-added-large-files
1313
- id: trailing-whitespace
1414
- id: check-yaml
15-
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.1.3
15+
- repo: https://github.com/tox-dev/pyproject-fmt
16+
rev: "1.5.2"
1717
hooks:
18-
- id: ruff
19-
- repo: https://github.com/psf/black
20-
rev: 23.10.1
18+
- id: pyproject-fmt
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.1.6
2121
hooks:
22-
- id: black
22+
- id: ruff-format
23+
- id: ruff
24+
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
2325
# mypy args:
2426
# must include --ignore-missing-imports for mypy. It is included by default
2527
# if no arguments are supplied, but we must supply it ourselves since we
2628
# specify args
2729
# cannot use --warn-unused-ignores because it conflicts with
2830
# --ignore-missing-imports
2931
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.6.1
32+
rev: v1.7.1
3133
hooks:
3234
- id: mypy
33-
args: ['--warn-unused-ignores', '--strict-equality','--no-implicit-optional']
35+
args: ['--warn-unused-ignores', '--strict-equality','--no-implicit-optional', '--check-untyped-defs']
3436
exclude: 'testdata/test_package_specifier/local_extras/setup.py'

.readthedocs.yaml .readthedocs.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
2-
31
version: 2
4-
52
build:
63
os: ubuntu-22.04
74
tools:
8-
python: "3.11"
5+
python: "3.12"
96
commands:
107
- pip install nox
118
- nox --session build_docs -- "${READTHEDOCS_OUTPUT}"/html

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ automatically upgraded.
2727
- Print all environment variables in `pipx environment`
2828
- Return an error message when directory can't be added to PATH successfully
2929
- Expose manual pages included in an application installed with `pipx install`
30+
- Add explicit 3.12 support
3031

3132
## 1.2.1
3233

CONTRIBUTING.md

+27-21
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,51 @@ nox -l
5252

5353
At the time of this writing, the output looks like this
5454
```
55-
- refresh_packages_cache-3.6 -> Populate .pipx_tests/package_cache
56-
- refresh_packages_cache-3.7 -> Populate .pipx_tests/package_cache
57-
- refresh_packages_cache-3.8 -> Populate .pipx_tests/package_cache
55+
- refresh_packages_cache-3.12 -> Populate .pipx_tests/package_cache
56+
- refresh_packages_cache-3.11 -> Populate .pipx_tests/package_cache
57+
- refresh_packages_cache-3.10 -> Populate .pipx_tests/package_cache
5858
- refresh_packages_cache-3.9 -> Populate .pipx_tests/package_cache
59-
- tests_internet-3.6 -> Tests using internet pypi only
60-
- tests_internet-3.7 -> Tests using internet pypi only
61-
- tests_internet-3.8 -> Tests using internet pypi only
59+
- refresh_packages_cache-3.8 -> Populate .pipx_tests/package_cache
60+
- tests_internet-3.12 -> Tests using internet pypi only
61+
- tests_internet-3.11 -> Tests using internet pypi only
62+
- tests_internet-3.10 -> Tests using internet pypi only
6263
- tests_internet-3.9 -> Tests using internet pypi only
63-
* tests-3.6 -> Tests using local pypiserver only
64-
* tests-3.7 -> Tests using local pypiserver only
65-
* tests-3.8 -> Tests using local pypiserver only
64+
- tests_internet-3.8 -> Tests using internet pypi only
65+
* tests-3.12 -> Tests using local pypiserver only
66+
* tests-3.11 -> Tests using local pypiserver only
67+
* tests-3.10 -> Tests using local pypiserver only
6668
* tests-3.9 -> Tests using local pypiserver only
67-
- test_all_packages-3.6
68-
- test_all_packages-3.7
69-
- test_all_packages-3.8
69+
* tests-3.8 -> Tests using local pypiserver only
70+
- test_all_packages-3.12
71+
- test_all_packages-3.11
72+
- test_all_packages-3.10
7073
- test_all_packages-3.9
74+
- test_all_packages-3.8
7175
- cover -> Coverage analysis
7276
* lint
73-
- develop-3.6
74-
- develop-3.7
75-
- develop-3.8
77+
- develop-3.12
78+
- develop-3.11
79+
- develop-3.10
7680
- develop-3.9
81+
- develop-3.8
7782
- build
7883
- publish
7984
* build_docs
80-
- publish_docs
8185
- watch_docs
86+
* build_man
8287
- pre_release
8388
- post_release
84-
- create_test_package_list-3.6
85-
- create_test_package_list-3.7
86-
- create_test_package_list-3.8
89+
- create_test_package_list-3.12
90+
- create_test_package_list-3.11
91+
- create_test_package_list-3.10
8792
- create_test_package_list-3.9
93+
- create_test_package_list-3.8
8894
```
8995

9096
### Unit Tests
91-
To run unit tests in Python3.9, you can run
97+
To run unit tests in Python3.12, you can run
9298
```
93-
nox -s tests-3.9
99+
nox -s tests-3.12
94100
```
95101

96102
!!! tip

docs/examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```
44
pipx install pycowsay
55
pipx install --python python3.10 pycowsay
6-
pipx install --python 3.11 pycowsay
6+
pipx install --python 3.12 pycowsay
77
pipx install git+https://github.com/psf/black
88
pipx install git+https://github.com/psf/black.git@branch-name
99
pipx install git+https://github.com/psf/black.git@git-hash

noxfile.py

+13-27
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44

55
import nox # type: ignore
66

7-
PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
8-
PYTHON_DEFAULT_VERSION = "3.11"
7+
PYTHON_ALL_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
8+
PYTHON_DEFAULT_VERSION = "3.12"
99
DOC_DEPENDENCIES = [".", "jinja2", "mkdocs", "mkdocs-material"]
1010
MAN_DEPENDENCIES = [".", "argparse-manpage[setuptools]"]
1111
LINT_DEPENDENCIES = [
12-
"black==23.10.1",
13-
"mypy==1.6.1",
12+
"mypy==1.7.1",
1413
"packaging>=20.0",
15-
"ruff==0.1.3",
14+
"ruff==0.1.6",
1615
"types-jinja2",
1716
]
1817
# Packages whose dependencies need an intact system PATH to compile
@@ -51,11 +50,7 @@ def prebuild_wheels(session, prebuild_dict):
5150

5251
def has_changes():
5352
status = (
54-
subprocess.run(
55-
"git status --porcelain", shell=True, check=True, stdout=subprocess.PIPE
56-
)
57-
.stdout.decode()
58-
.strip()
53+
subprocess.run("git status --porcelain", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode().strip()
5954
)
6055
return len(status) > 0
6156

@@ -103,7 +98,7 @@ def tests_with_options(session, net_pypiserver):
10398
if net_pypiserver:
10499
pypiserver_option = ["--net-pypiserver"]
105100
else:
106-
session.install("pypiserver[passlib]")
101+
session.install("pypiserver[passlib]", 'setuptools; python_version>="3.12"')
107102
refresh_packages_cache(session)
108103
pypiserver_option = []
109104

@@ -152,16 +147,14 @@ def cover(session):
152147
def lint(session):
153148
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
154149
session.install(*LINT_DEPENDENCIES)
155-
files = [str(Path("src") / "pipx"), "tests", "scripts"] + [
156-
str(p) for p in Path(".").glob("*.py")
157-
]
150+
files = [str(Path("src") / "pipx"), "tests", "scripts"] + [str(p) for p in Path(".").glob("*.py")]
158151
session.run("ruff", *files)
159-
session.run("black", "--check", *files)
160152
session.run(
161153
"mypy",
162154
"--strict-equality",
163155
"--no-implicit-optional",
164156
"--warn-unused-ignores",
157+
"--check-untyped-defs",
165158
*files,
166159
)
167160

@@ -170,7 +163,7 @@ def lint(session):
170163
def develop(session):
171164
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
172165
session.install(*DOC_DEPENDENCIES, *LINT_DEPENDENCIES)
173-
session.install("-e", ".")
166+
session.install("-e", ".", "pytest", "pypiserver[passlib]", 'setuptools; python_version>="3.12"')
174167

175168

176169
@nox.session(python=PYTHON_DEFAULT_VERSION)
@@ -196,9 +189,7 @@ def build_docs(session):
196189
site_dir = session.posargs or ["site/"]
197190
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
198191
session.install(*DOC_DEPENDENCIES)
199-
session.env[
200-
"PIPX__DOC_DEFAULT_PYTHON"
201-
] = "typically the python used to execute pipx"
192+
session.env["PIPX__DOC_DEFAULT_PYTHON"] = "typically the python used to execute pipx"
202193
session.run("python", "scripts/generate_docs.py")
203194
session.run("mkdocs", "build", "--strict", "--site-dir", *site_dir)
204195

@@ -214,9 +205,7 @@ def watch_docs(session):
214205
def build_man(session):
215206
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
216207
session.install(*MAN_DEPENDENCIES)
217-
session.env[
218-
"PIPX__DOC_DEFAULT_PYTHON"
219-
] = "typically the python used to execute pipx"
208+
session.env["PIPX__DOC_DEFAULT_PYTHON"] = "typically the python used to execute pipx"
220209
session.run("python", "scripts/generate_man.py")
221210

222211

@@ -247,17 +236,14 @@ def post_release(session):
247236
session.run("git", "--no-pager", "diff", external=True)
248237
print("")
249238
session.log(
250-
"If `git diff` above looks ok, execute the following command:\n\n"
251-
" git commit -a -m 'Post-release.'\n"
239+
"If `git diff` above looks ok, execute the following command:\n\n" " git commit -a -m 'Post-release.'\n"
252240
)
253241

254242

255243
@nox.session(python=PYTHON_ALL_VERSIONS)
256244
def create_test_package_list(session):
257245
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
258-
output_dir = (
259-
session.posargs[0] if session.posargs else str(PIPX_TESTS_PACKAGE_LIST_DIR)
260-
)
246+
output_dir = session.posargs[0] if session.posargs else str(PIPX_TESTS_PACKAGE_LIST_DIR)
261247
session.run(
262248
"python",
263249
"scripts/list_test_packages.py",

0 commit comments

Comments
 (0)