Skip to content

Commit cbdc8f2

Browse files
authored
Add more build platforms in GitHub Actions (#612)
1 parent 335d4a6 commit cbdc8f2

3 files changed

Lines changed: 92 additions & 61 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,63 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: [ubuntu-20.04, macos-latest, windows-latest]
20-
python-version: ["3.8", "3.9", "3.10", "3.11"]
21-
19+
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
20+
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
21+
versions:
22+
- { python: "3.8", numpy: 1.22.4 }
23+
- { python: "3.9", numpy: 1.22.4 }
24+
- { python: "3.10", numpy: 1.22.4 }
25+
- { python: "3.11", numpy: 1.24.3 }
26+
- { python: "3.12", numpy: 1.26.4 }
27+
2228
steps:
23-
- uses: actions/checkout@v2
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v2
29+
- name: Get number of CPU cores
30+
uses: SimenB/github-actions-cpu-cores@v2
31+
id: cpu-cores
32+
33+
- uses: actions/checkout@v4
34+
35+
- name: Setup Python ${{ matrix.versions.python }}
36+
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.versions.python != '3.8') && (matrix.versions.python != '3.9')) }}
37+
uses: actions/setup-python@v5
38+
id: pysetup
2739
with:
28-
python-version: ${{ matrix.python-version }}
40+
python-version: ${{ matrix.versions.python }}
2941
cache: 'pip'
3042

31-
- name: Display Python version
32-
run: python -c "import sys; print(sys.version)"
33-
34-
- name: Upgrade pip wheel setuptools
35-
run: python -m pip install wheel setuptools pip --upgrade
43+
- name: Setup Python 3.8-3.9 - macos-arm
44+
if: ${{ (matrix.os == 'macos-14') && ((matrix.versions.python == '3.8') || (matrix.versions.python == '3.9')) }}
45+
run: |
46+
brew update
47+
brew install python@${{ matrix.versions.python }}
48+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
49+
python${{ matrix.versions.python }} get-pip.py
3650
37-
- name: Install numpy for Python 3.8
38-
if: matrix.python-version == '3.8'
39-
run: python -m pip install numpy==1.20.3
40-
41-
- name: Install numpy for Python 3.9
42-
if: matrix.python-version == '3.9'
43-
run: python -m pip install numpy==1.20.3
51+
- name: Create Python alias for Windows
52+
if: matrix.os == 'windows-latest'
53+
run: |
54+
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.versions.python }}.exe")
55+
New-Item -ItemType HardLink -Path "$newPath" -Value "${{ steps.pysetup.outputs.python-path }}"
4456
45-
- name: Install numpy for Python 3.10
46-
if: matrix.python-version == '3.10'
47-
run: python -m pip install numpy==1.22.4
57+
- name: Display Python and Pip versions
58+
run: |
59+
python${{ matrix.versions.python }} -c "import sys; print(sys.version)"
60+
pip --version
4861
49-
- name: Install numpy for Python 3.11
50-
if: matrix.python-version == '3.11'
51-
run: python -m pip install numpy==1.24.3
62+
- name: Upgrade pip wheel setuptools
63+
run: pip install wheel setuptools pip --upgrade
5264

65+
- name: Install numpy ${{ matrix.versions.numpy }}
66+
run: pip install numpy==${{ matrix.versions.numpy }}
67+
5368
- name: Display numpy version
54-
run: python -c "import numpy; print(numpy.__version__)"
69+
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"
5570

5671
- name: Install other dependencies
5772
run: |
58-
python -m pip install scipy Cython pytest pytest-cov flake8
59-
python -m pip install -e .[tests]
73+
pip install scipy Cython pytest pytest-cov flake8
74+
python${{ matrix.versions.python }} setup.py build_ext -j${{ steps.cpu-cores.outputs.count }}
75+
pip install -e .[tests]
6076
6177
- name: Lint with flake8
6278
run: |
@@ -67,4 +83,4 @@ jobs:
6783
6884
- name: Test with pytest
6985
run: |
70-
python -m pytest --cov=cornac
86+
pytest --cov=cornac

.github/workflows/python-publish.yml

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,62 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
os: [ubuntu-20.04, macos-latest, windows-latest]
23-
python-version: ["3.8", "3.9", "3.10", "3.11"]
24-
25-
steps:
26-
- uses: actions/checkout@v2
22+
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
23+
versions:
24+
- { python: "3.8", numpy: 1.22.4 }
25+
- { python: "3.9", numpy: 1.22.4 }
26+
- { python: "3.10", numpy: 1.22.4 }
27+
- { python: "3.11", numpy: 1.24.3 }
28+
- { python: "3.12", numpy: 1.26.4 }
2729

