Unverified Commit 99ef74c1 authored by Simon Ward's avatar Simon Ward
Browse files

Code cleanup & WIN only test

parent b2ff7ae3
...@@ -6,60 +6,60 @@ on: ...@@ -6,60 +6,60 @@ on:
branches: [ simon ] branches: [ simon ]
jobs: jobs:
create-Linux: # create-Linux:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- uses: actions/checkout@v2 # - uses: actions/checkout@v2
#
- 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/buildscript.sh # run: docker run -e PLAT=manylinux2010_x86_64 -v `pwd`:/io quay.io/pypa/manylinux2010_x86_64 /io/buildscript.sh
#
- uses: actions/upload-artifact@v2 # - uses: actions/upload-artifact@v2
with: # with:
name: CrysFML - Linux # name: CrysFML - Linux
path: ${{ github.workspace }}/dist/*.whl # path: ${{ github.workspace }}/dist/*.whl
#
create-OSX: # create-OSX:
strategy: # strategy:
max-parallel: 4 # max-parallel: 4
matrix: # matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] # python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
os: [macos-10.15, macos-11.0] # os: [macos-10.15, macos-11.0]
gcc_v: [ 10 ] # Version of GFortran we want to use. # gcc_v: [ 10 ] # Version of GFortran we want to use.
exclude: # exclude:
- os: macos-10.15 # - os: macos-10.15
python-version: '3.6' # python-version: '3.6'
- os: macos-11.0 # - os: macos-11.0
python-version: '3.6' # python-version: '3.6'
- os: macos-11.0 # - os: macos-11.0
python-version: '3.7' # python-version: '3.7'
#
runs-on: ${{ matrix.os }} # runs-on: ${{ matrix.os }}
#
steps: # steps:
- uses: actions/checkout@v2 # - uses: actions/checkout@v2
#
- name: Setup python # - name: Setup python
uses: actions/setup-python@v1 # uses: actions/setup-python@v1
with: # with:
python-version: ${{matrix.python-version}} # python-version: ${{matrix.python-version}}
#
- name: Install cmake # - name: Install cmake
run: pip3 install cmake delocate wheel # run: pip3 install cmake delocate wheel
#
- name: Build CFML (OSX) # - name: Build CFML (OSX)
env: # env:
FC: gfortran-${{ matrix.gcc_v }} # FC: gfortran-${{ matrix.gcc_v }}
CC: gcc-${{ matrix.gcc_v }} # CC: gcc-${{ matrix.gcc_v }}
run: | # run: |
pip3 wheel ./ --no-deps -w ./dist/ # pip3 wheel ./ --no-deps -w ./dist/
delocate-wheel -w fixed_wheels -v ./dist/*.whl # delocate-wheel -w fixed_wheels -v ./dist/*.whl
#
- uses: actions/upload-artifact@v2 # - uses: actions/upload-artifact@v2
with: # with:
name: CrysFML - ${{ matrix.os }} - Python ${{ matrix.python-version }} # name: CrysFML - ${{ matrix.os }} - Python ${{ matrix.python-version }}
path: ./fixed_wheels/*.whl # path: ./fixed_wheels/*.whl
create-Windows: create-Windows:
strategy: strategy:
...@@ -82,7 +82,12 @@ jobs: ...@@ -82,7 +82,12 @@ jobs:
run: pip3 install cmake wheel run: pip3 install cmake wheel
- name: Install Fotran - name: Install Fotran
run: choco install mingw -y run: |
choco install mingw -y
choco install msys2 --params "/NoUpdate"
echo "::add-path::C:\\tools\\msys64\\usr\\bin"
echo "::add-path::C:\\tools\\msys64\\mingw64\\bin"
echo "::set-env name=PKG_CONFIG_PATH::/mingw64/lib/pkgconfig"
- name: Build CFML (Windows) - name: Build CFML (Windows)
run: pip3 wheel ./ --no-deps -w ./dist/ run: pip3 wheel ./ --no-deps -w ./dist/
......
...@@ -44,3 +44,5 @@ build/ ...@@ -44,3 +44,5 @@ build/
CFML.egg-info/ CFML.egg-info/
dist/ dist/
*.whl
...@@ -31,7 +31,7 @@ set_source_files_properties(forpy_mod.f90 PROPERTIES COMPILE_FLAG "-cpp") ...@@ -31,7 +31,7 @@ set_source_files_properties(forpy_mod.f90 PROPERTIES COMPILE_FLAG "-cpp")
# Add a dependency to crysfml_common to keep sure that the crysfml_common library will be built first. # Add a dependency to crysfml_common to keep sure that the crysfml_common library will be built first.
add_dependencies(${LIBRARY_NAME} crysfml_common) add_dependencies(${LIBRARY_NAME} crysfml_common)
set(COMPATIBLE_VERSIONS 3.8 3.7 3.6 3.5) set(COMPATIBLE_VERSIONS 3.10 3.9 3.8 3.7 3.6)
if (NOT PYTHON_INTERPRETER_PATH) if (NOT PYTHON_INTERPRETER_PATH)
set(Python_ADDITIONAL_VERSIONS ${COMPATIBLE_VERSIONS}) set(Python_ADDITIONAL_VERSIONS ${COMPATIBLE_VERSIONS})
find_package(PythonInterp REQUIRED) find_package(PythonInterp REQUIRED)
......
import os
import pathlib
import pkgutil
import shutil
import struct
import sys
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 setuptools import find_packages, setup, Extension from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext 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
from subprocess import CalledProcessError, check_output, check_call
import struct
import pkgutil
import pathlib
import os
import sys
import shutil
BITS = struct.calcsize("P") * 8 BITS = struct.calcsize("P") * 8
PACKAGE_NAME = "crysfml_api" PACKAGE_NAME = "crysfml_api"
...@@ -25,13 +26,16 @@ print(f'Compiler set to: {COMPILER}') ...@@ -25,13 +26,16 @@ print(f'Compiler set to: {COMPILER}')
# If cmake is a known module, import it and use it tell us its binary directory # If cmake is a known module, import it and use it tell us its binary directory
if pkgutil.find_loader('cmake') is not None: if pkgutil.find_loader('cmake') is not None:
import cmake import cmake
CMAKE_BIN = cmake.CMAKE_BIN_DIR + os.path.sep + 'cmake' CMAKE_BIN = cmake.CMAKE_BIN_DIR + os.path.sep + 'cmake'
else: else:
CMAKE_BIN = 'cmake' CMAKE_BIN = 'cmake'
def get_cmake(): def get_cmake():
return CMAKE_BIN return CMAKE_BIN
class CMakeExtension(Extension): class CMakeExtension(Extension):
""" """
An extension to run the cmake build An extension to run the cmake build
...@@ -41,8 +45,8 @@ class CMakeExtension(Extension): ...@@ -41,8 +45,8 @@ class CMakeExtension(Extension):
""" """
def __init__(self, name, sources=[]): def __init__(self, name, sources=[]):
super().__init__(name=name, sources=sources)
super().__init__(name = name, sources = sources)
class InstallCMakeLibsData(install_data): class InstallCMakeLibsData(install_data):
""" """
...@@ -55,17 +59,16 @@ class InstallCMakeLibsData(install_data): ...@@ -55,17 +59,16 @@ class InstallCMakeLibsData(install_data):
def run(self): def run(self):
""" """
Outfiles are the libraries that were built using cmake Out files are the libraries that were built using cmake
""" """
# There seems to be no other way to do this; I tried listing the # There seems to be no other way to do this; I tried listing the
# libraries during the execution of the InstallCMakeLibs.run() but # libraries during the execution of the InstallCMakeLibs.run() but
# setuptools never tracked them, seems like setuptools wants to # setuptools never tracked them, seems like setuptools wants to
# track the libraries through package data more than anything... # track the libraries through package data more than anything...
# help would be appriciated
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
...@@ -80,24 +83,20 @@ class InstallCMakeLibs(install_lib): ...@@ -80,24 +83,20 @@ class InstallCMakeLibs(install_lib):
""" """
self.announce("Moving library files", level=3) self.announce("Moving library files", level=3)
# We have already built the libraries in the previous build_ext step # We have already built the libraries in the previous build_ext step
self.skip_build = True self.skip_build = True
# bin_dir = self.distribution.bin_dir
# Depending on the files that are generated from your cmake # Depending on the files that are generated from your cmake
# build chain, you may need to change the below code, such that # build chain, you may need to change the below code, such that
# your files are moved to the appropriate location when the installation # your files are moved to the appropriate location when the installation
# is run # is run
# bin_dir = self.distribution.bin_dir
bin_dir = os.path.abspath(os.path.join(self.distribution.bin_dir, '..')) bin_dir = os.path.abspath(os.path.join(self.distribution.bin_dir, '..'))
libs = [os.path.join(bin_dir, _dir) for _dir in libs = [os.path.join(bin_dir, _dir) for _dir in
os.listdir(bin_dir) if os.listdir(bin_dir) if
os.path.isdir(os.path.join(bin_dir, _dir))] os.path.isdir(os.path.join(bin_dir, _dir))]
for lib in libs: for lib in libs:
shutil.move(lib, os.path.join(self.build_dir, shutil.move(lib, os.path.join(self.build_dir,
...@@ -139,6 +138,7 @@ class InstallCMakeLibs(install_lib): ...@@ -139,6 +138,7 @@ class InstallCMakeLibs(install_lib):
super().run() super().run()
class InstallCMakeScripts(install_scripts): class InstallCMakeScripts(install_scripts):
""" """
Install the scripts in the build dir Install the scripts in the build dir
...@@ -176,6 +176,7 @@ class InstallCMakeScripts(install_scripts): ...@@ -176,6 +176,7 @@ class InstallCMakeScripts(install_scripts):
super().run() super().run()
class BuildCMakeExt(build_ext): class BuildCMakeExt(build_ext):
""" """
Builds using cmake instead of the python setuptools implicit build Builds using cmake instead of the python setuptools implicit build
...@@ -187,7 +188,7 @@ class BuildCMakeExt(build_ext): ...@@ -187,7 +188,7 @@ 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()
def build_cmake(self, extension: Extension): def build_cmake(self, extension: Extension):
...@@ -233,9 +234,9 @@ class BuildCMakeExt(build_ext): ...@@ -233,9 +234,9 @@ class BuildCMakeExt(build_ext):
check_call( check_call(
[get_cmake(), "--build", ".", '--target', 'install'] + build_args, cwd=self.build_temp [get_cmake(), "--build", ".", '--target', 'install'] + build_args, cwd=self.build_temp
) )
# Build finished, now copy the files into the copy directory # Build finished, now copy the files into the copy directory
# The copy directory is the parent directory of the extension (.pyd) # The copy directory is the parent directory of the extension (.pyd)
self.announce("Moving built python module", level=3) self.announce("Moving built python module", level=3)
bin_dir = os.path.join(os.getcwd(), COMPILER, 'Python_API', 'CFML_api') bin_dir = os.path.join(os.getcwd(), COMPILER, 'Python_API', 'CFML_api')
...@@ -248,7 +249,6 @@ class BuildCMakeExt(build_ext): ...@@ -248,7 +249,6 @@ class BuildCMakeExt(build_ext):
os.path.splitext(_pyd)[1] in [".pyd", ".so"]][0] os.path.splitext(_pyd)[1] in [".pyd", ".so"]][0]
shutil.move(pyd_path, extension_path) shutil.move(pyd_path, extension_path)
# After build_ext is run, the following commands will run: # After build_ext is run, the following commands will run:
# #
# install_lib # install_lib
...@@ -259,27 +259,28 @@ class BuildCMakeExt(build_ext): ...@@ -259,27 +259,28 @@ class BuildCMakeExt(build_ext):
# wants to build those libs and scripts as well or move them to a # wants to build those libs and scripts as well or move them to a
# different place. See comments above for additional information # different place. See comments above for additional information
setup(name="CFML", setup(name="CFML",
version="0.0.1", version="0.0.1",
author="Simon Ward", author="Simon Ward",
author_email="simon.ward@ess.eu", author_email="simon.ward@ess.eu",
description="ManyLinux test of CrysFML", description="The Crystallographic Fortran Modules Library (CrysFML) is a set of modules containing "
ext_modules=[CMakeExtension(name="crysfml_api")], "procedures of interest in Crystallographic applications.",
ext_modules=[CMakeExtension(name=PACKAGE_NAME)],
long_description=open("./README", 'r').read(), long_description=open("./README", 'r').read(),
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
keywords="crystolography, physics, neutron, diffraction", keywords="crystallography, physics, neutron, diffraction",
classifiers=["Intended Audience :: Developers", classifiers=["Intended Audience :: Developers",
"License :: OSI Approved :: " "License :: OSI Approved :: "
"GNU Lesser General Public License v3 (LGPLv3)", "GNU Lesser General Public License v3 (LGPLv3)",
"Natural Language :: English", "Natural Language :: English",
"Programming Language :: C", "Programming Language :: Fortran",
"Programming Language :: C++",
"Programming Language :: Python"], "Programming Language :: Python"],
license='GPL-3.0', license='LGPL',
cmdclass={ cmdclass={
'build_ext': BuildCMakeExt, 'build_ext': BuildCMakeExt,
'install_data': InstallCMakeLibsData, 'install_data': InstallCMakeLibsData,
'install_lib': InstallCMakeLibs, 'install_lib': InstallCMakeLibs,
'install_scripts': InstallCMakeScripts 'install_scripts': InstallCMakeScripts
} }
) )
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