Skip to content

Commit c7513c1

Browse files
committed
- added Python bindings
1 parent d666cba commit c7513c1

File tree

145 files changed

+22557
-2267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+22557
-2267
lines changed

.github/workflows/build-linux.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,58 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v1
12+
- name: apt-get update
13+
run: sudo apt-get update --fix-missing
1214
- name: Install packages
1315
run: sudo apt-get -y install xorg-dev freeglut3-dev
1416
- name: configure
1517
run: mkdir build-release && cd build-release && cmake -DCMAKE_BUILD_TYPE=Release ..
1618
- name: build
1719
run: cmake --build build-release
20+
21+
build-manylinux-python:
22+
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
# python-version: [3.7]
27+
python-version: [cp36-cp36m, cp37-cp37m, cp38-cp38]
28+
29+
steps:
30+
- uses: actions/checkout@v1
31+
32+
# Set up python
33+
- name: Set up Python 3.8
34+
uses: actions/setup-python@v1
35+
with:
36+
python-version: 3.8
37+
38+
# Install dependencies
39+
- name: Install dependencies
40+
run: python -m pip install --upgrade twine
41+
42+
- name: Build manylinux Python wheels
43+
uses: digitalillusions/python-wheels-manylinux-build@master
44+
with:
45+
# python-versions: 'cp37-cp37m'
46+
python-versions: '${{ matrix.python-version }}'
47+
build-requirements: ''
48+
system-packages: 'cmake3'
49+
package-path: ''
50+
pip-wheel-args: '--manylinux-build'
51+
52+
# Upload artifacts
53+
- name: Upload compiled wheel
54+
uses: actions/upload-artifact@master
55+
with:
56+
name: pypbd-linux-${{ matrix.python-version }}
57+
path: wheelhouse
58+
if: always()
59+
60+
# Publish to pypi
61+
- name: Publish wheels to PyPI
62+
env:
63+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
64+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
65+
run: |
66+
twine upload wheelhouse/*-manylinux*.whl --skip-existing

.github/workflows/build-windows.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,43 @@ jobs:
1919
run: cmake --build build-release --config Release
2020

2121

22+
# Build the python wheel in parallel
23+
build-windows-python:
24+
runs-on: windows-latest
25+
strategy:
26+
matrix:
27+
# python-version: [3.7]
28+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
29+
30+
steps:
31+
# Checkout repo
32+
- uses: actions/checkout@v1
33+
34+
# Set up python
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
# Install python dependencies
41+
- name: Install dependencies
42+
run: python -m pip install --upgrade pip setuptools wheel twine
43+
44+
# Change directory and run setup py
45+
- name: Run setup py
46+
run: python setup.py bdist_wheel
47+
48+
# Upload artifacts
49+
- name: Upload compiled wheel
50+
uses: actions/upload-artifact@master
51+
with:
52+
name: pypbd-windows-${{ matrix.python-version }}
53+
path: build/dist
54+
if: always()
55+
56+
# Upload wheel to pypi
57+
- name: Upload wheel to pypi
58+
env:
59+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
60+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
61+
run: twine upload build/dist/* --skip-existing

CMake/Common.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(PBD_BINARY_DEBUG_POSTFIX "_d" CACHE INTERNAL "Postfix for executables")
1212
set(PBD_BINARY_RELWITHDEBINFO_POSTFIX "_rd" CACHE INTERNAL "Postfix for executables")
1313
set(PBD_BINARY_MINSIZEREL_POSTFIX "_ms" CACHE INTERNAL "Postfix for executables")
1414

15+
include(CMakeDependentOption)
16+
1517
if (NOT WIN32)
1618
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
1719
if (NOT CMAKE_BUILD_TYPE)
@@ -65,3 +67,10 @@ OPTION(USE_DOUBLE_PRECISION "Use double precision" ON)
6567
if (USE_DOUBLE_PRECISION)
6668
add_definitions( -DUSE_DOUBLE)
6769
endif (USE_DOUBLE_PRECISION)
70+
71+
cmake_dependent_option(USE_PYTHON_BINDINGS "Generate Python Bindings using PyBind11" ON "PYTHON_EXECUTABLE" OFF)
72+
if (USE_PYTHON_BINDINGS AND UNIX)
73+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
74+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
75+
message(STATUS "Adding -fPIC option when generating Python bindings using GCC")
76+
endif ()

CMake/DataCopyTargets.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
add_custom_target(CopyPBDShaders
2+
${CMAKE_COMMAND} -E copy_directory
3+
${PROJECT_SOURCE_DIR}/data/shaders
4+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/shaders
5+
COMMENT "Copying PBD shaders"
6+
)
7+
set_target_properties(CopyPBDShaders PROPERTIES FOLDER "Data copy")
8+
9+
add_custom_target(CopyPBDModels
10+
${CMAKE_COMMAND} -E copy_directory
11+
${PROJECT_SOURCE_DIR}/data/models
12+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/models
13+
COMMENT "Copying PBD models"
14+
)
15+
set_target_properties(CopyPBDModels PROPERTIES FOLDER "Data copy")
16+
17+
add_custom_target(CopyPBDScenes
18+
${CMAKE_COMMAND} -E copy_directory
19+
${PROJECT_SOURCE_DIR}/data/scenes
20+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/scenes
21+
COMMENT "Copying PBD scenes"
22+
)
23+
set_target_properties(CopyPBDScenes PROPERTIES FOLDER "Data copy")

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1313

1414
include(${PROJECT_PATH}/CMake/Common.cmake)
1515

16-
add_definitions(-DPBD_DATA_PATH="../data")
17-
1816
if (NOT WIN32)
1917
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
2018
endif()
@@ -78,11 +76,16 @@ endif()
7876
add_subdirectory(PositionBasedDynamics)
7977
add_subdirectory(Simulation)
8078
add_subdirectory(Utils)
81-
if (NOT PBD_NO_DEMOS)
79+
if (NOT PBD_LIBS_ONLY)
80+
include(DataCopyTargets)
8281
add_subdirectory(extern/glfw)
8382
add_subdirectory(extern/AntTweakBar)
8483
add_subdirectory(extern/md5)
8584
add_subdirectory(Demos)
85+
if (USE_PYTHON_BINDINGS)
86+
add_subdirectory(extern/pybind)
87+
add_subdirectory(pyPBD)
88+
endif ()
8689
endif()
8790

8891

Changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.0
2+
- added Python binding
3+
- cleaned up demos
14
- added XPBD distance constraint
25
- added XPBD isometric bending constraint
36
- added XPBD volume constraint

Demos/BarDemo/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(SIMULATION_LINK_LIBRARIES AntTweakBar glfw PositionBasedDynamics Simulation Utils)
2-
set(SIMULATION_DEPENDENCIES AntTweakBar glfw PositionBasedDynamics Simulation Utils)
2+
set(SIMULATION_DEPENDENCIES AntTweakBar glfw PositionBasedDynamics Simulation Utils CopyPBDShaders)
33

44
if(WIN32)
55
set(SIMULATION_LINK_LIBRARIES opengl32.lib glu32.lib ${SIMULATION_LINK_LIBRARIES})

0 commit comments

Comments
 (0)