Skip to content

Commit

Permalink
Add more build platforms in GitHub Actions (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqtg authored Apr 4, 2024
1 parent 335d4a6 commit cbdc8f2
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 61 deletions.
76 changes: 46 additions & 30 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,63 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]

os: [windows-latest, ubuntu-latest, macos-13, macos-14]
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
versions:
- { python: "3.8", numpy: 1.22.4 }
- { python: "3.9", numpy: 1.22.4 }
- { python: "3.10", numpy: 1.22.4 }
- { python: "3.11", numpy: 1.24.3 }
- { python: "3.12", numpy: 1.26.4 }

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores

- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.versions.python }}
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.versions.python != '3.8') && (matrix.versions.python != '3.9')) }}
uses: actions/setup-python@v5
id: pysetup
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.versions.python }}
cache: 'pip'

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Upgrade pip wheel setuptools
run: python -m pip install wheel setuptools pip --upgrade
- name: Setup Python 3.8-3.9 - macos-arm
if: ${{ (matrix.os == 'macos-14') && ((matrix.versions.python == '3.8') || (matrix.versions.python == '3.9')) }}
run: |
brew update
brew install python@${{ matrix.versions.python }}
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python${{ matrix.versions.python }} get-pip.py
- name: Install numpy for Python 3.8
if: matrix.python-version == '3.8'
run: python -m pip install numpy==1.20.3

- name: Install numpy for Python 3.9
if: matrix.python-version == '3.9'
run: python -m pip install numpy==1.20.3
- name: Create Python alias for Windows
if: matrix.os == 'windows-latest'
run: |
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.versions.python }}.exe")
New-Item -ItemType HardLink -Path "$newPath" -Value "${{ steps.pysetup.outputs.python-path }}"
- name: Install numpy for Python 3.10
if: matrix.python-version == '3.10'
run: python -m pip install numpy==1.22.4
- name: Display Python and Pip versions
run: |
python${{ matrix.versions.python }} -c "import sys; print(sys.version)"
pip --version
- name: Install numpy for Python 3.11
if: matrix.python-version == '3.11'
run: python -m pip install numpy==1.24.3
- name: Upgrade pip wheel setuptools
run: pip install wheel setuptools pip --upgrade

- name: Install numpy ${{ matrix.versions.numpy }}
run: pip install numpy==${{ matrix.versions.numpy }}

- name: Display numpy version
run: python -c "import numpy; print(numpy.__version__)"
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"

- name: Install other dependencies
run: |
python -m pip install scipy Cython pytest pytest-cov flake8
python -m pip install -e .[tests]
pip install scipy Cython pytest pytest-cov flake8
python${{ matrix.versions.python }} setup.py build_ext -j${{ steps.cpu-cores.outputs.count }}
pip install -e .[tests]
- name: Lint with flake8
run: |
Expand All @@ -67,4 +83,4 @@ jobs:
- name: Test with pytest
run: |
python -m pytest --cov=cornac
pytest --cov=cornac
76 changes: 45 additions & 31 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,62 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
os: [windows-latest, ubuntu-latest, macos-13, macos-14]
versions:
- { python: "3.8", numpy: 1.22.4 }
- { python: "3.9", numpy: 1.22.4 }
- { python: "3.10", numpy: 1.22.4 }
- { python: "3.11", numpy: 1.24.3 }
- { python: "3.12", numpy: 1.26.4 }

- name: Set up Python
uses: actions/setup-python@v2
steps:
- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.versions.python }}
if: ${{ (matrix.os != 'macos-14') || ((matrix.os == 'macos-14') && (matrix.versions.python != '3.8') && (matrix.versions.python != '3.9')) }}
uses: actions/setup-python@v5
id: pysetup
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.versions.python }}
cache: 'pip'

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install numpy for Python 3.8
if: matrix.python-version == '3.8'
run: python -m pip install numpy==1.20.3

- name: Install numpy for Python 3.9
if: matrix.python-version == '3.9'
run: python -m pip install numpy==1.20.3
- name: Setup Python 3.8-3.9 - macos-arm
if: ${{ (matrix.os == 'macos-14') && ((matrix.versions.python == '3.8') || (matrix.versions.python == '3.9')) }}
run: |
brew update
brew install python@${{ matrix.versions.python }}
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python${{ matrix.versions.python }} get-pip.py
- name: Install numpy for Python 3.10
if: matrix.python-version == '3.10'
run: python -m pip install numpy==1.22.4
- name: Create Python alias for Windows
if: matrix.os == 'windows-latest'
run: |
$newPath = "${{ steps.pysetup.outputs.python-path }}".Replace("python.exe", "python${{ matrix.versions.python }}.exe")
New-Item -ItemType HardLink -Path "$newPath" -Value "${{ steps.pysetup.outputs.python-path }}"
- name: Install numpy for Python 3.11
if: matrix.python-version == '3.11'
run: python -m pip install numpy==1.24.3
- name: Display Python and Pip versions
run: |
python${{ matrix.versions.python }} -c "import sys; print(sys.version)"
pip --version
- name: Upgrade pip wheel setuptools
run: pip install wheel setuptools pip --upgrade

- name: Install numpy ${{ matrix.versions.numpy }}
run: pip install numpy==${{ matrix.versions.numpy }}

- name: Display numpy version
run: python -c "import numpy; print(numpy.__version__)"
run: python${{ matrix.versions.python }} -c "import numpy; print(numpy.__version__)"

- name: Install other dependencies
run: |
python -m pip install scipy Cython wheel
pip install scipy Cython wheel
- name: Build wheels
run: python setup.py bdist_wheel
run: python${{ matrix.versions.python }} setup.py bdist_wheel

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

- name: Publish wheels to GitHub artifacts
Expand All @@ -72,17 +86,17 @@ jobs:

publish-pypi:
needs: [build-wheels]
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/download-artifact@v2
with:
name: wheels
path: dist/

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def run(self):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
Expand Down

0 comments on commit cbdc8f2

Please sign in to comment.