Skip to content

Commit

Permalink
Build Windows wheels on GHA (#152)
Browse files Browse the repository at this point in the history
* - build Windows wheels on GHA

* - fix test configuration
  • Loading branch information
dataflake authored May 25, 2024
1 parent d8363b5 commit 55121a3
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 103 deletions.
146 changes: 114 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
os: [ubuntu-20.04, macos-11]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "3.7"
include:
- python-version: "3.7"
os: macos-12

steps:
- name: checkout
Expand All @@ -117,23 +123,40 @@ jobs:
# to save the cache. So it must come before the thing we want to use
# the cache.
###
- name: Get pip cache dir
id: pip-cache
- name: Get pip cache dir (default)
id: pip-cache-default
if: ${{ !startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: pip cache
- name: Get pip cache dir (Windows)
id: pip-cache-windows
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT
- name: pip cache (default)
uses: actions/cache@v4
if: ${{ !startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache.outputs.dir }}
path: ${{ steps.pip-cache-default.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
- name: pip cache (Windows)
uses: actions/cache@v4
if: ${{ startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-windows.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Build Dependencies
run: |
pip install -U pip
pip install -U setuptools wheel twine cffi
pip install -U "setuptools<69" wheel twine
- name: Build AccessControl (macOS x86_64, Python 3.8+)
if: >
Expand Down Expand Up @@ -209,14 +232,14 @@ jobs:
with:
name: AccessControl-${{ runner.os }}-${{ matrix.python-version }}.whl
path: dist/*whl
- name: Publish package to PyPI (mac)
# We cannot 'uses: pypa/gh-action-pypi-publish@v1.4.1' because
# that's apparently a container action, and those don't run on
# the Mac.
- name: Publish package to PyPI (Non-Linux)
# We cannot use pypa/gh-action-pypi-publish because that
# is a container action, and those don't run on macOS
# or Windows GHA runners.
if: >
github.event_name == 'push'
&& startsWith(github.ref, 'refs/tags')
&& startsWith(runner.os, 'Mac')
&& !startsWith(runner.os, 'Linux')
&& !startsWith(matrix.python-version, 'pypy')
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
Expand All @@ -236,7 +259,13 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
os: [ubuntu-20.04, macos-11]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "3.7"
include:
- python-version: "3.7"
os: macos-12

steps:
- name: checkout
Expand All @@ -251,15 +280,32 @@ jobs:
# to save the cache. So it must come before the thing we want to use
# the cache.
###
- name: Get pip cache dir
id: pip-cache
- name: Get pip cache dir (default)
id: pip-cache-default
if: ${{ !startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: pip cache
- name: Get pip cache dir (Windows)
id: pip-cache-windows
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT
- name: pip cache (default)
uses: actions/cache@v4
if: ${{ !startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-default.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
- name: pip cache (Windows)
uses: actions/cache@v4
if: ${{ startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache.outputs.dir }}
path: ${{ steps.pip-cache-windows.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
Expand All @@ -271,7 +317,7 @@ jobs:
path: dist/
- name: Install AccessControl
run: |
pip install -U wheel setuptools
pip install -U wheel "setuptools<69"
pip install -U coverage
pip install -U 'cffi; platform_python_implementation == "CPython"'
# Unzip into src/ so that testrunner can find the .so files
Expand All @@ -286,7 +332,9 @@ jobs:
- name: Run tests without C extensions
run:
# coverage makes PyPy run about 3x slower!
PURE_PYTHON=1 python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress
python -m coverage run -p -m zope.testrunner --test-path=src --auto-color --auto-progress
env:
PURE_PYTHON: 1
- name: Report Coverage
run: |
coverage combine
Expand All @@ -300,7 +348,7 @@ jobs:

coveralls_finish:
needs: test
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
Expand All @@ -313,7 +361,7 @@ jobs:
strategy:
matrix:
python-version: ["3.9"]
os: [ubuntu-20.04]
os: [ubuntu-latest]

steps:
- name: checkout
Expand All @@ -328,15 +376,32 @@ jobs:
# to save the cache. So it must come before the thing we want to use
# the cache.
###
- name: Get pip cache dir
id: pip-cache
- name: Get pip cache dir (default)
id: pip-cache-default
if: ${{ !startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: pip cache
- name: Get pip cache dir (Windows)
id: pip-cache-windows
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT
- name: pip cache (default)
uses: actions/cache@v4
if: ${{ !startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-default.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
- name: pip cache (Windows)
uses: actions/cache@v4
if: ${{ startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache.outputs.dir }}
path: ${{ steps.pip-cache-windows.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
Expand All @@ -360,7 +425,7 @@ jobs:
# python -m pylint --limit-inference-results=1 --rcfile=.pylintrc AccessControl -f parseable -r n
manylinux:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
# We use a regular Python matrix entry to share as much code as possible.
strategy:
Expand All @@ -381,15 +446,32 @@ jobs:
# to save the cache. So it must come before the thing we want to use
# the cache.
###
- name: Get pip cache dir
id: pip-cache
- name: Get pip cache dir (default)
id: pip-cache-default
if: ${{ !startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: pip cache
- name: Get pip cache dir (Windows)
id: pip-cache-windows
if: ${{ startsWith(runner.os, 'Windows') }}
run: |
echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT
- name: pip cache (default)
uses: actions/cache@v4
if: ${{ !startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache-default.outputs.dir }}
key: ${{ runner.os }}-pip_manylinux-${{ matrix.image }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
- name: pip cache (Windows)
uses: actions/cache@v4
if: ${{ startsWith(runner.os, 'Windows') }}
with:
path: ${{ steps.pip-cache.outputs.dir }}
path: ${{ steps.pip-cache-windows.outputs.dir }}
key: ${{ runner.os }}-pip_manylinux-${{ matrix.image }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-
Expand Down Expand Up @@ -427,7 +509,7 @@ jobs:
path: wheelhouse/*whl
name: manylinux_${{ matrix.image }}_wheels.zip
- name: Restore pip cache permissions
run: sudo chown -R $(whoami) ${{ steps.pip-cache.outputs.dir }}
run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }}
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: >
Expand All @@ -436,5 +518,5 @@ jobs:
with:
user: __token__
password: ${{ secrets.TWINE_PASSWORD }}
skip_existing: true
packages_dir: wheelhouse/
skip-existing: true
packages-dir: wheelhouse/
12 changes: 6 additions & 6 deletions .manylinux-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ tox_env_map() {
# Compile wheels
for PYBIN in /opt/python/*/bin; do
if \
[[ "${PYBIN}" == *"cp311"* ]] || \
[[ "${PYBIN}" == *"cp312"* ]] || \
[[ "${PYBIN}" == *"cp37"* ]] || \
[[ "${PYBIN}" == *"cp38"* ]] || \
[[ "${PYBIN}" == *"cp39"* ]] || \
[[ "${PYBIN}" == *"cp310"* ]] ; then
[[ "${PYBIN}" == *"cp311/"* ]] || \
[[ "${PYBIN}" == *"cp312/"* ]] || \
[[ "${PYBIN}" == *"cp37/"* ]] || \
[[ "${PYBIN}" == *"cp38/"* ]] || \
[[ "${PYBIN}" == *"cp39/"* ]] || \
[[ "${PYBIN}" == *"cp310/"* ]] ; then
"${PYBIN}/pip" install -e /io/
"${PYBIN}/pip" wheel /io/ -w wheelhouse/
if [ `uname -m` == 'aarch64' ]; then
Expand Down
18 changes: 4 additions & 14 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
# https://github.com/zopefoundation/meta/tree/master/config/c-code
[meta]
template = "c-code"
commit-id = "1351c95d"
commit-id = "4dc0484e"

[python]
with-appveyor = true
with-windows = false
with-appveyor = false
with-windows = true
with-pypy = false
with-future-python = false
with-sphinx-doctests = false
with-macos = false
with-docs = false

[tox]
use-flake8 = true
Expand All @@ -36,14 +37,3 @@ additional-rules = [
"recursive-include src *.h",
"recursive-include src *.zcml",
]

[appveyor]
global-env-vars = [
"# Currently the builds use @dataflake's Appveyor account. The PyPI token belongs",
"# to zope.wheelbuilder, which is managed by @mgedmin and @dataflake.",
"",
"global:",
" TWINE_USERNAME: __token__",
" TWINE_PASSWORD:",
" secure: vSlDBj79vziJOA5k3z16r1OSr/7Jq6uCf23VKErSsXWb2dGJMUxR6GQ6tRs53GfiyxBQdpdfOA5QuVS4G4W3rVLwD/YXCidpidwBF3pKk4J2Nnk88HpZID6lQOV713DA/kkEuoO97Ty1BRYeaca9bA0P0KmRYU7Iy30p4xBUnmNKYnfilH0/waASYEDwpkrl49DiUh1+bMQjE5LKIBeaF0LLquzHGYETQf4BgpywUIV/8dQnc0vL/RXCa6PrWOxg/8S6ponIYyJ32Y4OoprZ1Q==",
]
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ For changes before version 3.0, see ``HISTORY.rst``.
6.4 (unreleased)
----------------

- Build Windows wheels on GHA.

- Make dict views (`.keys()`, `.items()` and `.values()`) behave like their
unrestricted versions.
(`#147 <https://github.com/zopefoundation/AccessControl/pull/147>`_)
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ include *.rst
include *.txt
include buildout.cfg
include tox.ini
include appveyor.yml
include .coveragerc

recursive-include src *.py
Expand Down
50 changes: 0 additions & 50 deletions appveyor.yml

This file was deleted.

Loading

0 comments on commit 55121a3

Please sign in to comment.