Skip to content

Commit b9c32cf

Browse files
author
Charlles Abreu
authored
Creates recipe for building conda package (#4)
* Included conda recipe * Changed installation configs * Changed python install procedure * Removed target PythonTest * Included py.typed * Fixed conda recipe * Fixed GH Actions workflows * Fixed GH Actions again * Fixed extension name * Added pytest in pyproject.toml * Changed GH actions workflows * Fixed pytest usage * Improved version handling * Simplified conda-build test
1 parent ed4ec69 commit b9c32cf

File tree

18 files changed

+178
-64
lines changed

18 files changed

+178
-64
lines changed

.github/workflows/Linux.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ jobs:
6666
run: |
6767
cd build
6868
make -j2 install
69-
make -j2 PythonInstall
69+
make -j2 PythonWrapper
70+
pip install --no-deps -e python/
7071
7172
- name: "List plugins"
7273
shell: bash -l {0}
@@ -82,5 +83,5 @@ jobs:
8283
- name: "Run Python test"
8384
shell: bash -l {0}
8485
run: |
85-
cd build/python/tests
86-
pytest --verbose Test*
86+
cd build/python
87+
pytest

.github/workflows/MacOS.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ jobs:
6464
run: |
6565
cd build
6666
make -j2 install
67-
make -j2 PythonInstall
67+
make -j2 PythonWrapper
68+
pip install --no-deps -e python/
6869
6970
- name: "List plugins"
7071
shell: bash -l {0}
@@ -80,5 +81,5 @@ jobs:
8081
- name: "Run Python test"
8182
shell: bash -l {0}
8283
run: |
83-
cd build/python/tests
84-
pytest --verbose Test*
84+
cd build/python
85+
pytest

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_CUSTOM_CPP_FORCES_TARGET})
7777
# install headers
7878
FILE(GLOB API_ONLY_INCLUDE_FILES "customcppforces/include/*.h")
7979
INSTALL (FILES ${API_ONLY_INCLUDE_FILES} DESTINATION include)
80-
FILE(GLOB API_ONLY_INCLUDE_FILES_INTERNAL "customcppforces/include/internal/*.h")
81-
INSTALL (FILES ${API_ONLY_INCLUDE_FILES_INTERNAL} DESTINATION include/internal)
8280

8381
# Enable testing
8482

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
rm -rf build || true
6+
7+
CMAKE_FLAGS="-DOPENMM_DIR=${PREFIX}"
8+
if [[ "$target_platform" == osx* ]]; then
9+
CMAKE_FLAGS+=" -DCMAKE_OSX_SYSROOT=${CONDA_BUILD_SYSROOT}"
10+
CMAKE_FLAGS+=" -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}"
11+
fi
12+
13+
# Build in subdirectory and install.
14+
mkdir -p build
15+
cd build
16+
cmake ${CMAKE_ARGS} ${CMAKE_FLAGS} ${SRC_DIR}
17+
make -j$CPU_COUNT install
18+
make -j$CPU_COUNT PythonWrapper
19+
${PREFIX}/bin/python -m pip install --no-deps --ignore-installed python/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
python:
2+
- 3.9
3+
- 3.10
4+
- 3.11
5+
- 3.12
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% set plugin_version = environ['PLUGIN_VERSION'].lstrip('v') %}
2+
3+
package:
4+
name: customcppforces
5+
version: {{ plugin_version }}
6+
7+
source:
8+
git_url: ../../..
9+
10+
build:
11+
number: 0
12+
13+
requirements:
14+
build:
15+
- python
16+
- swig <4.1
17+
- doxygen
18+
- openmm >=8.1
19+
- {{ compiler('cxx') }}
20+
- cmake
21+
- make
22+
- setuptools
23+
- pip
24+
host:
25+
- python
26+
- openmm >=8.1
27+
run:
28+
- python
29+
- {{ pin_compatible('openmm', max_pin='x.x') }}
30+
31+
test:
32+
imports:
33+
- customcppforces
34+
35+
about:
36+
home: https://github.com/craabreu/customcppforces
37+
summary: Platform-agnostic OpenMM Forces
38+
license: MIT
39+
license_file: LICENSE.md
40+
doc_url: https://craabreu.github.io/customcppforces
41+
dev_url: https://github.com/craabreu/customcppforces
42+
43+
extra:
44+
recipe-maintainers:
45+
- craabreu

python/CMakeLists.txt

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
1-
set(WRAP_FILE CustomCPPForcesWrapper.cpp)
21
set(MODULE_NAME customcppforces)
3-
configure_file(customcppforces.i ${CMAKE_CURRENT_BINARY_DIR})
4-
5-
# Execute SWIG to generate source code for the Python module.
6-
7-
add_custom_command(
8-
OUTPUT "${WRAP_FILE}"
9-
COMMAND "${SWIG_EXECUTABLE}"
10-
-python -c++
11-
-doxygen
12-
-o "${WRAP_FILE}"
13-
"-I${OPENMM_DIR}/include"
14-
"customcppforces.i"
15-
DEPENDS "customcppforces.i"
16-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
17-
)
2+
set(WRAP_FILE CustomCPPForcesWrapper.cpp)
183

194
# Compile the Python module.
205

21-
add_custom_target(PythonInstall DEPENDS "${WRAP_FILE}")
6+
add_custom_target(PythonInstall DEPENDS ${SHARED_CUSTOM_CPP_FORCES_TARGET} PythonWrapper)
227
set(PLUGIN_HEADER_DIR "${CMAKE_SOURCE_DIR}/customcppforces/include")
238
set(PLUGIN_LIBRARY_DIR "${CMAKE_BINARY_DIR}")
24-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
9+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${CMAKE_CURRENT_BINARY_DIR})
10+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR})
11+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.in ${CMAKE_CURRENT_BINARY_DIR})
2512
add_custom_command(TARGET PythonInstall
26-
COMMAND "${PYTHON_EXECUTABLE}" -m pip install .
13+
COMMAND "${PYTHON_EXECUTABLE}" -m pip install --no-deps --ignore-installed .
2714
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
2815
)
2916

30-
subdirs (tests)
17+
subdirs(customcppforces)

python/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global-exclude *.py[cod] __pycache__

python/customcppforces/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Execute SWIG to generate source code for the Python module.
2+
3+
add_custom_target(PythonWrapper DEPENDS "${MODULE_NAME}.i")
4+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_NAME}.i ${CMAKE_CURRENT_BINARY_DIR})
5+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_BINARY_DIR})
6+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/py.typed ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
7+
8+
file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.py)
9+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/)
10+
foreach(file ${TEST_FILES})
11+
configure_file(${file} ${CMAKE_CURRENT_BINARY_DIR}/tests COPYONLY)
12+
endforeach(file ${TEST_FILES})
13+
14+
add_custom_command(
15+
TARGET PythonWrapper
16+
COMMAND "${SWIG_EXECUTABLE}"
17+
-python -c++
18+
-doxygen
19+
-o "${WRAP_FILE}"
20+
"-I${OPENMM_DIR}/include"
21+
"${MODULE_NAME}.i"
22+
DEPENDS ${MODULE_NAME}.i ${TEST_FILES}
23+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
24+
)

python/customcppforces/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from @MODULE_NAME@.@MODULE_NAME@ import *
2+
3+
__version__ = "@PROJECT_VERSION@"

0 commit comments

Comments
 (0)