Skip to content

add wheel build #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ RUN git clone https://github.com/flux-framework/flux-security ~/security && \
./configure --prefix=/usr && \
make && \
sudo make install && \
sudo ldconfig
sudo ldconfig
55 changes: 55 additions & 0 deletions .github/workflows/build-legacy-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: build-legacy flux-python

on:
pull_request: []
workflow_dispatch:
inputs:
rc:
description: 'Release candiate to target for wheels'
default: "0"
repo:
description: 'Repository to build from'
default: "https://github.com/rse-ops/flux-core-python"

jobs:
build-manual:
runs-on: ubuntu-latest
container:
image: fluxrm/testenv:focal
steps:
- uses: actions/checkout@v3

- name: Prepare Versions
env:
FLUX_RELEASE_VERSION: ${{ inputs.release_version }}
FLUX_BRANCH: ${{ inputs.branch }}
FLUX_REPO: ${{ inputs.repo }}
run: |
echo ${FLUX_RELEASE_VERSION} > ./flux-release-version
echo ${FLUX_BRANCH} > ./flux-branch
echo ${FLUX_REPO} > ./flux-repo

- uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2010_x86_64
with:
python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311'
# build-requirements: 'cython numpy'
# system-packages: 'lrzip-devel zlib-devel'
pre-build-command: sh ./docker/pre-build.sh
# package-path: 'my_project'
#pip-wheel-args: '-w ./dist --no-deps'

- name: Build Python Wheels
run: |
/bin/bash ./docker/install-mamba.sh
/bin/bash ./docker/build-wheels.sh

- name: Install dependencies
if: (github.event_name != 'pull_request')
run: python3 -m pip install setuptools wheel twine

- name: Build and publish
if: (github.event_name != 'pull_request')
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
run: twine upload dist/*
5 changes: 5 additions & 0 deletions .github/workflows/build-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ jobs:
mv /tmp/flux-core/src/bindings/python/flux ./flux
python3 setup.py sdist
sudo ldconfig

- name: Build Python Wheels
run: |
/bin/bash ./docker/install-mamba.sh
/bin/bash ./docker/build-wheels.sh

- name: Install dependencies
if: (github.event_name != 'pull_request')
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ jobs:
- name: Build Python Bindings
run: |
mv /code/src/bindings/python/flux ./flux
python3 setup.py sdist
python3 setup.py sdist

- name: Build Python Wheels
run: |
/bin/bash ./docker/install-mamba.sh
/bin/bash ./docker/build-wheels.sh
55 changes: 15 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ If you want to build a custom version with Flux core you can do:

```bash
rm -rf ~/flux-core
export FLUX_VERSION=0.48.0
export FLUX_VERSION=0.49.0
wget https://github.com/flux-framework/flux-core/releases/download/v${FLUX_VERSION}/flux-core-${FLUX_VERSION}.tar.gz
tar -xzvf flux-core-${FLUX_VERSION}.tar.gz
sudo mv flux-core-${FLUX_VERSION} ~/flux-core
rm flux-core-${FLUX_VERSION}.tar.gz
cd ~/flux-core
./configure --prefix=/usr/local
./configure --prefix=/usr
make
sudo make install
```
Expand All @@ -49,6 +49,16 @@ $ python3 setup.py sdist
$ python3 setup.py sdist bdist_wheel
```

You can build versions of the Python wheels across 3.6 to 3.10 like:

```bash
# only need to run this once in the container
/bin/bash ./docker/install-mamba.sh

# And this to install the current Flux + version in setup.py as a wheel
/bin/bash ./docker/build-wheels.sh
```

And if you want to upload:

```bash
Expand Down Expand Up @@ -82,39 +92,13 @@ If you install to a local (personal) location (e.g., `$HOME/.local`) you'll need
export PYTHONPATH=$HOME/.local/lib/python3.7/site-packages
```

### Building Modules

We will need to build the tarball providing paths to the flux-core and flux-security
sources. This can be improved upon to just be one path if all the dependencies
are provided with the flux install (and we don't need the source). Note
that we also provide a custom version for the pypi package:

```bash
# Generate the wheel (requires pip install wheel)
$ python3 setup.py sdist bdist_wheel --flux-root /home/vscode/flux-core --security-src /home/vscode/security --security-include /usr/local/include/flux/security --version 0.46.0-rc-0
```

You can then install the wheel (as a user or to the root)

```bash
$ pip install dist/flux-0.46.0-cp38-cp38-linux_x86_64.whl --user
$ sudo pip install dist/flux-0.46.0-cp38-cp38-linux_x86_64.whl
```
```console
Processing ./dist/flux-0.46.0-cp38-cp38-linux_x86_64.whl
Requirement already satisfied: cffi>=1.1 in /usr/lib/python3/dist-packages (from flux==0.46.0) (1.14.0)
Installing collected packages: flux
Successfully installed flux-0.46.0
```

If the development container you are using still installs the Python bindings, you'll want to do the sudo variant above to override.
And then start a flux instance:
You can then do some basic testing.

```bash
$ flux start --test-size=4
```

And import flux.
**Ensure your PYTHONPATH is correct here** And import flux.

```bash
$ ipython
Expand Down Expand Up @@ -144,17 +128,8 @@ $ python .github/scripts/check_releases.py flux-framework --version 0.46.0
That basically checks if there should be a build. It will use the container provided
here to install a custom version of flux core that builds the release.

### Work in Progress

@vsoch wants to try installing her test releases to a system somewhere, and figure
out this issue with buidling a wheel (or maybe we don't want wheels after all):

> HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
> Binary wheel 'flux_python-0.46.0rc0-cp38-cp38-linux_x86_64.whl' has an
> unsupported platform tag 'linux_x86_64'.

#### Release

SPDX-License-Identifier: LGPL-3.0

LLNL-CODE-764420
LLNL-CODE-764420
21 changes: 21 additions & 0 deletions docker/build-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

here=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

version=${1}

if [[ "${version}" == "" ]]; then
echo "Version must be provided as script argument"
exit
fi

# This is intended to run in the container
echo "Building Python version ${version}"
/opt/conda/bin/mamba create -y -p /tmp/py${version} python==${version}
/opt/conda/bin/mamba install -y -q -p /tmp/py${version} cffi ply six pyyaml jsonschema
export PATH=/tmp/py${version}/bin:$PATH
export PYTHONPATH=/tmp/py${version}/lib/python3.6/site-packages

# Build the bindings for this python version!
python3 setup.py sdist bdist_wheel
unset PYTHONPATH
10 changes: 10 additions & 0 deletions docker/build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

here=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Create python environments for each version we want to release!
# We wrap like this because this script can be used locally, but
# in GitHub actions we want to do in a matrix
for version in 3.6 3.7 3.8 3.9 3.10; do
/bin/bash $here/build-wheel.sh ${version}
done
10 changes: 10 additions & 0 deletions docker/install-mamba.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Install mamba for different python versions
# Python - instead of a system python we install mamba
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh > mambaforge.sh
chmod +x ./mambaforge.sh
sudo bash mambaforge.sh -b -p /opt/conda
rm mambaforge.sh
/opt/conda/bin/pip install --upgrade --ignore-installed coverage cffi ply six pyyaml jsonschema
sudo chown -R vscode /opt/conda
120 changes: 120 additions & 0 deletions docker/pre-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

# This will install flux-core and flux-security into the
# alma image.

here=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
root=$(dirname $here)
ls

FLUX_REPO=$(cat ./flux-repo)
FLUX_BRANCH=$(cat ./flux-branch)
FLUX_RELEASE_VERSION=$(cat ./flux-release-version)

echo "repo: $FLUX_REPO"
echo "branch: $FLUX_BRANCH"
echo "release: $FLUX_RELEASE_VERSION"

git clone -b ${FLUX_BRANCH} ${FLUX_REPO} /tmp/flux-core || git clone https://github.com/flux-framework/flux-core /tmp/flux-core
mv /tmp/flux-core/src/bindings/python/flux ./flux
export FLUX_REPO FLUX_BRANCH FLUX_RELEASE_VERSION

yum -y update \
&& yum -y install epel-release \
&& yum -y install \
wget \
man-db \
less \
xz \
lbzip2 \
fftw-devel \
fftw \
git \
curl \
bind-utils \
sudo \
munge \
ccache \
lua \
valgrind \
jq \
which \
file \
unzip \
vim \
patch \
diffutils \
pkgconfig \
libtool \
autoconf \
automake \
gcc-gfortran \
gcc \
gcc-c++ \
make \
cmake \
bison \
flex \
python36 \
python3-devel \
python3-six \
python3-yaml \
python3-jsonschema \
python3-sphinx \
libsodium \
libsodium-devel \
libyaml-devel \
libgomp \
zeromq-devel \
czmq-devel \
jansson-devel \
munge-devel \
ncurses-devel \
lz4-devel \
sqlite-devel \
boost-devel \
libuuid-devel \
hwloc-devel \
lua-devel \
libedit-devel \
valgrind-devel \
libs3-devel \
systemd-devel \
libarchive-devel \
pam-devel \
openssh-server \
openssh-clients \
perl-Time-HiRes \
lua-posix \
libfaketime \
cppcheck \
enchant \
aspell \
aspell-en \
sudo \
glibc-langpack-en \
hwloc \
&& yum clean all

ldconfig
ln -fs /usr/local/bin/python3.8 /usr/bin/python3
printf "LANG=C.UTF-8" > /etc/locale.conf

# Assuming installing to /usr
export LD_LIBRARY_PATH=/usr/lib

# Full clone in case...
git clone https://github.com/flux-framework/flux-core ~/flux-core
cd ~/flux-core
./autogen.sh
./configure --prefix=/usr
make
make install

git clone https://github.com/flux-framework/flux-security ~/security
cd ~/security
./autogen.sh
./configure --prefix=/usr
make
make install
ldconfig
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Metadata
package_name = "flux-python"
package_version = "develop"
package_version = "0.49.0rc2"
package_description = "Python bindings for the flux resource manager API"
package_url = "https://github.com/flux-framework/flux-python"
package_keywords = "flux, job manager, workload manager, orchestration, hpc"
Expand Down