Skip to content

Commit ebba009

Browse files
committed
First attempt at faber-based build system.
1 parent 9ad3313 commit ebba009

File tree

6 files changed

+351
-23
lines changed

6 files changed

+351
-23
lines changed

appveyor.yml renamed to .appveyor.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ environment:
44
# /E:ON and /V:ON options are not enabled in the batch script intepreter
55
# See: http://stackoverflow.com/a/13751649/163740
66
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
7-
BOOST_PREFIX: C:\Libraries\boost_1_60_0
7+
BOOST_PREFIX: C:\Libraries\boost_1_63_0
88

99
matrix:
1010

@@ -15,7 +15,8 @@ environment:
1515
- PYTHON: "C:\\Python27"
1616
PYTHON_VERSION: "2.7.x" # currently 2.7.9
1717
PYTHON_ARCH: "32"
18-
ARCH: "x86"
18+
MSVC: "14.0"
19+
ARCH: x86
1920

2021
#- PYTHON: "C:\\Python27-x64"
2122
# PYTHON_VERSION: "2.7.x" # currently 2.7.9
@@ -26,9 +27,11 @@ environment:
2627
# PYTHON_VERSION: "3.5.x" # currently 3.4.3
2728
# PYTHON_ARCH: "32"
2829

29-
#- PYTHON: "C:\\Python35-x64"
30-
# PYTHON_VERSION: "3.5.x" # currently 3.4.3
31-
# PYTHON_ARCH: "64"
30+
- PYTHON: "C:\\Python36-x64"
31+
PYTHON_VERSION: "3.6.x"
32+
PYTHON_ARCH: "64"
33+
MSVC: "12.0"
34+
ARCH: x86_64
3235

3336
install:
3437
# If there is a newer build queued for the same PR, cancel this one.
@@ -68,21 +71,22 @@ install:
6871
# compiled extensions and are not provided as pre-built wheel packages,
6972
# pip will build them from source using the MSVC compiler matching the
7073
# target Python version and architecture
71-
- easy_install scons
74+
- |
75+
curl -LfsS -o faber.tar.gz https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz
76+
tar xf faber.tar.gz
77+
CD faber-release-0.2
78+
python setup.py install
79+
CD ..
80+
# report the available MSVC compilers
81+
- python -m faber.tools.msvc
7282
- easy_install sphinx
7383
- pip install numpy
74-
#- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
7584

7685
build_script:
77-
# Build the compiled extension
78-
#- "%CMD_IN_ENV% python setup.py build"
79-
- scons config arch=%ARCH% --boost-include=%BOOST_PREFIX%
80-
- scons arch=%ARCH% --verbose
86+
- faber --with-boost-include=%BOOST_PREFIX% target.arch=%ARCH% msvc.version=%MSVC%
8187

8288
test_script:
83-
# Run the project tests
84-
#- "%CMD_IN_ENV% python setup.py nosetests"
85-
- scons test arch=%ARCH% --verbose
89+
- faber --with-boost-include=%BOOST_PREFIX% test.report target.arch=%ARCH% msvc.version=%MSVC%
8690

8791
after_test:
8892
# If tests are successful, create binary packages for the project.
@@ -97,4 +101,4 @@ after_test:
97101

98102
#on_success:
99103
# - TODO: upload the content of dist/*.whl to a public wheelhouse
100-
#
104+
#

.ci/faber

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from faber.tools.python import python
2+
3+
p = python(command='$PYTHON')

.travis.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ matrix:
2626
- compiler: gcc
2727
env: CXX=g++ PYTHON=python3 CXXFLAGS=-std=c++11
2828
- compiler: clang
29-
# clang generates an 'illegal instruction' error in the NumPy check.
30-
# Perhaps we need to upgrade clang to a newer version ?
31-
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98 OPTIONS=--no-numpy
29+
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98
3230
- compiler: clang
33-
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11 OPTIONS=--no-numpy
34-
- env: PYTHON=python DOC=1
31+
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11
32+
#- env: PYTHON=python DOC=1
3533

3634

3735
addons:
@@ -77,16 +75,28 @@ install:
7775
./bootstrap.sh
7876
./b2 tools/bcp
7977
mkdir -p $HOME/Boost
78+
# Install Boost.Python prerequisites, but not Boost.Python itself.
8079
dist/bin/bcp python tools/boostbook tools/quickbook $HOME/Boost &> /dev/null
80+
rm -rf $HOME/Boost/boost/python*
81+
popd
82+
# Install Faber, the build tool.
83+
date=2017-11-09
84+
#wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz
85+
wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz
86+
tar xf 0.2.tar.gz
87+
pushd faber-release-0.2
88+
sudo python setup.py install
8189
popd
8290
fi
8391
8492
before_script:
85-
- scons --version
93+
- sed -e "s/\$PYTHON/$PYTHON/g" .ci/faber > ~/.faber
94+
- $PYTHON --version
95+
- faber -h
8696

