Skip to content

Commit dd662ae

Browse files
authored
Merge pull request #96 from robertodr/pybind11
Bind to Python with pybind11
2 parents ca137ba + db470d4 commit dd662ae

23 files changed

+321
-3612
lines changed

.ci/cmake.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
echo "-- Installing CMake"
6+
CMAKE_VERSION="3.11.4"
7+
target_path=$HOME/Deps/cmake/$CMAKE_VERSION
8+
cmake_url="https://cmake.org/files/v${CMAKE_VERSION%.*}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
9+
mkdir -p "$target_path"
10+
curl -Ls "$cmake_url" | tar -xz -C "$target_path" --strip-components=1
11+
echo "-- Done installing CMake"

.ci/pybind11.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
pybind11_VERSION="2.4.3"
6+
echo "-- Installing pybind11 $pybind11_VERSION"
7+
cd "$HOME"/Downloads
8+
mkdir -p pybind11
9+
curl -Ls https://github.com/pybind/pybind11/archive/v${pybind11_VERSION}.tar.gz | tar -xz -C pybind11 --strip-components=1
10+
cd pybind11
11+
cmake -H. -Bbuild_pybind11 -DCMAKE_INSTALL_PREFIX="$HOME"/Deps/pybind11 -DPYTHON_EXECUTABLE=$(which python) -DPYBIND11_TEST=OFF #&> /dev/null
12+
cmake --build build_pybind11 -- install #&> /dev/null
13+
cd "$TRAVIS_BUILD_DIR"
14+
rm -rf "$HOME"/Downloads/pybind11
15+
echo "-- Done with pybind11 $pybind11_VERSION"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ cmake/lib/*.pyc
4040

4141
# Emacs backup files
4242
*~
43+
/.ccls-cache/
44+
/.mypy_cache/

.travis.yml

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: cpp
22
sudo: false
3-
dist: trusty
3+
dist: xenial
44

55
matrix:
66
include:
@@ -11,25 +11,22 @@ matrix:
1111
apt:
1212
packages:
1313
- clang
14-
- cmake3
1514
- gfortran
16-
- swig
1715
env:
1816
- CXX_COMPILER='clang++'
1917
- C_COMPILER='clang'
2018
- Fortran_COMPILER='gfortran'
2119
- BUILD_TYPE='Release'
2220
- PYTHON='--three'
2321
- COVERAGE=OFF
22+
- PYBIND11='-Dpybind11_DIR=$HOME/Deps/pybind11/share/cmake/pybind11'
2423
- os: linux
2524
compiler: clang
2625
addons: &clang35
2726
apt:
2827
packages:
2928
- clang-3.5
30-
- cmake3
3129
- gfortran
32-
- swig
3330
env:
3431
- CXX_COMPILER='clang++-3.5'
3532
- C_COMPILER='clang-3.5'
@@ -43,9 +40,7 @@ matrix:
4340
apt:
4441
packages:
4542
- clang-3.8
46-
- cmake3
4743
- gfortran
48-
- swig
4944
env:
5045
- CXX_COMPILER='clang++-3.8'
5146
- C_COMPILER='clang-3.8'
@@ -59,18 +54,17 @@ matrix:
5954
addons: &gcc48
6055
apt:
6156
packages:
62-
- cmake3
63-
- g++
64-
- gcc
65-
- gfortran
66-
- swig
57+
- g++-4.8
58+
- gcc-4.8
59+
- gfortran-4.8
6760
env:
68-
- CXX_COMPILER='g++'
69-
- C_COMPILER='gcc'
70-
- Fortran_COMPILER='gfortran'
61+
- CXX_COMPILER='g++-4.8'
62+
- C_COMPILER='gcc-4.8'
63+
- Fortran_COMPILER='gfortran-4.8'
7164
- BUILD_TYPE='Release'
7265
- PYTHON='--two'
7366
- COVERAGE=OFF
67+
- PYBIND11='-Dpybind11_DIR=$HOME/Deps/pybind11/share/cmake/pybind11'
7468
- os: linux
7569
python: 3.6
7670
compiler: gcc
@@ -79,11 +73,9 @@ matrix:
7973
sources:
8074
- ubuntu-toolchain-r-test
8175
packages:
82-
- cmake3
8376
- g++-5
8477
- gcc-5
8578
- gfortran-5
86-
- swig
8779
env:
8880
- CXX_COMPILER='g++-5'
8981
- C_COMPILER='gcc-5'
@@ -98,11 +90,9 @@ matrix:
9890
sources:
9991
- ubuntu-toolchain-r-test
10092
packages:
101-
- cmake3
10293
- g++-6
10394
- gcc-6
10495
- gfortran-6
105-
- swig
10696
env:
10797
- CXX_COMPILER='g++-6'
10898
- C_COMPILER='gcc-6'
@@ -117,11 +107,9 @@ matrix:
117107
sources:
118108
- ubuntu-toolchain-r-test
119109
packages:
120-
- cmake3
121110
- g++-7
122111
- gcc-7
123112
- gfortran-7
124-
- swig
125113
env:
126114
- CXX_COMPILER='g++-7'
127115
- C_COMPILER='gcc-7'
@@ -132,16 +120,32 @@ matrix:
132120
# 3/ OSX Clang Builds
133121
- os: osx
134122
compiler: clang
123+
addons:
124+
homebrew:
125+
packages:
126+
- cmake
127+
- python
128+
- pipenv
129+
update: true
135130
env:
136131
- CXX_COMPILER='clang++'
137132
- C_COMPILER='clang'
138133
- Fortran_COMPILER='gfortran'
139134
- BUILD_TYPE='Release'
140135
- PYTHON='--two'
141136
- COVERAGE=OFF
137+
- PYBIND11='-Dpybind11_DIR=$HOME/Deps/pybind11/share/cmake/pybind11'
142138
# 4/ OSX GCC Builds
143139
- os: osx
144140
compiler: gcc
141+
addons:
142+
homebrew:
143+
packages:
144+
- gcc
145+
- cmake
146+
- python
147+
- pipenv
148+
update: true
145149
env:
146150
- CXX_COMPILER='g++'
147151
- C_COMPILER='gcc'
@@ -157,12 +161,10 @@ matrix:
157161
sources:
158162
- ubuntu-toolchain-r-test
159163
packages:
160-
- cmake3
161164
- g++-7
162165
- gcc-7
163166
- gfortran-7
164167
- lcov
165-
- swig
166168
env:
167169
- CXX_COMPILER='g++-7'
168170
- C_COMPILER='gcc-7'
@@ -175,25 +177,19 @@ before_install:
175177
- test -n $CC && unset CC
176178
- test -n $CXX && unset CXX
177179
- test -n $FC && unset FC
180+
- mkdir -p "$HOME"/Deps "$HOME"/Downloads
178181

179182
install:
180-
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
181-
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
182183
- |
183-
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
184-
brew update &> /dev/null
185-
brew cask uninstall --force oclint
186-
brew upgrade cmake python
187-
brew install gcc pipenv swig
188-
elif [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
189-
# pip install --user pipenv --upgrade
190-
# https://github.com/pypa/pipenv/issues/3224
191-
pip install --user --upgrade -e git+https://github.com/pypa/pipenv.git#egg=pipenv
184+
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
185+
pip install --user pipenv --upgrade
192186
fi
193187
- pipenv $PYTHON install --dev
188+
- source $(pipenv --venv)/bin/activate
189+
- ./.ci/cmake.sh
190+
- ./.ci/pybind11.sh
194191

195192
before_script:
196-
- source $(pipenv --venv)/bin/activate
197193
- python --version
198194
- cd ${TRAVIS_BUILD_DIR}
199195
- >
@@ -206,6 +202,7 @@ before_script:
206202
-DENABLE_PYTHON_INTERFACE=ON
207203
-DPYTHON_EXECUTABLE=$(which python)
208204
-DCMAKE_INSTALL_PREFIX=$HOME/Software/xcfun
205+
${PYBIND11}
209206
210207
script:
211208
# Build and install

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copyright (c) 2015-2019 by Radovan Bast, Roberto Di Remigio, Jonas Juselius, and contributors.
33

44
# set minimum cmake version
5-
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
5+
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
66

77
# project name
88
project(XCFun LANGUAGES CXX C)
@@ -61,5 +61,4 @@ include(${PROJECT_SOURCE_DIR}/cmake/custom/compilers/CXXFlags.cmake)
6161
include(${PROJECT_SOURCE_DIR}/cmake/custom/compilers/CFlags.cmake)
6262
include(${PROJECT_SOURCE_DIR}/cmake/custom/static_library.cmake)
6363
include(${PROJECT_SOURCE_DIR}/cmake/custom/xcfun.cmake)
64-
include(${PROJECT_SOURCE_DIR}/cmake/downloaded/autocmake_src.cmake)
6564
include(${PROJECT_SOURCE_DIR}/cmake/custom/test.cmake)

Pipfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ name = "pypi"
77

88
[packages]
99

10-
numpy = "*"
11-
1210
[dev-packages]
1311

1412
Sphinx = "*"
15-
sphinx_rtd_theme = "*"
1613
fprettify = "*"
17-
pathlib2 = {version = "*", markers="python_version < '3'"}
18-
pyyaml = "*"
14+
numpy = "*"
15+
pathlib2 = {version = "*", markers="python_version < '3'"}
1916
pytest = "*"
17+
pyyaml = "*"
18+
sphinx_rtd_theme = "*"
2019
yapf = "*"

api/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
file(
2-
COPY ${CMAKE_CURRENT_LIST_DIR}/xcfun.h
3-
DESTINATION ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
1+
configure_file(
2+
${CMAKE_CURRENT_LIST_DIR}/xcfun.h
3+
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/xcfun.h
4+
COPYONLY
45
)
56

67
install(
@@ -10,9 +11,10 @@ install(
1011
${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
1112
)
1213

13-
file(
14-
COPY ${CMAKE_CURRENT_LIST_DIR}/xcfun.F90
15-
DESTINATION ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
14+
configure_file(
15+
${CMAKE_CURRENT_LIST_DIR}/xcfun.F90
16+
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/xcfun.F90
17+
COPYONLY
1618
)
1719

1820
install(

cmake/autocmake.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# adapt the following lines and expand
44

55
name: XCFun
6-
min_cmake_version: 3.5
6+
min_cmake_version: 3.11
77
setup_script: setup
88
url_root: https://github.com/coderefinery/autocmake/raw/master/
99
default_build_type: Debug
@@ -30,7 +30,6 @@ modules:
3030
- src:
3131
- source:
3232
- 'custom/xcfun.cmake'
33-
- '%(url_root)modules/src.cmake'
3433
- testing:
3534
- source:
3635
- 'custom/test.cmake'

0 commit comments

Comments
 (0)