28-
- name: Set up Python
29-
uses: actions/setup-python@v2
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup Python ${{ matrix.versions.python }}
34+
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.versions.python != '3.8') && (matrix.versions.python != '3.9')) }}
35+
uses: actions/setup-python@v5
36+
id: pysetup
3037
with:
31-
python-version: ${{ matrix.python-version }}
38+
python-version: ${{ matrix.versions.python }}
39+
cache: 'pip'
3240

33-
- name: Display Python version
34-
run: python -c "import sys; print(sys.version)"
35-
36-
- name: Install numpy for Python 3.8
37-
if: matrix.python-version == '3.8'
38-
run: python -m pip install numpy==1.20.3
39-
40-
- name: Install numpy for Python 3.9
41-
if: matrix.python-version == '3.9'
42-
run: python -m pip install numpy==1.20.3
41+
- name: Setup Python 3.8-3.9 - macos-arm
42+
if: ${{ (matrix.os == 'macos-14') && ((matrix.versions.python == '3.8') || (matrix.versions.python == '3.9')) }}
43+
run: |
44+
brew update
45+
brew install python@${{ matrix.versions.python }}
46+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
47+
python${{ matrix.versions.python }} get-pip.py
4348
44-
- name: Install numpy for Python 3.10
45-
if: matrix.python-version == '3.10'
46-
run: python -m pip install numpy==1.22.4
49+
- name: Create Python alias for Windows
50+
if: matrix.os == 'windows-latest'
51+
run: |
52+
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.versions.python }}.exe")
53+
New-Item -ItemType HardLink -Path "$newPath" -Value "${{ steps.pysetup.outputs.python-path }}"
4754
48-
- name: Install numpy for Python 3.11
49-
if: matrix.python-version == '3.11'
50-
run: python -m pip install numpy==1.24.3
55+
- name: Display Python and Pip versions
56+
run: |
57+
python${{ matrix.versions.python }} -c "import sys; print(sys.version)"
58+
pip --version
5159
60+
- name: Upgrade pip wheel setuptools
61+
run: pip install wheel setuptools pip --upgrade
62+
63+
- name: Install numpy ${{ matrix.versions.numpy }}
64+
run: pip install numpy==${{ matrix.versions.numpy }}
65+
5266
- name: Display numpy version
53-
run: python -c "import numpy; print(numpy.__version__)"
67+
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"
5468

5569
- name: Install other dependencies
5670
run: |
57-
python -m pip install scipy Cython wheel
71+
pip install scipy Cython wheel
5872
5973
- name: Build wheels
60-
run: python setup.py bdist_wheel
74+
run: python${{ matrix.versions.python }} setup.py bdist_wheel
6175

6276
- name: Rename Linux wheels to supported platform of PyPI
63-
if: matrix.os == 'ubuntu-20.04'
77+
if: matrix.os == 'ubuntu-latest'
6478
run: for f in dist/*.whl; do mv "$f" "$(echo "$f" | sed s/linux/manylinux1/)"; done
6579

6680
- name: Publish wheels to GitHub artifacts
@@ -72,17 +86,17 @@ jobs:
7286

7387
publish-pypi:
7488
needs: [build-wheels]
75-
runs-on: ubuntu-20.04
89+
runs-on: ubuntu-latest
7690
steps:
77-
- uses: actions/checkout@v2
91+
- uses: actions/checkout@v4
7892

7993
- uses: actions/download-artifact@v2
8094
with:
8195
name: wheels
8296
path: dist/
8397

8498
- name: Set up Python
85-
uses: actions/setup-python@v2
99+
uses: actions/setup-python@v5
86100
with:
87101
python-version: "3.10"
88102

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def run(self):
357357
"Programming Language :: Python :: 3.9",
358358
"Programming Language :: Python :: 3.10",
359359
"Programming Language :: Python :: 3.11",
360+
"Programming Language :: Python :: 3.12",
360361
"License :: OSI Approved :: Apache Software License",
361362
"Topic :: Software Development",
362363
"Topic :: Scientific/Engineering",

0 commit comments

Comments
 (0)