Skip to content

Commit

Permalink
Add/wheels (#6)
Browse files Browse the repository at this point in the history
* add wheel build

this wont work because pypi will not accept this build, but
maybe someone else can help to use manylinuxl...

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed May 11, 2023
1 parent f52702a commit 5434941
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 54 deletions.
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
11 changes: 6 additions & 5 deletions .github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

# This will be empty for nightly test, and we will clone master branch
FLUX_RELEASE_VERSION=${FLUX_RELEASE_VERSION:-0.50.0}
FLUX_VERSION=${FLUX_VERSION:-develop}
FLUX_VERSION=${FLUX_VERSION:-0.50.0}

# Prepare the version file
echo "Flux Version for pypi is ${FLUX_VERSION}"
Expand All @@ -15,6 +15,7 @@ sudo apt-get update
sudo apt-get install -y \
libjson-glib-dev \
wget \
curl \
automake \
libsodium-dev \
libzmq3-dev \
Expand Down Expand Up @@ -46,12 +47,12 @@ sudo rm -rf /var/lib/apt/lists/*

sudo python3 -m pip install IPython
sudo python3 -m pip install -r .github/scripts/requirements-dev.txt
export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib

git clone https://github.com/flux-framework/flux-security ~/security
cd ~/security
./autogen.sh
./configure --prefix=/usr
./configure --prefix=/usr/local
make
sudo make install
sudo ldconfig
Expand All @@ -69,7 +70,7 @@ chmod +x etc/gen-cmdhelp.py

# This is only needed for non-releases
./autogen.sh || echo "No autogen here"
./configure --prefix=/usr
./configure --prefix=/usr/local

# We don't really care about the version here -just building python bindings
make VERBOSE=1
Expand All @@ -78,4 +79,4 @@ make VERBOSE=1
sudo make install || true
sudo make install
sudo ldconfig
cd ${here}
cd ${here}
58 changes: 58 additions & 0 deletions .github/workflows/build-legacy-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build-legacy flux-python

on:
pull_request: []
workflow_dispatch:
inputs:
branch:
description: 'Branch to build from'
default: "master"
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-legacy-wheels:
runs-on: ubuntu-latest
container:
image: fluxrm/testenv:focal
steps:
- uses: actions/checkout@v3

- name: Build Flux Core Branch
env:
FLUX_RELEASE_VERSION: ${{ inputs.release_version }}
FLUX_VERSION: ${{ inputs.version }}
run: /bin/bash .github/scripts/setup.sh

- name: Build Python Bindings
env:
FLUX_BRANCH: ${{ inputs.branch }}
FLUX_REPO: ${{ inputs.repo }}

run: |
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
python3 setup.py sdist
sudo ldconfig
- name: Build Python Wheels
env:
build_number: ${{ inputs.rc }}
run: |
/bin/bash ./docker/install-mamba.sh
/bin/bash ./docker/build-wheels.sh ${build_number}
- 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/*
2 changes: 1 addition & 1 deletion .github/workflows/build-legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
default: "https://github.com/rse-ops/flux-core-python"

jobs:
build-manual:
build-legacy:
runs-on: ubuntu-latest
container:
image: fluxrm/testenv:focal
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/build-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
release_version:
description: 'Version of flux to build'
default: "0.50.0"
rc:
description: 'Release candidate to build (for wheel)'
default: "0"
branch:
description: 'Branch to build from'
default: "master"
Expand Down Expand Up @@ -47,7 +50,14 @@ jobs:
mv /tmp/flux-core/src/bindings/python/flux ./flux
python3 setup.py sdist
sudo ldconfig
- name: Build Python Wheels
env:
build_number: ${{ inputs.rc }}
run: |
/bin/bash ./docker/install-mamba.sh
/bin/bash ./docker/build-wheels.sh ${build_number}
- name: Install dependencies
if: (github.event_name != 'pull_request')
run: python3 -m pip install setuptools wheel twine
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
14 changes: 10 additions & 4 deletions LLNL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

> 🐍️ You called me?
**Important** these bindings are under development, and we are still working on automation
and improvement! If you run into an issue, please [let us know](https://github.com/flux-framework/flux-python/issues)
so that we can fix.

Are you looking for specific instructions for your system at LLNL? You've
come to the right place! If your Python install or system is missing from here,
please [let us know](https://github.com/flux-framework/flux-python/issues).

**Important** these bindings are under development, and we are still working on automation
and improvement! If you run into an issue, please [let us know](https://github.com/flux-framework/flux-python/issues)
so that we can fix. For our wheels (under development) you will need `wheel` installed:

```bash
$ pip install wheel
```

And if it fails, it should fall back to the install from source.

## How does it work?

If you are installing the .tar.gz (from source) we try to link to Flux libraries by way of finding the main `flux` binary,
Expand Down
64 changes: 23 additions & 41 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,17 @@ $ 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
# The number is the build number
/bin/bash ./docker/build-wheels.sh 2
```

And if you want to upload:

```bash
Expand All @@ -58,7 +69,13 @@ $ twine upload dist/*.tar.gz
## Install on a System

Since we need to link to Flux libraries, you are advised to install flux and flux-security in the same location
that will be discovered via the executable "flux," so typically `/usr` or `/usr/local`. You can do either:
that will be discovered via the executable "flux," so typically `/usr` or `/usr/local`. You will need `wheel` installed:

```bash
$ pip install wheel
```

You can do either:

```bash
# Find the flux version on your system
Expand All @@ -82,39 +99,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 +135,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
23 changes: 23 additions & 0 deletions docker/build-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

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

version=${1}
build_number=${2:-0}

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
python3 setup.py bdist_wheel --plat-name=any --build-number=${build_number}
unset PYTHONPATH
11 changes: 11 additions & 0 deletions docker/build-wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

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

# 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} ${build_number}
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 $(id -u) /opt/conda

0 comments on commit 5434941

Please sign in to comment.