Skip to content

Commit 723ff0b

Browse files
authored
Merge pull request #142 from bnavigator/clean-setup-cmake
Clean build setup
2 parents 5a2798d + a45be5f commit 723ff0b

5 files changed

Lines changed: 21 additions & 112 deletions

File tree

‎.travis.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
os: osx
3030
language: shell
3131
env: TEST_PKG="dist" BLA_VENDOR="Apple"
32-
- name: "MacOSX, pyenv 3.8.7"
32+
- name: "MacOSX, pyenv 3.8.0"
3333
os: osx
3434
language: shell
35-
env: TEST_PKG="dist" BLA_VENDOR="Apple" SLYCOT_PYTHON_VERSION=3.8.7
36-
35+
env: TEST_PKG="dist" BLA_VENDOR="Apple" SLYCOT_PYTHON_VERSION=3.8.0
36+
allow_failures:
37+
- python: "3.9"
38+
env: TEST_PKG="conda" BLA_VENDOR="Intel10_64lp"
3739

3840
before_install:
3941
- |

‎CMakeLists.txt‎

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,21 @@ if (CMAKE_VERSION VERSION_GREATER "3.11.99")
77
endif()
88

99
project(slycot VERSION ${SLYCOT_VERSION} LANGUAGES NONE)
10-
# Fortran detection fails on windows, use the CMAKE_C_SIMULATE flag to
11-
# force success
12-
if(WIN32)
13-
set(CMAKE_Fortran_SIMULATE_VERSION 19.0)
14-
endif()
1510

16-
# this does not seem to work, maybe scikit-build's doing? the cxx compiler is
17-
# still tested
1811
enable_language(C)
1912
enable_language(Fortran)
2013

21-
# base site dir, use python installation for location specific includes
22-
execute_process(
23-
COMMAND "${PYTHON_EXECUTABLE}" -c
24-
"import os,numpy; print(os.path.dirname(numpy.__path__[0]))"
25-
OUTPUT_VARIABLE PYTHON_SITE
26-
OUTPUT_STRIP_TRAILING_WHITESPACE)
27-
if(WIN32)
28-
string(REPLACE "\\" "/" PYTHON_SITE ${PYTHON_SITE})
29-
endif()
30-
3114
find_package(PythonLibs REQUIRED)
15+
find_package(PythonExtensions REQUIRED)
3216
find_package(NumPy REQUIRED)
17+
find_package(F2PY REQUIRED)
3318
find_package(BLAS REQUIRED)
3419
find_package(LAPACK REQUIRED)
3520

36-
message(STATUS "NumPy: ${NumPy_INCLUDE_DIR}")
21+
message(STATUS "NumPy included from: ${NumPy_INCLUDE_DIR}")
22+
message(STATUS "F2PY included from: ${F2PY_INCLUDE_DIR}")
3723
message(STATUS "LAPACK: ${LAPACK_LIBRARIES}")
3824
message(STATUS "BLAS: ${BLAS_LIBRARIES}")
3925
message(STATUS "Slycot version: ${SLYCOT_VERSION}")
4026

41-
# find python, standard packages, F2PY find flaky on Windows
42-
if (NOT WIN32)
43-
find_package(F2PY REQUIRED)
44-
endif()
45-
46-
# pic option for flang not correct, remove for Windows
47-
if (WIN32)
48-
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "")
49-
endif()
50-
5127
add_subdirectory(slycot)
52-

‎README.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ Riccati, Lyapunov, and Sylvester equations.
1919
Dependencies
2020
------------
2121

22-
Slycot supports Python versions 2.7, and 3.5 or later.
22+
Slycot supports Python versions 3.6 or later.
2323

2424
To run the compiled Slycot package, the following must be installed as
2525
dependencies:
2626

27-
- Python 2.7, 3.5+
27+
- Python 3.6+
2828
- NumPy
2929

3030
If you are compiling and installing Slycot from source, you will need the
3131
following dependencies:
3232

33-
- Python 2.7, 3.5+
33+
- 3.6+
3434
- NumPy
3535
- scikit-build >= 0.10.0
3636
- CMake

‎setup.py‎

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88

9+
import builtins
910
import os
1011
import sys
1112
import subprocess
@@ -16,19 +17,14 @@
1617
except ImportError:
1718
import ConfigParser as configparser
1819

19-
if sys.version_info[0] >= 3:
20-
import builtins
21-
else:
22-
import __builtin__ as builtins
23-
2420
try:
2521
from skbuild import setup
2622
from skbuild.command.sdist import sdist
2723
except ImportError:
2824
raise ImportError('scikit-build must be installed before running setup.py')
2925

30-
if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[0:2] < (3, 5):
31-
raise RuntimeError("Python version 2.7 or >= 3.5 required.")
26+
if sys.version_info[0:2] < (3, 6):
27+
raise RuntimeError("Python version >= 3.6 required.")
3228

3329
DOCLINES = __doc__.split("\n")
3430

