| 1 |
name: Test, build, publish |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
on: [push, pull_request] |
| 7 |
|
| 8 |
jobs: |
| 9 |
run-tests: |
| 10 |
env: |
| 11 |
not_in_conda: "[]" |
| 12 |
not_in_aarch64: "['3.5', '=3.9[build=*_pypy]']" |
| 13 |
|
| 14 |
strategy: |
| 15 |
matrix: |
| 16 |
os: [ubuntu-latest, macos-latest, windows-latest] |
| 17 |
python-version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "=3.9[build=*_pypy]"] |
| 18 |
exclude: |
| 19 |
- os: windows-latest |
| 20 |
python-version: "2.7" |
| 21 |
- os: macos-latest |
| 22 |
python-version: "2.7" |
| 23 |
- os: macos-latest |
| 24 |
python-version: "3.5" |
| 25 |
- os: macos-latest |
| 26 |
python-version: "3.6" |
| 27 |
- os: macos-latest |
| 28 |
python-version: "3.7" |
| 29 |
- os: macos-latest |
| 30 |
python-version: "=3.9[build=*_pypy]" |
| 31 |
- os: windows-latest |
| 32 |
python-version: "=3.9[build=*_pypy]" |
| 33 |
include: |
| 34 |
- os: ubuntu-latest |
| 35 |
os-name: Linux |
| 36 |
pip-cache-path: ~/.cache/pip |
| 37 |
- os: macos-latest |
| 38 |
os-name: MacOS |
| 39 |
pip-cache-path: ~/Library/Caches/pip |
| 40 |
- os: windows-latest |
| 41 |
os-name: w32 |
| 42 |
pip-cache-path: ~\AppData\Local\pip\Cache |
| 43 |
|
| 44 |
name: Python ${{ matrix.python-version }} @ ${{ matrix.os-name }} |
| 45 |
runs-on: ${{ matrix.os }} |
| 46 |
|
| 47 |
steps: |
| 48 |
|
| 49 |
- uses: actions/checkout@v4 |
| 50 |
- uses: conda-incubator/setup-miniconda@v3 |
| 51 |
with: |
| 52 |
channels: conda-forge, conda-forge/label/python_rc |
| 53 |
miniforge-version: latest |
| 54 |
python-version: ${{ matrix.python-version }} |
| 55 |
if: ${{ !contains(fromJSON(env.not_in_conda), matrix.python-version) }} |
| 56 |
|
| 57 |
- name: Install additional Python 3.7 |
| 58 |
run: | |
| 59 |
conda create -n py37 --yes python=3.7 |
| 60 |
ln -s "$CONDA/envs/py37/bin/python" "$CONDA/envs/test/bin/python3.7" |
| 61 |
ln -s "$CONDA/envs/py37/bin/pip" "$CONDA/envs/test/bin/pip3.7" |
| 62 |
python3.7 --version |
| 63 |
pip3.7 --version |
| 64 |
shell: bash -el {0} |
| 65 |
if: ${{ matrix.python-version == '2.7' && runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/') }} |
| 66 |
- uses: actions/setup-python@v4 |
| 67 |
with: |
| 68 |
python-version: ${{ matrix.python-version }} |
| 69 |
if: ${{ contains(fromJSON(env.not_in_conda), matrix.python-version) }} |
| 70 |
- uses: actions/cache@v3 |
| 71 |
with: |
| 72 |
path: ~/conda_pkgs_dir |
| 73 |
key: ${{ runner.os }}-conda |
| 74 |
- name: Cache pip |
| 75 |
uses: actions/cache@v3 |
| 76 |
with: |
| 77 |
path: ${{ matrix.pip-cache-path }} |
| 78 |
key: ${{ runner.os }}-pip |
| 79 |
|
| 80 |
- name: Install dependencies |
| 81 |
run: | |
| 82 |
python --version |
| 83 |
python -m pip || python -m ensurepip --default-pip --upgrade |
| 84 |
python -m pip install --upgrade pip setuptools wheel |
| 85 |
pip --version |
| 86 |
pip install --upgrade virtualenv "tox >= 3.15, < 4" |
| 87 |
shell: bash -el {0} |
| 88 |
- name: Set TOXENV |
| 89 |
run: | |
| 90 |
python -c " |
| 91 |
import os, sys |
| 92 |
ld_library_path = None |
| 93 |
if hasattr(sys, 'pypy_version_info'): |
| 94 |
toxenv = 'pypy3' |
| 95 |
else: |
| 96 |
pyver = '%d%d' % tuple(sys.version_info[:2]) |
| 97 |
if (pyver == '27') and (os.name == 'posix'): # Python 2.7 on Linux requires `$LD_LIBRARY_PATH` |
| 98 |
ld_library_path = os.path.join( |
| 99 |
os.path.dirname(os.path.dirname(sys.executable)), 'lib') |
| 100 |
toxenv = 'py%s' % pyver |
| 101 |
if os.name == 'posix': |
| 102 |
toxenv += ',py%s-flake8' % pyver |
| 103 |
with open(os.environ['GITHUB_ENV'], 'a') as f: |
| 104 |
if ld_library_path: |
| 105 |
f.write('LD_LIBRARY_PATH=' + ld_library_path + '\n') |
| 106 |
f.write('TOXENV=' + toxenv + '\n') |
| 107 |
" |
| 108 |
shell: bash -el {0} |
| 109 |
|
| 110 |
- name: Run tox |
| 111 |
run: | |
| 112 |
python -c "import os; print(os.environ['TOXENV'])" |
| 113 |
tox --version |
| 114 |
tox |
| 115 |
shell: bash -el {0} |
| 116 |
|
| 117 |
- name: Build and publish sdist and wheel on Unix |
| 118 |
run: | |
| 119 |
pip install -U --ignore-installed certifi # Replace conda-installed |
| 120 |
devscripts/CI/ghactions-release |
| 121 |
env: |
| 122 |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
| 123 |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
| 124 |
shell: bash -el {0} |
| 125 |
if: ${{ !contains(matrix.python-version, '_pypy') && runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/') }} |
| 126 |
- name: Build and publish wheel on w32 |
| 127 |
run: | |
| 128 |
pip install -U pip setuptools twine wheel |
| 129 |
python setup.py bdist_wheel |
| 130 |
twine upload --disable-progress-bar --skip-existing dist\* |
| 131 |
if: ${{ !contains(matrix.python-version, '_pypy') && runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') }} |
| 132 |
env: |
| 133 |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
| 134 |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
| 135 |
- name: Build and publish wheel on Linux/aarch64 |
| 136 |
uses: uraimo/run-on-arch-action@v2 |
| 137 |
with: |
| 138 |
arch: aarch64 |
| 139 |
distro: ubuntu22.04 |
| 140 |
env: | |
| 141 |
PY_VER: "${{ matrix.python-version }}" |
| 142 |
RUNNER_OS: ${{ runner.os }} |
| 143 |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} |
| 144 |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} |
| 145 |
install: | |
| 146 |
set -ex |
| 147 |
apt-get update -q -y |
| 148 |
apt-get install -q -y curl gcc patchelf |
| 149 |
run: | |
| 150 |
set -ex |
| 151 |
CONDA_ROOT="$HOME"/miniforge3 |
| 152 |
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" |
| 153 |
bash Miniforge3-$(uname)-$(uname -m).sh -b -u -p "$CONDA_ROOT" |
| 154 |
source "$CONDA_ROOT"/etc/profile.d/conda.sh |
| 155 |
pyv="`echo $PY_VER | sed 's/\.//'`" |
| 156 |
conda create -n py$pyv --yes python=$PY_VER |
| 157 |
conda activate py$pyv |
| 158 |
python --version |
| 159 |
python -m pip || python -m ensurepip --default-pip --upgrade |
| 160 |
python -m pip install --upgrade pip setuptools wheel |
| 161 |
pip --version |
| 162 |
if [ $PY_VER = 2.7 ]; then |
| 163 |
conda create -n py37 --yes python=3.7 |
| 164 |
ln -s "$CONDA_ROOT"/envs/py37/bin/python "$HOME"/miniforge3/envs/py27/bin/python3.7 |
| 165 |
ln -s "$CONDA_ROOT"/envs/py37/bin/pip "$HOME"/miniforge3/envs/py27/bin/pip3.7 |
| 166 |
python3.7 --version |
| 167 |
pip3.7 --version |
| 168 |
fi |
| 169 |
exec devscripts/CI/ghactions-release |
| 170 |
if: ${{ !contains(fromJSON(env.not_in_aarch64), matrix.python-version) && runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') }} |
| 171 |
- name: Publish wheel to Releases |
| 172 |
uses: ncipollo/release-action@v1 |
| 173 |
with: |
| 174 |
artifacts: "dist/*" |
| 175 |
allowUpdates: true |
| 176 |
bodyFile: "LATEST-CHANGES.rst" |
| 177 |
omitBodyDuringUpdate: true |
| 178 |
omitNameDuringUpdate: true |
| 179 |
omitPrereleaseDuringUpdate: true |
| 180 |
prerelease: false |
| 181 |
replacesArtifacts: false |
| 182 |
skipIfReleaseExists: false |
| 183 |
updateOnlyUnreleased: false |
| 184 |
if: ${{ !contains(matrix.python-version, '_pypy') && startsWith(github.ref, 'refs/tags/') }} |