Skip to content

Commit

Permalink
Add 3.12 support and bump linters (#1118)
Browse files Browse the repository at this point in the history
Co-authored-by: chrysle <[email protected]>
  • Loading branch information
gaborbernat and chrysle authored Dec 2, 2023
1 parent f130306 commit 7184de2
Show file tree
Hide file tree
Showing 58 changed files with 482 additions and 976 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/create_tests_package_lists.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Create tests package lists for offline tests
on:
workflow_dispatch:

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true
jobs:
create_package_lists:
name: Create package lists
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/exhaustive_package_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Exhaustive Package Test (slow)
on:
workflow_dispatch:

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true
jobs:
test_all_packages:
name: Exhaustive Package Test
Expand All @@ -10,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
workflow_dispatch:

env:
default-python: "3.11"
default-python: "3.12"

jobs:
testpypi-publish:
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
name: tests

on:
pull_request:
push:
tags-ignore: ["**"]
pull_request:
schedule:
- cron: "0 8 * * *"
concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

# If changing default-python be sure to change job "tests" matrix: include: also
env:
default-python: "3.11"
default-python: "3.12"

jobs:
lint:
Expand Down Expand Up @@ -55,12 +61,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
include:
- os: windows-latest
python-version: "3.11"
python-version: "3.12"
- os: macos-latest
python-version: "3.11"
python-version: "3.12"

steps:
- uses: actions/checkout@v4
Expand Down
18 changes: 10 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ repos:
- id: check-added-large-files
- id: trailing-whitespace
- id: check-yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.5.2"
hooks:
- id: ruff
- repo: https://github.com/psf/black
rev: 23.10.1
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: black
- id: ruff-format
- id: ruff
args: [ "--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
# mypy args:
# must include --ignore-missing-imports for mypy. It is included by default
# if no arguments are supplied, but we must supply it ourselves since we
# specify args
# cannot use --warn-unused-ignores because it conflicts with
# --ignore-missing-imports
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.7.1
hooks:
- id: mypy
args: ['--warn-unused-ignores', '--strict-equality','--no-implicit-optional']
args: ['--warn-unused-ignores', '--strict-equality','--no-implicit-optional', '--check-untyped-defs']
exclude: 'testdata/test_package_specifier/local_extras/setup.py'
5 changes: 1 addition & 4 deletions .readthedocs.yaml → .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"
commands:
- pip install nox
- nox --session build_docs -- "${READTHEDOCS_OUTPUT}"/html
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ automatically upgraded.
- Print all environment variables in `pipx environment`
- Return an error message when directory can't be added to PATH successfully
- Expose manual pages included in an application installed with `pipx install`
- Add explicit 3.12 support

## 1.2.1

Expand Down
48 changes: 27 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,45 +52,51 @@ nox -l

At the time of this writing, the output looks like this
```
- refresh_packages_cache-3.6 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.7 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.8 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.12 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.11 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.10 -> Populate .pipx_tests/package_cache
- refresh_packages_cache-3.9 -> Populate .pipx_tests/package_cache
- tests_internet-3.6 -> Tests using internet pypi only
- tests_internet-3.7 -> Tests using internet pypi only
- tests_internet-3.8 -> Tests using internet pypi only
- refresh_packages_cache-3.8 -> Populate .pipx_tests/package_cache
- tests_internet-3.12 -> Tests using internet pypi only
- tests_internet-3.11 -> Tests using internet pypi only
- tests_internet-3.10 -> Tests using internet pypi only
- tests_internet-3.9 -> Tests using internet pypi only
* tests-3.6 -> Tests using local pypiserver only
* tests-3.7 -> Tests using local pypiserver only
* tests-3.8 -> Tests using local pypiserver only
- tests_internet-3.8 -> Tests using internet pypi only
* tests-3.12 -> Tests using local pypiserver only
* tests-3.11 -> Tests using local pypiserver only
* tests-3.10 -> Tests using local pypiserver only
* tests-3.9 -> Tests using local pypiserver only
- test_all_packages-3.6
- test_all_packages-3.7
- test_all_packages-3.8
* tests-3.8 -> Tests using local pypiserver only
- test_all_packages-3.12
- test_all_packages-3.11
- test_all_packages-3.10
- test_all_packages-3.9
- test_all_packages-3.8
- cover -> Coverage analysis
* lint
- develop-3.6
- develop-3.7
- develop-3.8
- develop-3.12
- develop-3.11
- develop-3.10
- develop-3.9
- develop-3.8
- build
- publish
* build_docs
- publish_docs
- watch_docs
* build_man
- pre_release
- post_release
- create_test_package_list-3.6
- create_test_package_list-3.7
- create_test_package_list-3.8
- create_test_package_list-3.12
- create_test_package_list-3.11
- create_test_package_list-3.10
- create_test_package_list-3.9
- create_test_package_list-3.8
```

### Unit Tests
To run unit tests in Python3.9, you can run
To run unit tests in Python3.12, you can run
```
nox -s tests-3.9
nox -s tests-3.12
```

!!! tip
Expand Down
2 changes: 1 addition & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
```
pipx install pycowsay
pipx install --python python3.10 pycowsay
pipx install --python 3.11 pycowsay
pipx install --python 3.12 pycowsay
pipx install git+https://github.com/psf/black
pipx install git+https://github.com/psf/black.git@branch-name
pipx install git+https://github.com/psf/black.git@git-hash
Expand Down
40 changes: 13 additions & 27 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import nox # type: ignore

PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
PYTHON_DEFAULT_VERSION = "3.11"
PYTHON_ALL_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
PYTHON_DEFAULT_VERSION = "3.12"
DOC_DEPENDENCIES = [".", "jinja2", "mkdocs", "mkdocs-material"]
MAN_DEPENDENCIES = [".", "argparse-manpage[setuptools]"]
LINT_DEPENDENCIES = [
"black==23.10.1",
"mypy==1.6.1",
"mypy==1.7.1",
"packaging>=20.0",
"ruff==0.1.3",
"ruff==0.1.6",
"types-jinja2",
]
# Packages whose dependencies need an intact system PATH to compile
Expand Down Expand Up @@ -51,11 +50,7 @@ def prebuild_wheels(session, prebuild_dict):

def has_changes():
status = (
subprocess.run(
"git status --porcelain", shell=True, check=True, stdout=subprocess.PIPE
)
.stdout.decode()
.strip()
subprocess.run("git status --porcelain", shell=True, check=True, stdout=subprocess.PIPE).stdout.decode().strip()
)
return len(status) > 0

Expand Down Expand Up @@ -103,7 +98,7 @@ def tests_with_options(session, net_pypiserver):
if net_pypiserver:
pypiserver_option = ["--net-pypiserver"]
else:
session.install("pypiserver[passlib]")
session.install("pypiserver[passlib]", 'setuptools; python_version>="3.12"')
refresh_packages_cache(session)
pypiserver_option = []

Expand Down Expand Up @@ -152,16 +147,14 @@ def cover(session):
def lint(session):
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
session.install(*LINT_DEPENDENCIES)
files = [str(Path("src") / "pipx"), "tests", "scripts"] + [
str(p) for p in Path(".").glob("*.py")
]
files = [str(Path("src") / "pipx"), "tests", "scripts"] + [str(p) for p in Path(".").glob("*.py")]
session.run("ruff", *files)
session.run("black", "--check", *files)
session.run(
"mypy",
"--strict-equality",
"--no-implicit-optional",
"--warn-unused-ignores",
"--check-untyped-defs",
*files,
)

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


@nox.session(python=PYTHON_DEFAULT_VERSION)
Expand All @@ -196,9 +189,7 @@ def build_docs(session):
site_dir = session.posargs or ["site/"]
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
session.install(*DOC_DEPENDENCIES)
session.env[
"PIPX__DOC_DEFAULT_PYTHON"
] = "typically the python used to execute pipx"
session.env["PIPX__DOC_DEFAULT_PYTHON"] = "typically the python used to execute pipx"
session.run("python", "scripts/generate_docs.py")
session.run("mkdocs", "build", "--strict", "--site-dir", *site_dir)

Expand All @@ -214,9 +205,7 @@ def watch_docs(session):
def build_man(session):
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
session.install(*MAN_DEPENDENCIES)
session.env[
"PIPX__DOC_DEFAULT_PYTHON"
] = "typically the python used to execute pipx"
session.env["PIPX__DOC_DEFAULT_PYTHON"] = "typically the python used to execute pipx"
session.run("python", "scripts/generate_man.py")


Expand Down Expand Up @@ -247,17 +236,14 @@ def post_release(session):
session.run("git", "--no-pager", "diff", external=True)
print("")
session.log(
"If `git diff` above looks ok, execute the following command:\n\n"
" git commit -a -m 'Post-release.'\n"
"If `git diff` above looks ok, execute the following command:\n\n" " git commit -a -m 'Post-release.'\n"
)


@nox.session(python=PYTHON_ALL_VERSIONS)
def create_test_package_list(session):
session.run("python", "-m", "pip", "install", "--upgrade", "pip")
output_dir = (
session.posargs[0] if session.posargs else str(PIPX_TESTS_PACKAGE_LIST_DIR)
)
output_dir = session.posargs[0] if session.posargs else str(PIPX_TESTS_PACKAGE_LIST_DIR)
session.run(
"python",
"scripts/list_test_packages.py",
Expand Down
Loading

0 comments on commit 7184de2

Please sign in to comment.