@@ -41,8 +37,10 @@
4137
Programming Language :: C
4238
Programming Language :: Fortran
4339
Programming Language :: Python
44-
Programming Language :: Python :: 2
45-
Programming Language :: Python :: 3
40+
Programming Language :: Python :: 3.6
41+
Programming Language :: Python :: 3.7
42+
Programming Language :: Python :: 3.8
43+
Programming Language :: Python :: 3.9
4644
Topic :: Software Development
4745
Topic :: Scientific/Engineering
4846
Operating System :: Microsoft :: Windows
@@ -190,35 +188,6 @@ def get_version_info(srcdir=None):
190188
return FULLVERSION, GIT_REVISION
191189

192190

193-
def check_submodules():
194-
""" verify that the submodules are checked out and clean
195-
use `git submodule update --init`; on failure
196-
"""
197-
if not os.path.exists('.git'):
198-
return
199-
with open('.gitmodules') as f:
200-
for l in f:
201-
if 'path' in l:
202-
p = l.split('=')[-1].strip()
203-
if not os.path.exists(p):
204-
raise ValueError('Submodule %s missing' % p)
205-
206-
proc = subprocess.Popen(['git', 'submodule', 'status'],
207-
stdout=subprocess.PIPE)
208-
status, _ = proc.communicate()
209-
status = status.decode("ascii", "replace")
210-
for line in status.splitlines():
211-
if line.startswith('-') or line.startswith('+'):
212-
raise ValueError('Submodule not clean: %s' % line)
213-
214-
215-
class sdist_checked(sdist):
216-
""" check submodules on sdist to prevent incomplete tarballs """
217-
def run(self):
218-
# slycot had no submodules currently
219-
# check_submodules()
220-
sdist.run(self)
221-
222191

223192
def setup_package():
224193
src_path = os.path.dirname(os.path.abspath(__file__))
@@ -241,7 +210,6 @@ def setup_package():
241210
license='GPL-2.0',
242211
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
243212
platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
244-
cmdclass={"sdist": sdist_checked},
245213
cmake_args=['-DSLYCOT_VERSION:STRING=' + VERSION,
246214
'-DGIT_REVISION:STRING=' + gitrevision,
247215
'-DISRELEASE:STRING=' + str(ISRELEASED),
@@ -250,40 +218,6 @@ def setup_package():
250218
install_requires=['numpy'],
251219
)
252220

253-
# Windows builds use Flang.
254-
# Flang detection and configuration is not automatic yet; the CMAKE
255-
# settings below are to circumvent that; when scikit-build and cmake
256-
# tools have improved, most of this might be removed?
257-
if platform.system() == 'Windows':
258-
259-
pbase = r'/'.join(sys.executable.split(os.sep)[:-1])
260-
env2cmakearg = {
261-
'FC': ('-DCMAKE_Fortran_COMPILER=',
262-
pbase + r'/Library/bin/flang.exe'),
263-
'F2PY': ('-DF2PY_EXECUTABLE=',
264-
pbase + r'/Scripts/f2py.exe'),
265-
'NUMPY_INCLUDE': ('-DNumPy_INCLUDE_DIR=',
266-
pbase + r'/Include')
267-
}
268-
269-
metadata['cmake_args'].extend(['-GNMake Makefiles'])
270-
271-
for k, v in env2cmakearg.items():
272-
print(k, v, os.environ.get(k, ''))
273-
envval = os.environ.get(k, None)
274-
if envval:
275-
# get from environment
276-
metadata['cmake_args'].append(
277-
v[0] + envval.replace('\\', '/'))
278-
else:
279-
# default
280-
metadata['cmake_args'].append(v[0] + v[1])
281-
282-
metadata['cmake_args'].extend([
283-
'-DCMAKE_Fortran_SIMULATE_VERSION=5.0.0',
284-
'-DCMAKE_Fortran_COMPILER_ID=Flang',
285-
'-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON'])
286-
print(metadata['cmake_args'])
287221
try:
288222
setup(**metadata)
289223
finally:

‎slycot/CMakeLists.txt‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ set(PYSOURCE
122122
${CMAKE_CURRENT_BINARY_DIR}/version.py)
123123

124124
set(SLYCOT_MODULE "_wrapper")
125-
find_package(PythonExtensions REQUIRED)
126125

127126
set(GENERATED_MODULE
128127
${CMAKE_CURRENT_BINARY_DIR}/${SLYCOT_MODULE}${PYTHON_EXTENSION_MODULE_SUFFIX})
@@ -141,7 +140,7 @@ add_custom_command(
141140
add_library(
142141
${SLYCOT_MODULE} MODULE
143142
_wrappermodule.c
144-
${PYTHON_SITE}/numpy/f2py/src/fortranobject.c
143+
${F2PY_INCLUDE_DIR}/fortranobject.c
145144
_wrapper-f2pywrappers.f
146145
${FSOURCES})
147146

@@ -150,8 +149,7 @@ target_link_libraries(${SLYCOT_MODULE}
150149

151150
target_include_directories(
152151
${SLYCOT_MODULE} PUBLIC
153-
${PYTHON_SITE}/numpy/core/include
154-
${PYTHON_SITE}/numpy/f2py/src
152+
${F2PY_INCLUDE_DIRS}
155153
${PYTHON_INCLUDE_DIRS}
156154
)
157155

0 commit comments

Comments
 (0)