Skip to content

Commit

Permalink
Merge a122a51 into 2e451d2
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber authored Nov 22, 2021
2 parents 2e451d2 + a122a51 commit be54e5a
Show file tree
Hide file tree
Showing 21 changed files with 884 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ jobs:
architecture: x64
- name: Install Python dependencies
run: |
python -m pip install -U pip 'setuptools>=47.0.0,<48'
python -m pip install -U pip 'setuptools>=43.0.0'
python -m pip install scons pypiwin32 numpy ruamel.yaml cython h5py pandas pytest pytest-github-actions-annotate-failures
- name: Restore Boost cache
uses: actions/cache@v2
Expand Down
234 changes: 234 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
name: Build Python Package

on:
push:
branches:
- add-pypi-package

env:
CIBW_BUILD_FRONTEND: build
CIBW_BUILD_VERBOSITY: 3

jobs:
sdist:
name: Build the sdist
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install libboost-dev
- uses: actions/checkout@v2
name: Checkout the repository
with:
submodules: recursive
- name: Set Up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Update pip
run: python3 -m pip install -U pip setuptools
- name: Install dependencies
run: python3 -m pip install scons build
- name: Build the interface
run: python3 `which scons` sdist f90_interface=n python_package='none'
- name: Archive the built sdist
uses: actions/upload-artifact@v2
with:
path: ./build/python_sdist/dist/*.tar.gz
name: sdist
if-no-files-found: error

manylinux-wheel:
name: Build ${{ matrix.arch }} Manylinux Wheels for py${{ matrix.py }}
runs-on: ubuntu-20.04
needs: ["sdist"]
strategy:
matrix:
py: ["36", "37", "38", "39", "310"]
arch: ["x86_64", "i686", "aarch64", "ppc64le", "s390x"]
fail-fast: true
env:
BOOST_INCLUDE: ${{ github.workspace }}/include
BOOST_URL: https://pilotfiber.dl.sourceforge.net/project/boost/boost/1.75.0/boost_1_75_0.7z
steps:
- name: Download pre-built sdist
uses: actions/download-artifact@v2
with:
name: sdist
- name: Extract the sdist tarball
run: tar -xvf *.tar.gz --strip-components=1
- name: Restore Boost cache
uses: actions/cache@v2
id: cache-boost
with:
path: ${{env.BOOST_INCLUDE}}
key: boost-${{env.BOOST_URL}}
- name: Install Boost Headers
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
mkdir -p $BOOST_INCLUDE
curl --progress-bar --location --output $BOOST_INCLUDE/download.7z $BOOST_URL
7z -o$BOOST_INCLUDE x $BOOST_INCLUDE/download.7z -y -bd boost_1_75_0/boost
mv $BOOST_INCLUDE/boost_1_75_0/boost $BOOST_INCLUDE/boost
rm $BOOST_INCLUDE/download.7z
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_BUILD: cp${{ matrix.py }}-*
CIBW_ARCHS: ${{ matrix.arch }}

- name: Archive the built wheels
uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
name: wheels

windows-wheel:
name: Build ${{ matrix.arch }} Windows Wheels for py${{ matrix.py }}
runs-on: windows-2019
needs: ["sdist"]
strategy:
matrix:
py: ["36", "37", "38", "39", "310"]
arch: ["AMD64", "x86"]
fail-fast: true
env:
BOOST_ROOT: ${{ github.workspace }}/3rdparty/boost
BOOST_URL: https://pilotfiber.dl.sourceforge.net/project/boost/boost/1.75.0/boost_1_75_0.7z
steps:
- name: Download pre-built sdist
uses: actions/download-artifact@v2
with:
name: sdist
- name: Extract the sdist tarball
run: tar -xvf *.tar.gz --strip-components=1
shell: bash
- name: Restore Boost cache
uses: actions/cache@v2
id: cache-boost
with:
path: ${{env.BOOST_ROOT}}
key: boost-${{env.BOOST_URL}}
- name: Install Boost Headers
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
BOOST_ROOT=$(echo $BOOST_ROOT | sed 's/\\/\//g')
mkdir -p $BOOST_ROOT
curl --progress-bar --location --output $BOOST_ROOT/download.7z $BOOST_URL
7z -o$BOOST_ROOT x $BOOST_ROOT/download.7z -y -bd boost_1_75_0/boost
mv $BOOST_ROOT/boost_1_75_0/boost $BOOST_ROOT/boost
rm $BOOST_ROOT/download.7z
shell: bash
- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_ENVIRONMENT: "BOOST_INCLUDE=${BOOST_ROOT}"
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: cp${{ matrix.py }}-*
CIBW_SKIP: cp35-*
- name: Archive the built wheels
uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
name: wheels

macos-intel-wheel:
name: Build Intel macOS Wheels for py${{ matrix.py }}
runs-on: macos-10.15
needs: ["sdist"]
env:
MACOSX_DEPLOYMENT_TARGET: 10.9
strategy:
matrix:
py: ["36", "37", "38", "39", "310"]
fail-fast: true
steps:
- name: Download pre-built sdist
uses: actions/download-artifact@v2
with:
name: sdist
- name: Extract the sdist tarball
run: tar -xvf *.tar.gz --strip-components=1
- name: Install Brew dependencies
run: brew install boost
- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_BUILD: cp${{ matrix.py }}-*
CIBW_SKIP: cp35-*
CIBW_ARCHS: "x86_64"

- name: Archive the built wheels
uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
name: wheels

macos-arm-wheel:
name: Build arm64 macOS Wheels for py${{ matrix.py }}
runs-on: macos-10.15
needs: ["sdist"]
strategy:
matrix:
py: ["38", "39", "310"]
fail-fast: true
env:
SDKROOT: "macosx11.0"
_PYTHON_HOST_PLATFORM: "macosx-11.0-arm64"
ARCHFLAGS: "-arch arm64"
MACOSX_DEPLOYMENT_TARGET: "10.9"
DEVELOPER_DIR: "/Applications/Xcode_12.2.app/Contents/Developer"
steps:
- name: Download pre-built sdist
uses: actions/download-artifact@v2
with:
name: sdist
- name: Extract the sdist tarball
run: tar -xvf *.tar.gz --strip-components=1
- name: Install Brew dependencies
run: brew install boost
- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_ENVIRONMENT: 'BOOST_INCLUDE="$(brew --prefix)/include"'
CIBW_ARCHS: "arm64"
CIBW_BUILD: cp${{ matrix.py }}-*
- name: Archive the built wheels
uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
name: wheels

publish-files-to-pypi:
name: Publish distribution files to PyPI
runs-on: ubuntu-20.04
needs:
- "sdist"
- "manylinux-wheel"
- "windows-wheel"
- "macos-intel-wheel"
- "macos-arm-wheel"
steps:
- name: Download pre-built wheels
uses: actions/download-artifact@v2
with:
path: dist/
name: wheels
- name: Download pre-build sdist
uses: actions/download-artifact@v2
with:
path: dist/
name: sdist
- name: pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# Ignore existing packages as long as we're uploading to TestPyPI
skip_existing: true
29 changes: 21 additions & 8 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ if os.name not in ["nt", "posix"]:
sys.exit(1)

valid_commands = ("build", "clean", "install", "uninstall",
"help", "msi", "samples", "sphinx", "doxygen", "dump")
"help", "msi", "samples", "sphinx", "doxygen", "dump",
"sdist")

for command in COMMAND_LINE_TARGETS:
if command not in valid_commands and not command.startswith('test'):
Expand All @@ -106,8 +107,12 @@ if "clean" in COMMAND_LINE_TARGETS:
remove_directory("include/cantera/ext")
remove_file("interfaces/cython/cantera/_cantera.cpp")
remove_file("interfaces/cython/cantera/_cantera.h")
remove_file("interfaces/cython/setup.py")
remove_file("interfaces/python_minimal/setup.py")
remove_file("interfaces/cython/setup.cfg")
remove_file("interfaces/cython/LICENSE.txt")
remove_file("interfaces/cython/README.rst")
remove_file("interfaces/python_minimal/setup.cfg")
remove_file("interfaces/python_minimal/LICENSE.txt")
remove_file("interfaces/python_minimal/README.rst")
remove_file("config.log")
remove_directory("doc/sphinx/matlab/examples")
remove_file("doc/sphinx/matlab/examples.rst")
Expand Down Expand Up @@ -239,6 +244,10 @@ config_options = [
Cython) are installed. Note: 'y' is a synonym for 'full' and 'n'
is a synonym for 'none'.""",
"default", ("full", "minimal", "none", "n", "y", "default")),
BoolOption(
"python_sdist",
"""Setting this option to True builds the Python sdist.""",
False),
PathOption(
"python_cmd",
"""Cantera needs to know where to find the Python interpreter. If
Expand Down Expand Up @@ -817,6 +826,8 @@ if 'doxygen' in COMMAND_LINE_TARGETS:
env['doxygen_docs'] = True
if 'sphinx' in COMMAND_LINE_TARGETS:
env['sphinx_docs'] = True
if "sdist" in COMMAND_LINE_TARGETS:
env["python_sdist"] = True

for arg in ARGUMENTS:
if arg not in config:
Expand Down Expand Up @@ -1349,7 +1360,7 @@ if env['VERBOSE']:
env['python_cmd_esc'] = quoted(env['python_cmd'])

# Python Package Settings
python_min_version = parse_version('3.5')
python_min_version = parse_version("3.6")
# The string is used to set python_requires in setup.py.in
env['py_min_ver_str'] = str(python_min_version)
# Note: cython_min_version is redefined below if the Python version is 3.8 or higher
Expand Down Expand Up @@ -1868,6 +1879,10 @@ if env['matlab_toolbox'] == 'y':
if env['doxygen_docs'] or env['sphinx_docs']:
SConscript('doc/SConscript')

if env["python_sdist"]:
VariantDir("build/python_sdist", "interfaces/python_sdist", duplicate=1)
SConscript("interfaces/python_sdist/SConscript", variant_dir="build/python_sdist")

# Sample programs (also used from test_problems/SConscript)
VariantDir('build/samples', 'samples', duplicate=0)
sampledir_excludes = ['\\.o$', '^~$', '\\.in', 'SConscript']
Expand Down Expand Up @@ -1896,12 +1911,10 @@ def postBuildMessage(target, source, env):
print("- To run the test suite, type 'scons test'.")
print("- To list available tests, type 'scons test-help'.")
if env['googletest'] == 'none':
print(" WARNING: You set the 'googletest' to 'none' and all it's tests will be skipped.")
print(" WARNING: You set the 'googletest' to 'none' and all its tests will be skipped.")
print("- To install, type 'scons install'.")
if os.name == 'nt':
print("- To install, type 'scons install'.")
print("- To create a Windows MSI installer, type 'scons msi'.")
else:
print("- To install, type 'scons install'.")
print("*******************************************************")

finish_build = env.Command('finish_build', [], postBuildMessage)
Expand Down
Loading

0 comments on commit be54e5a

Please sign in to comment.