8797
script:
88-
- scons config --python=$PYTHON --boost-include=$HOME/Boost $OPTIONS
89-
- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
98+
- faber --with-boost-include=$HOME/Boost test.report cxx.name=$CXX cxxflags=$CXXFLAGS
99+
#- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
90100

91101
after_success:
92102
# Upload docs only when building upstream.

fabscript

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# -*- python -*-
2+
#
3+
# Copyright (c) 2016 Stefan Seefeld
4+
# All rights reserved.
5+
#
6+
# Distributed under the Boost Software License, Version 1.0.
7+
# (See accompanying file LICENSE_1_0.txt or copy at
8+
# http://www.boost.org/LICENSE_1_0.txt)
9+
10+
from faber.feature import set
11+
from faber.types import cxx
12+
from faber.tools.compiler import cxxflags, define, include
13+
from faber.tools.python import python
14+
from faber.config import report, cxx_checks
15+
from faber.config.try_run import try_run
16+
17+
features += include('include')
18+
features += define('BOOST_ALL_NO_LIB') # disable auto-linking
19+
boost_include = options.get_with('boost-include')
20+
if boost_include:
21+
features += include(boost_include)
22+
python = python.instance()
23+
features |= set(python.include, python.linkpath, python.libs)
24+
25+
class has_numpy(try_run):
26+
27+
src = r"""
28+
// If defined, enforces linking against PythonXXd.lib, which
29+
// is usually not included in Python environments.
30+
#undef _DEBUG
31+
#include "Python.h"
32+
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
33+
#include "numpy/arrayobject.h"
34+
35+
#if PY_VERSION_HEX >= 0x03000000
36+
void *initialize() { import_array();}
37+
#else
38+
void initialize() { import_array();}
39+
#endif
40+
41+
int main()
42+
{
43+
int result = 0;
44+
Py_Initialize();
45+
initialize();
46+
if (PyErr_Occurred())
47+
{
48+
result = 1;
49+
}
50+
else
51+
{
52+
npy_intp dims = 2;
53+
PyObject * a = PyArray_SimpleNew(1, &dims, NPY_INT);
54+
if (!a) result = 1;
55+
Py_DECREF(a);
56+
}
57+
Py_Finalize();
58+
return result;
59+
}
60+
"""
61+
def __init__(self, features=()):
62+
63+
inc = ''
64+
try:
65+
inc = python.check_python('import numpy; print(numpy.get_include())')
66+
features |= include(inc)
67+
except Exception:
68+
# ignore errors, the check will fail during compilation...
69+
pass
70+
try_run.__init__(self, 'has_numpy', has_numpy.src, cxx, features,
71+
if_=(include(inc), define('HAS_NUMPY')))
72+
73+
checks = [cxx_checks.has_cxx11(features, define('HAS_CXX11')),
74+
has_numpy(features)]
75+
config = report('config', checks)
76+
77+
src = module('src', features=config.use)
78+
test = module('test', features=config.use)
79+
80+
default = src.default

src/fabscript

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- python -*-
2+
#
3+
# Copyright (c) 2016 Stefan Seefeld
4+
# All rights reserved.
5+
#
6+
# Distributed under the Boost Software License, Version 1.0.
7+
# (See accompanying file LICENSE_1_0.txt or copy at
8+
# http://www.boost.org/LICENSE_1_0.txt)
9+
10+
from faber.feature import set
11+
from faber.artefacts.library import library
12+
from faber.tools.compiler import define
13+
14+
root = module('..')
15+
16+
bpl = library('boost_python',
17+
['list.cpp',
18+
'long.cpp',
19+
'dict.cpp',
20+
'tuple.cpp',
21+
'str.cpp',
22+
'slice.cpp',
23+
'converter/from_python.cpp',
24+
'converter/registry.cpp',
25+
'converter/type_id.cpp',
26+
'object/enum.cpp',
27+
'object/class.cpp',
28+
'object/function.cpp',
29+
'object/inheritance.cpp',
30+
'object/life_support.cpp',
31+
'object/pickle_support.cpp',
32+
'errors.cpp',
33+
'module.cpp',
34+
'converter/builtin_converters.cpp',
35+
'converter/arg_to_python_base.cpp',
36+
'object/iterator.cpp',
37+
'object/stl_iterator.cpp',
38+
'object_protocol.cpp',
39+
'object_operators.cpp',
40+
'wrapper.cpp',
41+
'import.cpp',
42+
'exec.cpp',
43+
'object/function_doc_signature.cpp'],
44+
dependencies=root.config,
45+
features=features + define('BOOST_PYTHON_SOURCE'))
46+
47+
bnl = library('boost_numpy',
48+
['numpy/dtype.cpp',
49+
'numpy/matrix.cpp',
50+
'numpy/ndarray.cpp',
51+
'numpy/numpy.cpp',
52+
'numpy/scalars.cpp',
53+
'numpy/ufunc.cpp',
54+
bpl],
55+
dependencies=root.config,
56+
features=features + define('BOOST_NUMPY_SOURCE'),
57+
condition=set.define.contains('HAS_NUMPY'))
58+
default = [bpl, bnl]

0 commit comments

Comments
 (0)