Skip to content

Commit

Permalink
CI: Try to make Ubuntu wheels easier to install (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-ward authored Jan 10, 2023
1 parent 94e3d99 commit fe554bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
os: ["ubuntu-22.04", "ubuntu-20.04", "macos-12"]
platform: ["x86_64"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
env:
PLATFORM_OS: ${{ matrix.os }}

steps:
- name: Checkout repository
Expand Down Expand Up @@ -130,9 +132,12 @@ jobs:
sudo mkdir -p $BUILD_TEMP_DIR
sudo chown -R $(id -u):$(id -g) $BUILD_TEMP_DIR
pip install wheel
python setup.py bdist_wheel --plat-name=$PLATFORM_TAG
python setup.py bdist_wheel
echo "List wheels"
ls ./dist
find ./dist -type f -name '*.whl' -exec mv {} {}.$PLATFORM_OS \;
echo "Renamed with $PLATFORM_OS suffix"
ls ./dist
- name: Build package for MacOS
if: runner.os == 'macOS'
Expand All @@ -144,9 +149,10 @@ jobs:
pip install wheel
python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
- name: "Upload artifacts"
uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
path: ./dist/*

test-wheels:
name: Test wheels on ${{ matrix.os }} ${{ matrix.platform }} (Python ${{ matrix.python-version }})
Expand All @@ -158,7 +164,7 @@ jobs:
os: ["ubuntu-22.04", "ubuntu-20.04", "macos-12", "macos-11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
env:
PYTHON_VERSION: ${{ matrix.python-version }}
PLATFORM_OS: ${{ matrix.os }}

steps:
- name: Install Ubuntu 22.04 runtime dependencies
Expand All @@ -176,7 +182,6 @@ jobs:
libegl1 \
libopengl0 \
xvfb
echo "PLATFORM_TAG=ubuntu22_04_x86_64" >> $GITHUB_ENV
- name: Install Ubuntu 20.04 runtime dependencies
if: matrix.os == 'ubuntu-20.04'
Expand All @@ -193,7 +198,6 @@ jobs:
libegl1 \
libopengl0 \
xvfb
echo "PLATFORM_TAG=ubuntu20_04_x86_64" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -208,15 +212,14 @@ jobs:
- name: Install dependencies
shell: bash
run: |
echo "PYTHON_SITE_PACKAGES=$pythonLocation/lib/python$PYTHON_VERSION/site-packages" >> $GITHUB_ENV
python -m pip install pytest Pillow numpy pixelmatch python-dotenv
- name: Install and test wheels on Ubuntu
if: runner.os == 'Linux'
run: |
python -m pip install --find-links wheelhouse/artifact --platform $PLATFORM_TAG --target $PYTHON_SITE_PACKAGES --no-deps --upgrade pymgl
find ./wheelhouse/artifact -type f -name "*.whl.$PLATFORM_OS" -print0 -exec bash -c 'mv "${0}" "${0//.$PLATFORM_OS/}"' {} \;
python -m pip install --find-links wheelhouse/artifact pymgl
python -m pip list
python -m pip list --path $PYTHON_SITE_PACKAGES
xvfb-run -a --server-args="-screen 0 1024x768x24 -ac +render -noreset" \
python -m pytest --pyargs pymgl -v
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ Ubuntu 22.04 and 20.04.

Wheels are available on the release page in Github. Download and install from there.

Something like:
Unfortunately, Python wheel names are very restrictive, so we have added
`.ubuntu-22.04` and `.ubuntu-20.04` suffixes to the wheel names, which have to
be stripped off before you can install them.

Something like this for Ubuntu 22.04:

```bash
pip install https://github.com/brendan-ward/pymgl/releases/download/<release>/pymgl-<release>-<Python version>-<Python version>-ubuntu<Ubuntu version>_x86_64.whl

wget https://github.com/brendan-ward/pymgl/releases/download/<release>/pymgl-<release>-<Python version>-<Python version>-linux_x86_64.whl.ubuntu-22.04
# rename file to remove .ubuntu-22.04 suffix
find . -type f -name "*.whl.ubuntu-22.04" -print0 -exec bash -c 'mv "${0}" "${0//.ubuntu-22.04/}"' {} \;
python3 -m pip install --find-links . pymgl
```

You also need to install the following runtime dependencies:
Expand Down

0 comments on commit fe554bc

Please sign in to comment.