Greater safety and fewer assumptions doing cross-thread cleanup. #635
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: tests | |
on: [push, pull_request, workflow_dispatch] | |
env: | |
PYTHONHASHSEED: 1042466059 | |
ZOPE_INTERFACE_STRICT_IRO: 1 | |
PYTHONUNBUFFERED: 1 | |
PYTHONDONTWRITEBYTECODE: 1 | |
PYTHONDEVMODE: 1 | |
PYTHONFAULTHANDLER: 1 | |
PIP_UPGRADE_STRATEGY: eager | |
# Don't get warnings about Python 2 support being deprecated. We | |
# know. The env var works for pip 20. | |
PIP_NO_PYTHON_VERSION_WARNING: 1 | |
PIP_NO_WARN_SCRIPT_LOCATION: 1 | |
# Uploading built wheels for releases. | |
# TWINE_PASSWORD is encrypted and stored directly in the | |
# repo settings. | |
TWINE_USERNAME: __token__ | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12", "3.13"] | |
os: [ubuntu-latest] | |
include: | |
# Needs to be all supported Python versions, they upload the built | |
# wheels for releases. | |
- os: macos-latest | |
python-version: 3.8 | |
- os: macos-latest | |
python-version: 3.9 | |
- os: macos-latest | |
python-version: "3.10" | |
- os: macos-latest | |
python-version: "3.11" | |
- os: macos-latest | |
python-version: "3.12" | |
- os: macos-latest | |
python-version: "3.13" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: setup.py | |
allow-prereleases: true | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip setuptools wheel | |
python -m pip install -U twine | |
- name: Install greenlet (non-Mac) | |
if: ${{ ! startsWith(runner.os, 'Mac') }} | |
run: | | |
# Stupid setuptools doesn't want you running 'python setup.py' anymore, | |
# but stupid pip hides all the intersting compiler output by default, and the | |
# only way to get anything useful out is to ask *everything* to be verbose, | |
# which is much more junk than we need to wade through, making it hard to | |
# see what we want. What's the point of having warnings at all if we can't | |
# see them, though? | |
python -m pip wheel -v --wheel-dir ./dist . | |
python -m pip install -U -e ".[test,docs]" | |
env: | |
# Ensure we test with assertions enabled. | |
# As opposed to the manylinux builds, which we distribute and | |
# thus only use O3 (because Ofast enables fast-math, which has | |
# process-wide effects), we test with Ofast here, because we | |
# expect that some people will compile it themselves with that setting. | |
CPPFLAGS: "-Ofast -UNDEBUG -Wall" | |
CFLAGS: "-Ofast -UNDEBUG -Wall" | |
- name: Install greenlet (Mac) | |
if: startsWith(runner.os, 'Mac') | |
run: | | |
python -m pip wheel -v --wheel-dir ./dist . | |
python -m pip install -U -e ".[test,docs]" | |
ls -l dist | |
# Something in the build system isn't detecting that we're building for both, | |
# so we're getting tagged with just x86_64. Force the universal2 tag. | |
# (I've verified that the .so files are in fact universal, with both architectures.) | |
# The macosx_11_0 tag is conservative: At this writing, | |
# on GHA, Python 3.7/3.8/3.9/3.10 all produce that tag, while | |
# 3.11/3.12 produce the less restrictive macosx_10_9 tag. (Locally on JAM's mac, | |
# the official CPython builds produce 10_9 for everything from 3.9 onward.) | |
wheel tags --remove --platform-tag macosx_11_0_universal2 dist/*whl | |
env: | |
# Unlike the above, we are actually distributing these | |
# wheels, so they need to be built for production use. | |
CPPFLAGS: "-O3 -flto -ffunction-sections" | |
CFLAGS: "-O3 -flto -ffunction-sections" | |
# Build for both architectures | |
ARCHFLAGS: "-arch x86_64 -arch arm64" | |
- name: Check greenlet build | |
run: | | |
ls -l dist | |
twine check dist/* | |
- name: Store greenlet wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: greenlet-${{ runner.os }}-${{ matrix.python-version }}.whl | |
path: dist/*whl | |
- name: Test | |
run: | | |
python -VV | |
python -c 'import greenlet._greenlet as G; assert G.GREENLET_USE_STANDARD_THREADING' | |
python -m unittest discover -v greenlet.tests | |
- name: Doctest | |
run: | | |
sphinx-build -b doctest -d docs/_build/doctrees2 docs docs/_build/doctest2 | |
- name: Lint | |
if: matrix.python-version == '3.12' && startsWith(runner.os, 'Linux') | |
# We only need to do this on one version. | |
# We do this here rather than a separate job to avoid the compilation overhead. | |
run: | | |
pip install -U pylint | |
python -m pylint --rcfile=.pylintrc greenlet | |
- name: Publish package to PyPI (mac) | |
# We cannot 'uses: pypa/[email protected]' because | |
# that's apparently a container action, and those don't run on | |
# the Mac. | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && startsWith(runner.os, 'Mac') | |
env: | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
run: | | |
twine upload --skip-existing dist/* | |
CodeQL: | |
runs-on: ubuntu-latest | |
permissions: | |
# required for all workflows | |
security-events: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: 'pip' | |
cache-dependency-path: setup.py | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip | |
python -m pip install -U setuptools wheel | |
# Set the `CODEQL-PYTHON` environment variable to the Python executable | |
# that includes the dependencies | |
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV | |
# Initializes the CodeQL tools for scanning. | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: python, cpp | |
# Override the default behavior so that the action doesn't attempt | |
# to auto-install Python dependencies | |
setup-python-dependencies: false | |
- name: Install greenlet | |
run: | | |
python setup.py build | |
# - name: Autobuild | |
# uses: github/codeql-action/autobuild@v1 | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
manylinux: | |
runs-on: ubuntu-latest | |
# We use a regular Python matrix entry to share as much code as possible. | |
strategy: | |
matrix: | |
python-version: [3.9] | |
image: | |
- manylinux_2_28_x86_64 | |
- manylinux2014_aarch64 | |
- manylinux2014_ppc64le | |
- manylinux2014_s390x | |
- manylinux2014_x86_64 | |
- musllinux_1_1_x86_64 | |
- musllinux_1_1_aarch64 | |
name: ${{ matrix.image }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Build and test greenlet | |
env: | |
DOCKER_IMAGE: quay.io/pypa/${{ matrix.image }} | |
run: bash ./make-manylinux | |
- name: Store greenlet wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
path: wheelhouse/*whl | |
name: ${{ matrix.image }}_wheels.zip | |
- name: Publish package to PyPI | |
uses: pypa/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
with: | |
user: __token__ | |
password: ${{ secrets.TWINE_PASSWORD }} | |
skip_existing: true | |
packages_dir: wheelhouse/ |