Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 authored Apr 1, 2024
2 parents 4da382b + c059de2 commit e57733c
Show file tree
Hide file tree
Showing 194 changed files with 7,482 additions and 5,563 deletions.
37 changes: 0 additions & 37 deletions .coveragerc

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/autodeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
Autodeps:
if: github.repository_owner == 'python-trio'
name: Autodeps
timeout-minutes: 10
runs-on: 'ubuntu-latest'
Expand All @@ -18,23 +19,24 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Bump dependencies
run: |
python -m pip install -U pip
python -m pip install -U pip pre-commit
python -m pip install -r test-requirements.txt
pip-compile -U test-requirements.in
pip-compile -U docs-requirements.in
pre-commit autoupdate --jobs 0
- name: Black
run: |
# The new dependencies may contain a new black version.
# Commit any changes immediately.
python -m pip install -r test-requirements.txt
black setup.py trio
black src/trio
- name: Commit changes and create automerge PR
env:
GH_TOKEN: ${{ github.token }}
Expand Down
86 changes: 70 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ jobs:
strategy:
fail-fast: false
matrix:
# pypy-3.10 is failing, see https://github.com/python-trio/trio/issues/2678
python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly'] #, 'pypy-3.10-nightly']
python: ['3.8', '3.9', '3.10']
arch: ['x86', 'x64']
lsp: ['']
lsp_extract_file: ['']
extra_name: ['']
exclude:
# pypy does not release 32-bit binaries
- python: 'pypy-3.9-nightly'
arch: 'x86'
#- python: 'pypy-3.10-nightly'
# arch: 'x86'
include:
- python: '3.8'
arch: 'x64'
Expand Down Expand Up @@ -57,9 +50,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
# This allows the matrix to specify just the major.minor version while still
# expanding it to get the latest patch version including alpha releases.
Expand Down Expand Up @@ -94,7 +87,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12-dev', 'pypy-3.9-nightly', 'pypy-3.10-nightly']
python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12']
check_formatting: ['0']
no_test_requirements: ['0']
extra_name: ['']
Expand All @@ -117,9 +110,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
Expand Down Expand Up @@ -150,7 +143,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly']
python: ['3.8', '3.9', '3.10']
continue-on-error: >-
${{
(
Expand All @@ -162,9 +155,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
Expand All @@ -179,6 +172,65 @@ jobs:
name: macOS (${{ matrix.python }})
flags: macOS,${{ matrix.python }}

# run CI on a musl linux
Alpine:
name: "Alpine"
runs-on: ubuntu-latest
container: alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install necessary packages
# can't use setup-python because that python doesn't seem to work;
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
run: apk update && apk add python3-dev bash nodejs
- name: Enter virtual environment
run: python -m venv .venv
- name: Run tests
run: source .venv/bin/activate && ./ci.sh
- if: always()
uses: codecov/codecov-action@v3
with:
directory: empty
token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46
name: Alpine
flags: Alpine,3.12

Cython:
name: "Cython"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ['3.8', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python }}'
cache: pip
# setuptools is needed to get distutils on 3.12, which cythonize requires
- name: install trio and setuptools
run: python -m pip install --upgrade pip . setuptools

- name: install cython<3
run: python -m pip install "cython<3"
- name: compile pyx file
run: cythonize -i tests/cython/test_cython.pyx
- name: import & run module
run: python -c 'import tests.cython.test_cython'

- name: install cython>=3
run: python -m pip install "cython>=3"
- name: compile pyx file
# different cython version should trigger a re-compile, but --force just in case
run: cythonize --inplace --force tests/cython/test_cython.pyx
- name: import & run module
run: python -c 'import tests.cython.test_cython'

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection

Expand All @@ -188,6 +240,8 @@ jobs:
- Windows
- Ubuntu
- macOS
- Alpine
- Cython

runs-on: ubuntu-latest

Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ repos:
- id: check-case-conflict
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- repo: https://github.com/psf/black
rev: 23.10.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
rev: v0.3.4
hooks:
- id: ruff
types: [file]
types_or: [python, pyi, toml]
args: ["--show-fixes"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include LICENSE LICENSE.MIT LICENSE.APACHE2
include README.rst
include CODE_OF_CONDUCT.md CONTRIBUTING.md
include test-requirements.txt
include trio/py.typed
recursive-include trio/_tests/test_ssl_certs *.pem
include src/trio/py.typed
recursive-include src/trio/_tests/test_ssl_certs *.pem
recursive-include docs *
prune docs/build
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ demonstration of implementing the "Happy Eyeballs" algorithm in an
older library versus Trio.

**Cool, but will it work on my system?** Probably! As long as you have
some kind of Python 3.8-or-better (CPython or [currently maintained versions of
PyPy3](https://doc.pypy.org/en/latest/faq.html#which-python-versions-does-pypy-implement)
some kind of Python 3.8-or-better (CPython or `currently maintained versions of
PyPy3 <https://doc.pypy.org/en/latest/faq.html#which-python-versions-does-pypy-implement>`__
are both fine), and are using Linux, macOS, Windows, or FreeBSD, then Trio
will work. Other environments might work too, but those
are the ones we test on. And all of our dependencies are pure Python,
Expand Down
29 changes: 12 additions & 17 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

# Test if the generated code is still up to date
echo "::group::Generate Exports"
python ./trio/_tools/gen_exports.py --test \
python ./src/trio/_tools/gen_exports.py --test \
|| EXIT_STATUS=$?
echo "::endgroup::"

Expand All @@ -23,10 +23,10 @@ echo "::endgroup::"
# autoflake --recursive --in-place .
# pyupgrade --py3-plus $(find . -name "*.py")
echo "::group::Black"
if ! black --check setup.py trio; then
if ! black --check src/trio; then
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY"
EXIT_STATUS=1
black --diff setup.py trio
black --diff src/trio
echo "::endgroup::"
echo "::error:: Black found issues"
else
Expand Down Expand Up @@ -57,16 +57,16 @@ echo "::group::Mypy"
rm -f mypy_annotate.dat
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
set -o pipefail
mypy trio --show-error-end --platform linux | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
mypy --show-error-end --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
|| { echo "* Mypy (Linux) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
# Darwin tests FreeBSD too
mypy trio --show-error-end --platform darwin | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
mypy --show-error-end --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
|| { echo "* Mypy (Mac) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
mypy trio --show-error-end --platform win32 | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
mypy --show-error-end --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
|| { echo "* Mypy (Windows) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
set +o pipefail
# Re-display errors using Github's syntax, read out of mypy_annotate.dat
python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
# Then discard.
rm -f mypy_annotate.dat
echo "::endgroup::"
Expand Down Expand Up @@ -97,15 +97,10 @@ fi
codespell || EXIT_STATUS=$?

echo "::group::Pyright interface tests"
python trio/_tests/check_type_completeness.py --overwrite-file || EXIT_STATUS=$?
if git status --porcelain trio/_tests/verify_types*.json | grep -q "M"; then
echo "* Type completeness changed, please update!" >> "$GITHUB_STEP_SUMMARY"
echo "::error::Type completeness changed, please update!"
git --no-pager diff --color trio/_tests/verify_types*.json
EXIT_STATUS=1
fi
python src/trio/_tests/check_type_completeness.py || EXIT_STATUS=$?

pyright trio/_tests/type_tests || EXIT_STATUS=$?
pyright src/trio/_tests/type_tests || EXIT_STATUS=$?
pyright src/trio/_core/_tests/type_tests || EXIT_STATUS=$?
echo "::endgroup::"

# Finally, leave a really clear warning of any issues and exit
Expand All @@ -118,8 +113,8 @@ Problems were found by static analysis (listed above).
To fix formatting and see remaining errors, run
pip install -r test-requirements.txt
black setup.py trio
isort setup.py trio
black src/trio
ruff check src/trio
./check.sh
in your local checkout.
Expand Down
16 changes: 8 additions & 8 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio
echo "::endgroup::"

echo "::group::Install dependencies"
python -m pip install -U pip setuptools wheel
python -m pip install -U pip build
python -m pip --version

python setup.py sdist --formats=zip
python -m pip install dist/*.zip
python -m build
python -m pip install dist/*.whl

if [ "$CHECK_FORMATTING" = "1" ]; then
python -m pip install -r test-requirements.txt
Expand Down Expand Up @@ -95,7 +95,7 @@ else
# when installing, and then running 'certmgr.msc' and exporting the
# certificate. See:
# http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/
certutil -addstore "TrustedPublisher" trio/_tests/astrill-codesigning-cert.cer
certutil -addstore "TrustedPublisher" src/trio/_tests/astrill-codesigning-cert.cer
# Double-slashes are how you tell windows-bash that you want a single
# slash, and don't treat this as a unix-style filename that needs to
# be replaced by a windows-style filename.
Expand Down Expand Up @@ -128,17 +128,17 @@ else

echo "::endgroup::"
echo "::group:: Run Tests"
if COVERAGE_PROCESS_START=$(pwd)/../.coveragerc coverage run --rcfile=../.coveragerc -m pytest -r a -p trio._tests.pytest_plugin --junitxml=../test-results.xml --run-slow ${INSTALLDIR} --verbose --durations=10 $flags; then
if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -ra --junitxml=../test-results.xml --run-slow ${INSTALLDIR} --verbose --durations=10 $flags; then
PASSED=true
else
PASSED=false
fi
echo "::endgroup::"
echo "::group::Coverage"

coverage combine --rcfile ../.coveragerc
coverage report -m --rcfile ../.coveragerc
coverage xml --rcfile ../.coveragerc
coverage combine --rcfile ../pyproject.toml
coverage report -m --rcfile ../pyproject.toml
coverage xml --rcfile ../pyproject.toml

# Remove the LSP again; again we want to do this ASAP to avoid
# accidentally breaking other stuff.
Expand Down
Loading

0 comments on commit e57733c

Please sign in to comment.