Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
CrysFML
Commits
e453159f
Unverified
Commit
e453159f
authored
Jul 19, 2021
by
Simon Ward
Browse files
Make platform independent [ci skip]
parent
757e93f9
Changes
3
Show whitespace changes
Inline
Side-by-side
.github/workflows/build_variants.yml
View file @
e453159f
# Adapted from https://github.com/RalfG/python-wheels-manylinux-build/blob/master/full_workflow_example.yml
name
:
Build CFML wheels on various systems
name
:
Python libs
on
:
push
:
branches
:
[
simon
]
branches
:
[
master
]
pull_request
:
branches
:
[
master
]
# schedule:
# # Every day at 1am
# - cron: '0 1 * * *'
jobs
:
# create-Linux:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v2
#
# - 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
#
# - uses: actions/upload-artifact@v2
# with:
# name: CrysFML - Linux
# path: ${{ github.workspace }}/dist/*.whl
#
# create-OSX:
# strategy:
# max-parallel: 4
# matrix:
# python-version: ['3.6', '3.7', '3.8', '3.9']
# os: [macos-10.15]
# 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 }}
#
# steps:
# - uses: actions/checkout@v2
#
# - name: Setup python
# uses: actions/setup-python@v1
# with:
# python-version: ${{matrix.python-version}}
#
# - name: Install cmake
# run: pip3 install cmake delocate wheel
#
# - name: Build CFML (OSX)
# env:
# FC: gfortran-${{ matrix.gcc_v }}
# CC: gcc-${{ matrix.gcc_v }}
# run: |
# pip3 wheel ./ --no-deps -w ./old/
# delocate-wheel -w dist -v ./old/*.whl
#
# - uses: actions/upload-artifact@v2
# with:
# name: CrysFML - ${{ matrix.os }} - Python ${{ matrix.python-version }}
# path: ./dist/*.whl
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
:
runs-on
:
ubuntu-latest
needs
:
get_Latest
steps
:
-
uses
:
actions/download-artifact@v2
with
:
name
:
CrysFML_SRC
-
name
:
Build manylinux wheels
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
with
:
name
:
CrysFML - Linux
path
:
${{ github.workspace }}/dist/*.whl
create-OSX
:
strategy
:
max-parallel
:
4
matrix
:
python-version
:
[
'
3.8'
]
os
:
[
macos-10.15
]
gcc_v
:
[
10
]
# Version of GFortran we want to use.
runs-on
:
${{ matrix.os }}
needs
:
get_Latest
steps
:
-
uses
:
actions/download-artifact@v2
with
:
name
:
CrysFML_SRC
-
name
:
Setup python
uses
:
actions/setup-python@v1
with
:
python-version
:
${{matrix.python-version}}
-
name
:
Install cmake
run
:
pip3 install cmake delocate wheel
-
name
:
Build CFML (OSX)
env
:
FC
:
gfortran-${{ matrix.gcc_v }}
CC
:
gcc-${{ matrix.gcc_v }}
run
:
|
pip3 wheel ./ --no-deps -w ./old/
delocate-wheel -w dist -v ./old/*.whl
-
uses
:
actions/upload-artifact@v2
with
:
name
:
CrysFML - MacOS
path
:
./dist/*.whl
create-Windows
:
strategy
:
...
...
@@ -92,25 +117,25 @@ jobs:
-
uses
:
actions/upload-artifact@v2
with
:
name
:
CrysFML -
${{ matrix.os }} - Python ${{ matrix.python-version }}
name
:
CrysFML -
Windows
path
:
./dist/*.whl
#
Upload_Artifacts:
#
runs-on: ubuntu-latest
#
needs: [create-Linux, create-OSX
, create-Windows
]
#
steps:
#
- uses: actions/
checkou
t@v2
#
-
uses: actions/download-artifact@v2
#
- name: Upload Artifacts GitHub releases
##
if: github.event_name == 'push'
#
uses: ncipollo/release-action@v1
#
with:
#
draft: falase
#
prerelease: tru
e
#
allowUpdates
: true
#
replacesArtifact
s: true
#
token: ${{ secrets.GITHUB_TOKEN }}
#
artifacts: "./dist/*.whl"
##
tag: ${{ env.BRANCH_NAME }}
##
commit: ${{ env.BRANCH_NAME }}
#
body
File: "RELEASE.md
"
Upload_Artifacts
:
runs-on
:
ubuntu-latest
needs
:
[
create-Linux
,
create-OSX
]
steps
:
-
uses
:
actions/
download-artifac
t@v2
-
name
:
What is downloaded
run
:
|
ls -al
-
name
:
Upload Artifacts GitHub releases
uses
:
ncipollo/release-action@v1
with
:
draft
:
fals
e
prerelease
:
true
allowUpdate
s
:
true
replacesArtifacts
:
true
token
:
${{ secrets.GITHUB_TOKEN }}
artifacts
:
"
./**/*.whl"
tag
:
"
CurrentBuild"
body
:
"
This
is
a
build
of
the
CFML
libraries.
"
Scripts/buildscript.sh
View file @
e453159f
...
...
@@ -17,11 +17,11 @@ function repair_wheel {
# Compile wheels
for
PYBIN
in
/opt/python/
*
/bin
;
do
# "${PYBIN}/pip" install -r /io/dev-requirements.txt
"
${
PYBIN
}
/pip"
wheel /io/
--no-deps
--use-feature
=
in
-tree-build
-w
/io/dist/
rm
-rf
/io/build/
done
#
for PYBIN in /opt/python/*/bin; do
export
PYBIN
=
/opt/python/cp38-cp38/bin
"
${
PYBIN
}
/pip"
wheel /io/
--no-deps
--use-feature
=
in
-tree-build
-w
/io/dist/
rm
-rf
/io/build/
#
done
# Bundle external shared libraries into the wheels
for
whl
in
/io/dist/
*
.whl
;
do
...
...
@@ -29,7 +29,6 @@ for whl in /io/dist/*.whl; do
done
# Install packages and test
for
PYBIN
in
/opt/python/
*
/bin/
;
do
"
${
PYBIN
}
/pip"
install
CFML
--no-index
-f
/io/dist
# (cd "$HOME"; "${PYBIN}/nosetests" pymanylinuxdemo)
done
\ No newline at end of file
#for PYBIN in /opt/python/*/bin/; do
"
${
PYBIN
}
/pip"
install
CFML
--no-index
-f
/io/dist
#done
\ No newline at end of file
setup.py
View file @
e453159f
import
os
import
pathlib
import
pkgutil
...
...
@@ -7,6 +8,7 @@ import sys
import
setuptools
import
distutils.sysconfig
as
sysconfig
from
distutils.core
import
setup
import
distutils.command.build
from
distutils.command.install_data
import
install_data
from
subprocess
import
CalledProcessError
,
check_output
,
check_call
...
...
@@ -15,6 +17,23 @@ from setuptools.command.build_ext import build_ext
from
setuptools.command.install_lib
import
install_lib
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
PACKAGE_NAME
=
"crysfml_api"
SOURCE_DIR
=
'.'
...
...
@@ -42,7 +61,6 @@ def get_cmake():
class
CMakeExtension
(
Extension
):
"""
An extension to run the cmake build
This simply overrides the base extension class so that setuptools
doesn't try to build your sources for you
"""
...
...
@@ -54,7 +72,6 @@ class CMakeExtension(Extension):
class
InstallCMakeLibsData
(
install_data
):
"""
Just a wrapper to get the install data into the egg-info
Listing the installed files in the egg-info guarantees that
all of the package files will be uninstalled when the user
uninstalls your package through pip
...
...
@@ -72,10 +89,10 @@ class InstallCMakeLibsData(install_data):
self
.
outfiles
=
self
.
distribution
.
data_files
class
InstallCMakeLibs
(
install_lib
):
"""
Get the libraries from the parent distribution, use those as the outfiles
Skip building anything; everything is already built, forward libraries to
the installation step
"""
...
...
@@ -141,6 +158,8 @@ class InstallCMakeLibs(install_lib):
super
().
run
()
pass
class
InstallCMakeScripts
(
install_scripts
):
"""
...
...
@@ -192,7 +211,8 @@ class BuildCMakeExt(build_ext):
for
extension
in
self
.
extensions
:
self
.
build_cmake
(
extension
)
super
().
run
()
# super().run()
pass
def
build_cmake
(
self
,
extension
:
Extension
):
"""
...
...
@@ -203,10 +223,17 @@ class BuildCMakeExt(build_ext):
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
(
ext
ension
_path
.
parent
.
absolute
(),
exist_ok
=
True
)
os
.
makedirs
(
ext_path
.
parent
.
absolute
(),
exist_ok
=
True
)
# Now that the necessary directories are created, build
...
...
@@ -264,6 +291,16 @@ class BuildCMakeExt(build_ext):
# 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"
,
version
=
"0.0.1"
,
author
=
"Simon Ward"
,
...
...
@@ -281,11 +318,14 @@ setup(name="CFML",
"Programming Language :: Fortran"
,
"Programming Language :: Python"
],
license
=
'LGPL'
,
cpython_tags
=
None
,
cmdclass
=
{
'build'
:
BuildCommand
,
'build_ext'
:
BuildCMakeExt
,
'install_data'
:
InstallCMakeLibsData
,
'install_lib'
:
InstallCMakeLibs
,
'install_scripts'
:
InstallCMakeScripts
'install_scripts'
:
InstallCMakeScripts
,
'bdist_wheel'
:
Bdist_wheel
},
setup_requires
=
[
'wheel'
]
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment