Skip to content
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

Generate manylinux wheels #13

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fb3ae38
Merge pull request #4 from DanShort12/serialise_plasma_source
DanShort12 Sep 24, 2020
f6059de
Use cibuildwheel to create wheels
DanShort12 Sep 24, 2020
3fd24bf
Work in manylinux container
DanShort12 Sep 24, 2020
f1381ba
No sudo as we're in a container
DanShort12 Sep 24, 2020
9f5d9e4
Use yum rather than apt
DanShort12 Sep 24, 2020
00ec010
Use yum package names
DanShort12 Sep 24, 2020
4972b86
Use cmake3
DanShort12 Sep 24, 2020
b7ceb2e
Register cmake3 as alternative for cmake
DanShort12 Sep 24, 2020
b404fd3
Run pip as a python module
DanShort12 Sep 24, 2020
a4c46d8
Use manylinux installed python
DanShort12 Sep 24, 2020
494abf5
Install auditwheel and repair
DanShort12 Sep 24, 2020
90a2b40
Test to determine which python is used for test
DanShort12 Sep 24, 2020
d83d4cd
Use correct python version for tests
DanShort12 Sep 25, 2020
037f1b1
Run tests from within tests directory
DanShort12 Sep 25, 2020
c3e9ebe
Support Python 3.9
DanShort12 Sep 25, 2020
1883ec6
Publish wheel to test PyPI
DanShort12 Sep 25, 2020
c54d596
Fix indentation
DanShort12 Sep 25, 2020
6e66b52
Don't upload to TestPyPI for now
DanShort12 Sep 25, 2020
8144f77
Generate version from git tags and commits
DanShort12 Sep 28, 2020
7e499ad
Refactor actions and include publish to PyPI
DanShort12 Sep 28, 2020
9b2ecf2
Fix yaml syntax error
DanShort12 Sep 28, 2020
319d361
Add missing steps identifier
DanShort12 Sep 28, 2020
ada610a
Add missing run identifier
DanShort12 Sep 28, 2020
a8109aa
Action not finding artifact after download
DanShort12 Sep 28, 2020
4feb6f3
GitHub doesn't have 3.9 installed
DanShort12 Sep 28, 2020
b943a17
Add some log messages when creating version
DanShort12 Sep 28, 2020
a76d50c
Get full repo history so we know number of commits
DanShort12 Sep 28, 2020
5169061
Use post as the version extension
DanShort12 Sep 28, 2020
f01ed23
Verbose twine output
DanShort12 Sep 28, 2020
eb070b6
Run workflow when a release is created
DanShort12 Sep 30, 2020
952ff27
Don't reinstall twine
DanShort12 Sep 30, 2020
acaff6e
Check TestPyPI and PyPI versions
DanShort12 Sep 30, 2020
8a21eb9
Use same account for PyPI and TestPyPI
DanShort12 Sep 30, 2020
e866b3e
trigger GitHub actions
DanShort12 Sep 30, 2020
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
84 changes: 72 additions & 12 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,101 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- created

jobs:
build_and_test:
build:

runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
fetch-depth: 0 # Get the repo history so we can version by number of commits
- name: Install OpenMC
run: |
sudo apt-get install -y g++ cmake libhdf5-dev
yum install -y gcc-c++ cmake3 hdf5-devel
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake
git clone --recurse-submodules https://github.com/openmc-dev/openmc.git
cd openmc
git checkout
mkdir build && cd build
cmake ..
make
sudo make install
- name: Install plasma source
make install
- name: Build plasma source
run: |
pip install -r requirements-develop.txt
export PYVER=${{ matrix.python-version }}
alias python=$(ls -d /opt/python/* | grep ${PYVER//.})/bin/python
python -m pip install -r requirements-develop.txt
python -m pip install auditwheel
python setup.py bdist_wheel
python -m pip install --verbose dist/*.whl
- name: Run tests
run: |
pytest tests
python -m auditwheel show dist/*.whl
python -m auditwheel repair dist/*.whl
- name: Upload wheel artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: wheelhouse

test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Download build
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Install plasma source
run: |
python -m pip install --no-index --find-links=file:dist parametric-plasma-source
- name: Run tests
run: |
python -m pip install -r requirements-develop.txt
cd tests
python -m pytest

publish:
runs-on: ubuntu-latest
needs: test

steps:
- name: Download build
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Publish wheel artifact to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m pip install twine
python3 -m twine upload --repository testpypi dist/* --verbose
- name: Release wheel artifact to PyPI
if: startsWith(github.ref, 'refs/tags')
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m twine upload dist/* --verbose
1 change: 1 addition & 0 deletions requirements-develop.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
black
flake8
pytest
requests
wheel
70 changes: 69 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import os
import requests
import subprocess
import sys

Expand Down Expand Up @@ -58,12 +60,78 @@ def build_extension(self, ext):
)


def get_version(release_override="0.0.1"):
def get_last_version_root(last_version):
if ".post" in last_version or ".dev" in last_version:
last_version_root = ".".join(last_version.split(".")[:-1])
else:
last_version_root = last_version
return last_version_root

cwd = os.path.dirname(os.path.realpath(__file__))
git_version = subprocess.check_output(
["git", "describe", "--always", "--tags"], stderr=None, cwd=cwd
).strip().decode("utf-8")

if "." not in git_version:
# Git doesn't know about a tag yet, so set the version root to release_override
version_root = release_override
else:
version_root = git_version.split("-")[0]

if "." not in git_version or "-" in git_version:
# This commit doesn't correspond to a tag, so mark it as post or dev
response = requests.get(
"https://test.pypi.org/pypi/parametric-plasma-source/json"
)
if response.status_code == 200:
# Response from TestPyPI was successful - get latest version and increment
last_version = json.loads(response.content)["info"]["version"]
last_version_root = get_last_version_root(last_version)

if last_version_root == version_root:
# We're still on the same released version, so increment the 'post'
post_count = 1
if "post" in last_version:
post_index = last_version.rfind("post") + 4
post_count = int(last_version[post_index:])
post_count += 1
version = version_root + ".post" + str(post_count)
else:
response = requests.get(
"https://pypi.org/pypi/parametric-plasma-source/json"
)
dev_count = 1
if response.status_code == 200:
# Response from PyPI was successful - get dev version and increment
last_version = json.loads(response.content)["info"]["version"]
last_version_root = get_last_version_root(last_version)

if last_version_root == version_root:
if "dev" in last_version:
dev_index = last_version.rfind("dev") + 3
dev_count = int(last_version[dev_index:])
dev_count += 1
version = version_root + ".dev" + str(dev_count)
else:
# Bad response from TestPyPI, so use git commits (requires git history)
# NOTE: May cause version clashes on mutliple branches - use test.pypi
# to avoid this.
num_commits = subprocess.check_output(
["git", "rev-list", "--count", "HEAD"], stderr=None, cwd=cwd
).strip().decode("utf-8")
version = release_override + ".post" + num_commits
else:
version = version_root
return version


with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name="parametric_plasma_source",
version="0.0.6",
version=get_version("0.0.6"),
author="Andrew Davis",
author_email="[email protected]",
description="Parametric plasma source for fusion simulations in OpenMC",
Expand Down