Skip to content

Commit

Permalink
Complete packaging support (using manylinux)
Browse files Browse the repository at this point in the history
See RELEASING.md for steps to release a new pygrgl version.
  • Loading branch information
dcdehaas committed Oct 8, 2024
1 parent f1d4cae commit b69f45e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 62 deletions.
1 change: 1 addition & 0 deletions Dockerfile.package
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM quay.io/pypa/manylinux_2_28_x86_64
27 changes: 0 additions & 27 deletions Dockerfile.pkg1

This file was deleted.

21 changes: 0 additions & 21 deletions Dockerfile.pkg2

This file was deleted.

27 changes: 13 additions & 14 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@ Steps:

## Packaging for PyPi

Build the package distributions for PyPi. We build a source dist and then Linux binary distributions for recent Python versions.
Build the package distributions for PyPi. We build a source dist and then Linux binary distributions for recent Python versions. The container is based on the [manylinux](https://github.com/pypa/manylinux) project.

```
# Remove dist/ to start fresh
rm -rf dist
# Build the source distribution (for MacOS, mostly)
python setup.py sdist
# Build the container based on the manylinux project
docker build . -f Dockerfile.pkg -t grgl_pkg:latest
# Build the Python3.8 and Python3.9 packages on an older Docker image
docker build . -f Dockerfile.pkg1 -t grgl_pkg1:latest
docker run -v $PWD/dist:/dist -it grgl_pkg1:latest bash -c "cp /output/*.whl /dist/"
# Build the Python3.10+ packages on a newer Docker image
docker build . -f Dockerfile.pkg2 -t grgl_pkg2:latest
docker run -v $PWD/dist:/dist -it grgl_pkg2:latest bash -c "cp /output/*.whl /dist/"
# Run the packaging inside the container
docker run -v $PWD:/io -it grgl_pkg:latest /io/package.sh
# Fix file permissions from Docker
sudo chown ddehaas dist/*.whl
sudo chgrp ddehaas dist/*.whl
sudo chown -R ddehaas dist/
sudo chgrp -R ddehaas dist/
# Copy the source wheel to wheelhouse
cp ./dist/*.tar.gz ./dist/wheelhouse/
```

To upload to PyPi, ensure that your dist directory is clean (only has the packages you _just_ built), then upload via twine:
To upload to PyPi:
```
python3 -m twine upload dist/*
python3 -m twine upload dist/wheelhouse/*
```
26 changes: 26 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -ev

cd /io

# Build the source distribution
/opt/python/cp38-cp38/bin/python setup.py sdist

echo "Building for Python 3.8"
GRGL_GSL=1 GRGL_BGEN=1 /opt/python/cp38-cp38/bin/python setup.py bdist_wheel
echo "Building for Python 3.9"
GRGL_GSL=1 GRGL_BGEN=1 /opt/python/cp39-cp39/bin/python setup.py bdist_wheel
echo "Building for Python 3.10"
GRGL_GSL=1 GRGL_BGEN=1 /opt/python/cp310-cp310/bin/python setup.py bdist_wheel
echo "Building for Python 3.11"
GRGL_GSL=1 GRGL_BGEN=1 /opt/python/cp311-cp311/bin/python setup.py bdist_wheel
echo "Building for Python 3.12"
GRGL_GSL=1 GRGL_BGEN=1 /opt/python/cp312-cp312/bin/python setup.py bdist_wheel

cd /io/dist
auditwheel repair --plat manylinux_2_24_x86_64 pygrgl-1.1-cp38-cp38-linux_x86_64.whl
auditwheel repair --plat manylinux_2_24_x86_64 pygrgl-1.1-cp39-cp39-linux_x86_64.whl
auditwheel repair --plat manylinux_2_24_x86_64 pygrgl-1.1-cp310-cp310-linux_x86_64.whl
auditwheel repair --plat manylinux_2_24_x86_64 pygrgl-1.1-cp311-cp311-linux_x86_64.whl
auditwheel repair --plat manylinux_2_24_x86_64 pygrgl-1.1-cp312-cp312-linux_x86_64.whl

0 comments on commit b69f45e

Please sign in to comment.