Unverified Commit 0d3a99c8 authored by Simon Ward's avatar Simon Ward
Browse files

Merge branch 'CFML_build_updates' into feature-python_api-build_wheels

parents b829e2a1 59e1503b
Pipeline #10461 failed with stages
in 6 minutes and 28 seconds
# Adapted from https://github.com/RalfG/python-wheels-manylinux-build/blob/master/full_workflow_example.yml name: Python libs
name: Build CFML wheels on various systems
on: on:
push: push:
branches: [ simon ] branches: [ master ]
pull_request:
branches: [ master ]
# schedule:
# # Every day at 1am
# - cron: '0 1 * * *'
jobs: jobs:
get_Latest:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout ILL repo
run: |
git clone https://code.ill.fr/scientific-software/crysfml/ ./
git checkout feature-python_api-build_wheels
rm -rf ./.git ./Html
- uses: actions/upload-artifact@v2
with:
name: CrysFML_SRC
path: ${{ github.workspace }}
retention-days: 1
create-Linux: create-Linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: get_Latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/download-artifact@v2
with:
name: CrysFML_SRC
- name: Build manylinux wheels - name: Build manylinux wheels
run: docker run -e PLAT=manylinux2010_x86_64 -v `pwd`:/io quay.io/pypa/manylinux2010_x86_64 /io/Scripts/buildscript.sh run: |
chmod +x ./Scripts/buildscript.sh
docker run -e PLAT=manylinux2010_x86_64 -v ${{ github.workspace }}:/io quay.io/pypa/manylinux2010_x86_64 /io/Scripts/buildscript.sh
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: CrysFML - Linux name: CrysFML - Linux
...@@ -24,19 +51,18 @@ jobs: ...@@ -24,19 +51,18 @@ jobs:
strategy: strategy:
max-parallel: 4 max-parallel: 4
matrix: matrix:
python-version: ['3.6', '3.7', '3.8', '3.9'] python-version: ['3.8']
os: [macos-10.15] os: [macos-10.15]
gcc_v: [ 10 ] # Version of GFortran we want to use. gcc_v: [ 10 ] # Version of GFortran we want to use.
# exclude: # Currently only python > 3.8 is supported on macos-11.0 and > 3.6 on macos-10.15
# - os: macos-11.0
# python-version: '3.7'
# - os: macos-11.0
# python-version: '3.8'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: get_Latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/download-artifact@v2
with:
name: CrysFML_SRC
- name: Setup python - name: Setup python
uses: actions/setup-python@v1 uses: actions/setup-python@v1
...@@ -53,31 +79,27 @@ jobs: ...@@ -53,31 +79,27 @@ jobs:
run: | run: |
pip3 wheel ./ --no-deps -w ./old/ pip3 wheel ./ --no-deps -w ./old/
delocate-wheel -w dist -v ./old/*.whl delocate-wheel -w dist -v ./old/*.whl
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: CrysFML - ${{ matrix.os }} - Python ${{ matrix.python-version }} name: CrysFML - MacOS
path: ./dist/*.whl path: ./dist/*.whl
create-Windows: create-Windows:
strategy: strategy:
max-parallel: 4 max-parallel: 1
matrix: matrix:
python-version: [ '3.6', '3.7'] python-version: [ '3.6', '3.7']
os: [ windows-latest ] os: [ windows-latest ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup python - uses: conda-incubator/setup-miniconda@v2
uses: actions/setup-python@v1
with: with:
python-version: ${{matrix.python-version}} auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install wheel auto-activate-base: true
run: pip install wheel
- uses: msys2/setup-msys2@v2 - uses: msys2/setup-msys2@v2
with: with:
...@@ -89,31 +111,31 @@ jobs: ...@@ -89,31 +111,31 @@ jobs:
- name: Build CFML - name: Build CFML
shell: msys2 {0} shell: msys2 {0}
id: build id: build
run: pip wheel ./ --no-deps -w ./dist/ run: python setup.py bdist_wheel
env: env:
MINGW_ARCH: MINGW64 MINGW_ARCH: MINGW64
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: CrysFML - ${{ matrix.os }} - Python ${{ matrix.python-version }} name: CrysFML - Windows
path: ./dist/*.whl path: ./dist/*.whl
Upload_Artifacts: Upload_Artifacts:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [create-Linux, create-OSX, create-Windows] needs: [create-Linux, create-OSX]
steps: steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v2
- name: What is downloaded
run: |
ls -al
- name: Upload Artifacts GitHub releases - name: Upload Artifacts GitHub releases
# if: github.event_name == 'push'
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
draft: falase draft: false
prerelease: true prerelease: true
allowUpdates: true allowUpdates: true
replacesArtifacts: true replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "./dist/*.whl" artifacts: "./**/*.whl"
tag: ${{ env.BRANCH_NAME }} tag: "CurrentBuild"
commit: ${{ env.BRANCH_NAME }} body: "This is a build of the CFML libraries."
bodyFile: "RELEASE.md"
...@@ -17,11 +17,11 @@ function repair_wheel { ...@@ -17,11 +17,11 @@ function repair_wheel {
# Compile wheels # Compile wheels
for PYBIN in /opt/python/*/bin; do #for PYBIN in /opt/python/*/bin; do
# "${PYBIN}/pip" install -r /io/dev-requirements.txt export PYBIN=/opt/python/cp38-cp38/bin
"${PYBIN}/pip" wheel /io/ --no-deps --use-feature=in-tree-build -w /io/dist/ "${PYBIN}/pip" wheel /io/ --no-deps --use-feature=in-tree-build -w /io/dist/
rm -rf /io/build/ rm -rf /io/build/
done #done
# Bundle external shared libraries into the wheels # Bundle external shared libraries into the wheels
for whl in /io/dist/*.whl; do for whl in /io/dist/*.whl; do
...@@ -29,7 +29,6 @@ for whl in /io/dist/*.whl; do ...@@ -29,7 +29,6 @@ for whl in /io/dist/*.whl; do
done done
# Install packages and test # Install packages and test
for PYBIN in /opt/python/*/bin/; do #for PYBIN in /opt/python/*/bin/; do
"${PYBIN}/pip" install CFML --no-index -f /io/dist "${PYBIN}/pip" install CFML --no-index -f /io/dist
# (cd "$HOME"; "${PYBIN}/nosetests" pymanylinuxdemo) #done
done \ No newline at end of file
\ No newline at end of file
import os import os
import pathlib import pathlib
import pkgutil import pkgutil
...@@ -7,6 +8,7 @@ import sys ...@@ -7,6 +8,7 @@ import sys
import setuptools import setuptools
import distutils.sysconfig as sysconfig import distutils.sysconfig as sysconfig
from distutils.core import setup from distutils.core import setup
import distutils.command.build
from distutils.command.install_data import install_data from distutils.command.install_data import install_data
from subprocess import CalledProcessError, check_output, check_call from subprocess import CalledProcessError, check_output, check_call
...@@ -15,6 +17,23 @@ from setuptools.command.build_ext import build_ext ...@@ -15,6 +17,23 @@ from setuptools.command.build_ext import build_ext
from setuptools.command.install_lib import install_lib from setuptools.command.install_lib import install_lib
from setuptools.command.install_scripts import install_scripts from setuptools.command.install_scripts import install_scripts
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
# this overrides standard naming of the wheel to not include
# architecture or python dot version number
class Bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False
def get_tag(self):
python, abi, plat = _bdist_wheel.get_tag(self)
python, abi = 'py3', 'none'
return python, abi, plat
except ImportError:
Bdist_wheel = None
BITS = struct.calcsize("P") * 8 BITS = struct.calcsize("P") * 8
PACKAGE_NAME = "crysfml_api" PACKAGE_NAME = "crysfml_api"
SOURCE_DIR = '.' SOURCE_DIR = '.'
...@@ -42,7 +61,6 @@ def get_cmake(): ...@@ -42,7 +61,6 @@ def get_cmake():
class CMakeExtension(Extension): class CMakeExtension(Extension):
""" """
An extension to run the cmake build An extension to run the cmake build
This simply overrides the base extension class so that setuptools This simply overrides the base extension class so that setuptools
doesn't try to build your sources for you doesn't try to build your sources for you
""" """
...@@ -54,7 +72,6 @@ class CMakeExtension(Extension): ...@@ -54,7 +72,6 @@ class CMakeExtension(Extension):
class InstallCMakeLibsData(install_data): class InstallCMakeLibsData(install_data):
""" """
Just a wrapper to get the install data into the egg-info Just a wrapper to get the install data into the egg-info
Listing the installed files in the egg-info guarantees that Listing the installed files in the egg-info guarantees that
all of the package files will be uninstalled when the user all of the package files will be uninstalled when the user
uninstalls your package through pip uninstalls your package through pip
...@@ -72,10 +89,10 @@ class InstallCMakeLibsData(install_data): ...@@ -72,10 +89,10 @@ class InstallCMakeLibsData(install_data):
self.outfiles = self.distribution.data_files self.outfiles = self.distribution.data_files
class InstallCMakeLibs(install_lib): class InstallCMakeLibs(install_lib):
""" """
Get the libraries from the parent distribution, use those as the outfiles Get the libraries from the parent distribution, use those as the outfiles
Skip building anything; everything is already built, forward libraries to Skip building anything; everything is already built, forward libraries to
the installation step the installation step
""" """
...@@ -141,6 +158,8 @@ class InstallCMakeLibs(install_lib): ...@@ -141,6 +158,8 @@ class InstallCMakeLibs(install_lib):
super().run() super().run()
pass
class InstallCMakeScripts(install_scripts): class InstallCMakeScripts(install_scripts):
""" """
...@@ -192,7 +211,8 @@ class BuildCMakeExt(build_ext): ...@@ -192,7 +211,8 @@ class BuildCMakeExt(build_ext):
for extension in self.extensions: for extension in self.extensions:
self.build_cmake(extension) self.build_cmake(extension)
super().run() # super().run()
pass
def build_cmake(self, extension: Extension): def build_cmake(self, extension: Extension):
""" """
...@@ -203,10 +223,17 @@ class BuildCMakeExt(build_ext): ...@@ -203,10 +223,17 @@ class BuildCMakeExt(build_ext):
build_dir = pathlib.Path(self.build_temp) build_dir = pathlib.Path(self.build_temp)
extension_path = pathlib.Path(self.get_ext_fullpath(extension.name)) # don't store the abi3 info in filename
extension._file_name = extension._full_name
ext_path = pathlib.Path(self.get_ext_fullpath(extension.name))
ext_ext = os.path.splitext(ext_path)[1]
filename = extension._file_name + ext_ext
extension_path = os.path.join(ext_path.parent, filename)
os.makedirs(build_dir, exist_ok=True) os.makedirs(build_dir, exist_ok=True)
os.makedirs(extension_path.parent.absolute(), exist_ok=True) os.makedirs(ext_path.parent.absolute(), exist_ok=True)
# Now that the necessary directories are created, build # Now that the necessary directories are created, build
...@@ -264,6 +291,16 @@ class BuildCMakeExt(build_ext): ...@@ -264,6 +291,16 @@ class BuildCMakeExt(build_ext):
# different place. See comments above for additional information # different place. See comments above for additional information
class BuildCommand(distutils.command.build.build):
def initialize_options(self):
# this overrides the directory names for
# build/lib and build/temp
distutils.command.build.build.initialize_options(self)
self.build_platlib = 'build/lib'
self.build_temp = 'build/temp'
setup(name="CFML", setup(name="CFML",
version="0.0.1", version="0.0.1",
author="Simon Ward", author="Simon Ward",
...@@ -281,11 +318,14 @@ setup(name="CFML", ...@@ -281,11 +318,14 @@ setup(name="CFML",
"Programming Language :: Fortran", "Programming Language :: Fortran",
"Programming Language :: Python"], "Programming Language :: Python"],
license='LGPL', license='LGPL',
cpython_tags=None,
cmdclass={ cmdclass={
'build': BuildCommand,
'build_ext': BuildCMakeExt, 'build_ext': BuildCMakeExt,
'install_data': InstallCMakeLibsData, 'install_data': InstallCMakeLibsData,
'install_lib': InstallCMakeLibs, 'install_lib': InstallCMakeLibs,
'install_scripts': InstallCMakeScripts 'install_scripts': InstallCMakeScripts,
'bdist_wheel': Bdist_wheel
}, },
setup_requires=['wheel'] setup_requires=['wheel']
) )
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment