Unverified Commit 71ead488 authored by Simon Ward's avatar Simon Ward
Browse files

Test of building

parent 28c531c5
# Adapted from https://github.com/RalfG/python-wheels-manylinux-build/blob/master/full_workflow_example.yml
name: Build and (soon Publish Linux Python packages)
on:
push:
branches: [ simon ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install twine
- name: Build manylinux wheels
uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38'
build-requirements: 'cmake'
system-packages: ''
package-path: ''
pip-wheel-args: '--no-deps'
- uses: actions/upload-artifact@v2
with:
name: CrysFML
path: ${{ github.workspace }}/dist/*
\ No newline at end of file
......@@ -37,3 +37,6 @@
# Directories
Build
.idea/
build/
......@@ -52,16 +52,16 @@ message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}")
# Include and library paths for Python.
# They must be set by the user.
if(DEFINED PYTHON_LIBRARY_PATH)
set(PYTHON_LIBRARY_PATH ${PYTHON_LIBRARY_PATH} CACHE PATH "Python library path")
else()
set(PYTHON_LIBRARY_PATH "" CACHE PATH "Python library path")
endif()
if(DEFINED PYTHON_INTERPRETER_PATH)
set(PYTHON_INTERPRETER_PATH ${PYTHON_INTERPRETER_PATH} CACHE PATH "Python interpreter path")
else()
set(PYTHON_INTERPRETER_PATH "" CACHE PATH "Python interpreter path")
endif()
# if(DEFINED PYTHON_LIBRARY_PATH)
# set(PYTHON_LIBRARY_PATH ${PYTHON_LIBRARY_PATH} CACHE PATH "Python library path")
# else()
# set(PYTHON_LIBRARY_PATH "" CACHE PATH "Python library path")
# endif()
# if(DEFINED PYTHON_INTERPRETER_PATH)
# set(PYTHON_INTERPRETER_PATH ${PYTHON_INTERPRETER_PATH} CACHE PATH "Python interpreter path")
# else()
# set(PYTHON_INTERPRETER_PATH "" CACHE PATH "Python interpreter path")
# endif()
# Include and library paths for HDF5.
# They must be set by the user.
......
# -*- coding: utf-8 -*-
import os
import sys
from subprocess import CalledProcessError, check_output, check_call
import pkgutil
import re
from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion
from distutils.sysconfig import get_python_inc
import distutils.sysconfig as sysconfig
# Convert distutils Windows platform specifiers to CMake -A arguments
PLAT_TO_CMAKE = {
"win32": "Win32",
"win-amd64": "x64",
"win-arm32": "ARM",
"win-arm64": "ARM64",
}
# We can use cmake provided from pip which (normally) gets installed at /bin
# Except that in the manylinux builds it's placed at /opt/python/[version]/bin/
# (as a symlink at least) which is *not* on the path.
# If cmake is a known module, import it and use it tell us its binary directory
if pkgutil.find_loader('cmake') is not None:
import cmake
CMAKE_BIN = cmake.CMAKE_BIN_DIR + os.path.sep + 'cmake'
else:
CMAKE_BIN = 'cmake'
def get_cmake():
return CMAKE_BIN
# A CMakeExtension needs a sourcedir instead of a file list.
# The name must be the _single_ output extension from the CMake build.
# If you need multiple extensions, see scikit-build.
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def run(self):
try:
out = check_output([get_cmake(), '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build" +
" the following extensions: " +
", ".join(e.name for e in self.extensions))
rex = r'version\s*([\d.]+)'
cmake_version = LooseVersion(re.search(rex, out.decode()).group(1))
if cmake_version < '3.13.0':
raise RuntimeError("CMake >= 3.13.0 is required")
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# required for auto-detection of auxiliary "native" libs
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
cfg = "Debug" if self.debug else "Release"
cmake_args = [
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
"-DPython_ROOT_DIR={}/".format(sys.base_prefix),
"-DPYTHON_INCLUDE_DIR={}".format(get_python_inc()),
"-DPYTHON_LIBRARY ={}".format(sysconfig.get_config_var('LIBDIR')),
"-DPYTHON_LIBRARIES ={}".format(sysconfig.get_config_var('LIBDIR')),
"-DARCH32=OFF",
"-DCMAKE_Fortran_COMPILER=gfortran",
"-DPYTHON_API=ON",
"-DUSE_HDF=OFF",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(extdir),
"-DEXAMPLE_VERSION_INFO={}".format(self.distribution.get_version()),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
]
build_args = []
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
check_call(
[get_cmake(), ext.sourcedir] + cmake_args, cwd=self.build_temp
)
check_call(
[get_cmake(), "--build", "."] + build_args, cwd=self.build_temp
)
# The information here can also be placed in setup.cfg - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="CFML",
version="0.0.1",
author="Simon Ward",
author_email="simon.ward@ess.eu",
description="ManyLinux test of CrysFML",
long_description="",
ext_modules=[CMakeExtension("cmake_example")],
packages=find_packages(),
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
)
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