pyb2d3 0.5.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyb2d3-0.5.3/.clang-format +91 -0
- pyb2d3-0.5.3/.github/workflows/conda.yaml +70 -0
- pyb2d3-0.5.3/.github/workflows/publish.yaml +110 -0
- pyb2d3-0.5.3/.gitignore +72 -0
- pyb2d3-0.5.3/.pre-commit-config.yaml +23 -0
- pyb2d3-0.5.3/CMakeLists.txt +148 -0
- pyb2d3-0.5.3/LICENSE +21 -0
- pyb2d3-0.5.3/PKG-INFO +15 -0
- pyb2d3-0.5.3/README.md +60 -0
- pyb2d3-0.5.3/build_pkg.sh +35 -0
- pyb2d3-0.5.3/dev-environment.yaml +23 -0
- pyb2d3-0.5.3/examples/notebooks/raycast.ipynb +156 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/__init__.py +28 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/billard.py +313 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/chain_builder.py +118 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/coupled_minigolf.py +269 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/goo_game.py +825 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/joints.py +97 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/jump.py +124 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/mirror.py +125 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/newtons_cradle.py +62 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/raycast.py +84 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/shapes.py +212 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/soft_bodies.py +99 -0
- pyb2d3-0.5.3/examples/pyb2d3_samples/tumbler.py +183 -0
- pyb2d3-0.5.3/extra_licenses/LICENSE_BOX2D +21 -0
- pyb2d3-0.5.3/extra_licenses/LICENSE_NANOBIND +26 -0
- pyb2d3-0.5.3/extra_licenses/README +0 -0
- pyb2d3-0.5.3/include/pyb2d3/batch_api/batch_exporters.hpp +167 -0
- pyb2d3-0.5.3/include/pyb2d3/batch_api/ndarray_traits.hpp +259 -0
- pyb2d3-0.5.3/include/pyb2d3/batch_api.hpp +47 -0
- pyb2d3-0.5.3/include/pyb2d3/debug_draw.hpp +236 -0
- pyb2d3-0.5.3/include/pyb2d3/numpy_utils.hpp +63 -0
- pyb2d3-0.5.3/include/pyb2d3/py_chain_def.hpp +20 -0
- pyb2d3-0.5.3/include/pyb2d3/py_converter.hpp +241 -0
- pyb2d3-0.5.3/include/pyb2d3/threadpool.hpp +294 -0
- pyb2d3-0.5.3/include/pyb2d3/world_to_canvas.hpp +99 -0
- pyb2d3-0.5.3/include/pyb2d3/wrapper_structs.hpp +1917 -0
- pyb2d3-0.5.3/pyproject.toml +78 -0
- pyb2d3-0.5.3/src/export_batch_api.cpp +89 -0
- pyb2d3-0.5.3/src/export_box2d_types.cpp +928 -0
- pyb2d3-0.5.3/src/export_box2d_wrapper_structs.cpp +766 -0
- pyb2d3-0.5.3/src/export_collision.cpp +381 -0
- pyb2d3-0.5.3/src/export_math_functions.cpp +736 -0
- pyb2d3-0.5.3/src/export_threadpool.cpp +27 -0
- pyb2d3-0.5.3/src/export_world_to_canvas.cpp +90 -0
- pyb2d3-0.5.3/src/main.cpp +41 -0
- pyb2d3-0.5.3/src/module/pyb2d3/__init__.py +917 -0
- pyb2d3-0.5.3/src/module/pyb2d3/debug_draw/__init__.py +1 -0
- pyb2d3-0.5.3/src/module/pyb2d3/debug_draw/debug_draw.py +36 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/__init__.py +2 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/frontend/__init__.py +22 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/frontend/default_frontend.py +55 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/frontend/frontend_base.py +586 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/frontend/ipycanvas_frontend.py +574 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/frontend/pygame_frontend.py +342 -0
- pyb2d3-0.5.3/src/module/pyb2d3/samples/sample_base.py +176 -0
- pyb2d3-0.5.3/src/py_debug_draw.cpp +49 -0
- pyb2d3-0.5.3/src/py_debug_draw.hpp +81 -0
- pyb2d3-0.5.3/tests/__init__.py +0 -0
- pyb2d3-0.5.3/tests/conftest.py +0 -0
- pyb2d3-0.5.3/tests/headless_test_frontend.py +247 -0
- pyb2d3-0.5.3/tests/test_pyb2d3.py +246 -0
- pyb2d3-0.5.3/tests/test_samples.py +32 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
BasedOnStyle: Mozilla
|
|
2
|
+
|
|
3
|
+
AccessModifierOffset: '-4'
|
|
4
|
+
AlignAfterOpenBracket: BlockIndent
|
|
5
|
+
AlignEscapedNewlines: Left
|
|
6
|
+
AllowAllArgumentsOnNextLine: false
|
|
7
|
+
AllowAllParametersOfDeclarationOnNextLine: false
|
|
8
|
+
AllowShortBlocksOnASingleLine: false
|
|
9
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
10
|
+
AllowShortFunctionsOnASingleLine: false
|
|
11
|
+
AllowShortIfStatementsOnASingleLine: false
|
|
12
|
+
# Forbid one line lambdas because clang-format makes a weird split when
|
|
13
|
+
# single instructions lambdas are too long.
|
|
14
|
+
AllowShortLambdasOnASingleLine: Empty
|
|
15
|
+
AllowShortLoopsOnASingleLine: false
|
|
16
|
+
AlwaysBreakAfterDefinitionReturnType: None
|
|
17
|
+
AlwaysBreakAfterReturnType: None
|
|
18
|
+
AlwaysBreakTemplateDeclarations: Yes
|
|
19
|
+
BinPackArguments: false
|
|
20
|
+
BinPackParameters: false
|
|
21
|
+
BreakBeforeBinaryOperators: NonAssignment
|
|
22
|
+
BreakBeforeBraces: Allman
|
|
23
|
+
BreakBeforeTernaryOperators: true
|
|
24
|
+
BreakConstructorInitializers: BeforeComma
|
|
25
|
+
BreakInheritanceList: AfterComma
|
|
26
|
+
BreakStringLiterals: false
|
|
27
|
+
ColumnLimit: '110'
|
|
28
|
+
ConstructorInitializerIndentWidth: '4'
|
|
29
|
+
ContinuationIndentWidth: '4'
|
|
30
|
+
Cpp11BracedListStyle: true
|
|
31
|
+
DerivePointerAlignment: false
|
|
32
|
+
DisableFormat: false
|
|
33
|
+
EmptyLineAfterAccessModifier: Always
|
|
34
|
+
EmptyLineBeforeAccessModifier: Always
|
|
35
|
+
ExperimentalAutoDetectBinPacking: true
|
|
36
|
+
IncludeBlocks: Regroup
|
|
37
|
+
IncludeCategories:
|
|
38
|
+
- Regex: <[^.]+>
|
|
39
|
+
Priority: 1
|
|
40
|
+
- Regex: <sparrow/.+>
|
|
41
|
+
Priority: 3
|
|
42
|
+
- Regex: <.+>
|
|
43
|
+
Priority: 2
|
|
44
|
+
- Regex: '"sparrow/.+"'
|
|
45
|
+
Priority: 4
|
|
46
|
+
- Regex: '".+"'
|
|
47
|
+
Priority: 5
|
|
48
|
+
IndentCaseLabels: true
|
|
49
|
+
IndentPPDirectives: AfterHash
|
|
50
|
+
IndentWidth: '4'
|
|
51
|
+
IndentWrappedFunctionNames: false
|
|
52
|
+
InsertBraces: true
|
|
53
|
+
InsertTrailingCommas: Wrapped
|
|
54
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
55
|
+
LambdaBodyIndentation: Signature
|
|
56
|
+
Language: Cpp
|
|
57
|
+
MaxEmptyLinesToKeep: '2'
|
|
58
|
+
NamespaceIndentation: All
|
|
59
|
+
ObjCBlockIndentWidth: '4'
|
|
60
|
+
ObjCSpaceAfterProperty: false
|
|
61
|
+
ObjCSpaceBeforeProtocolList: false
|
|
62
|
+
PackConstructorInitializers: Never
|
|
63
|
+
PenaltyBreakAssignment: 100000
|
|
64
|
+
PenaltyBreakBeforeFirstCallParameter: 0
|
|
65
|
+
PenaltyBreakComment: 10
|
|
66
|
+
PenaltyBreakOpenParenthesis: 0
|
|
67
|
+
PenaltyBreakTemplateDeclaration: 0
|
|
68
|
+
PenaltyExcessCharacter: 10
|
|
69
|
+
PenaltyIndentedWhitespace: 0
|
|
70
|
+
PenaltyReturnTypeOnItsOwnLine: 10
|
|
71
|
+
PointerAlignment: Left
|
|
72
|
+
QualifierAlignment: Custom # Experimental
|
|
73
|
+
QualifierOrder: [inline, static, constexpr, const, volatile, type]
|
|
74
|
+
ReflowComments: true
|
|
75
|
+
SeparateDefinitionBlocks: Always
|
|
76
|
+
SortIncludes: CaseInsensitive
|
|
77
|
+
SortUsingDeclarations: true
|
|
78
|
+
SpaceAfterCStyleCast: true
|
|
79
|
+
SpaceAfterTemplateKeyword: true
|
|
80
|
+
SpaceBeforeAssignmentOperators: true
|
|
81
|
+
SpaceBeforeParens: ControlStatements
|
|
82
|
+
SpaceInEmptyParentheses: false
|
|
83
|
+
SpacesBeforeTrailingComments: '2'
|
|
84
|
+
SpacesInAngles: false
|
|
85
|
+
SpacesInCStyleCastParentheses: false
|
|
86
|
+
SpacesInContainerLiterals: false
|
|
87
|
+
SpacesInParentheses: false
|
|
88
|
+
SpacesInSquareBrackets: false
|
|
89
|
+
Standard: c++20
|
|
90
|
+
TabWidth: '4'
|
|
91
|
+
UseTab: Never
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
name: conda
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
jobs:
|
|
7
|
+
|
|
8
|
+
pip:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout repo
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- uses: mamba-org/setup-micromamba@v2
|
|
18
|
+
with:
|
|
19
|
+
environment-file: dev-environment.yaml
|
|
20
|
+
init-shell: >-
|
|
21
|
+
bash
|
|
22
|
+
cache-environment: true
|
|
23
|
+
post-cleanup: 'all'
|
|
24
|
+
|
|
25
|
+
- name: build
|
|
26
|
+
shell: bash -el {0}
|
|
27
|
+
run: |
|
|
28
|
+
export CMAKE_ARGS="-DFETCH_BOX2D=OFF"
|
|
29
|
+
uv pip install .
|
|
30
|
+
|
|
31
|
+
- name: test
|
|
32
|
+
shell: bash -el {0}
|
|
33
|
+
run: |
|
|
34
|
+
pytest -v
|
|
35
|
+
|
|
36
|
+
raw-cmake:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
strategy:
|
|
39
|
+
fail-fast: false
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- name: Checkout repo
|
|
43
|
+
uses: actions/checkout@v4
|
|
44
|
+
with:
|
|
45
|
+
fetch-depth: 0
|
|
46
|
+
|
|
47
|
+
- uses: mamba-org/setup-micromamba@v2
|
|
48
|
+
with:
|
|
49
|
+
environment-file: dev-environment.yaml
|
|
50
|
+
init-shell: >-
|
|
51
|
+
bash
|
|
52
|
+
cache-environment: true
|
|
53
|
+
post-cleanup: 'all'
|
|
54
|
+
|
|
55
|
+
- name: build
|
|
56
|
+
shell: bash -el {0}
|
|
57
|
+
run: |
|
|
58
|
+
NANOBIND_CMAKE_DIR=$(python -m nanobind --cmake_dir)
|
|
59
|
+
mkdir -p build
|
|
60
|
+
cd build
|
|
61
|
+
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
|
|
62
|
+
-Dnanobind_DIR=$NANOBIND_CMAKE_DIR \
|
|
63
|
+
-DFETCH_BOX2D=OFF
|
|
64
|
+
|
|
65
|
+
cmake --build . --config Release
|
|
66
|
+
|
|
67
|
+
- name: test
|
|
68
|
+
shell: bash -el {0}
|
|
69
|
+
run: |
|
|
70
|
+
PYTHONPATH=$(pwd)/src/module pytest -v
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
name: Build and upload to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
# branches:
|
|
8
|
+
# - main
|
|
9
|
+
release:
|
|
10
|
+
types:
|
|
11
|
+
- published
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build_wheels:
|
|
15
|
+
name: Build wheels for ${{ matrix.os }}
|
|
16
|
+
runs-on: ${{ matrix.runs-on }}
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- os: linux-intel
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
- os: linux-arm
|
|
23
|
+
runs-on: ubuntu-24.04-arm
|
|
24
|
+
- os: windows-intel
|
|
25
|
+
runs-on: windows-latest
|
|
26
|
+
# - os: windows-arm
|
|
27
|
+
# runs-on: windows-11-arm
|
|
28
|
+
- os: macos-intel
|
|
29
|
+
# macos-13 was the last x86_64 runner
|
|
30
|
+
runs-on: macos-13
|
|
31
|
+
- os: macos-arm
|
|
32
|
+
# macos-14+ (including latest) are ARM64 runners
|
|
33
|
+
runs-on: macos-latest
|
|
34
|
+
# - os: android-intel
|
|
35
|
+
# runs-on: ubuntu-latest
|
|
36
|
+
# platform: android
|
|
37
|
+
# - os: android-arm
|
|
38
|
+
# runs-on: macos-latest
|
|
39
|
+
# platform: android
|
|
40
|
+
# - os: ios
|
|
41
|
+
# runs-on: macos-latest
|
|
42
|
+
# platform: ios
|
|
43
|
+
# - os: pyodide
|
|
44
|
+
# runs-on: ubuntu-latest
|
|
45
|
+
# platform: pyodide
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
|
|
50
|
+
# GitHub Actions can't currently run the Android emulator on macOS.
|
|
51
|
+
- name: Skip Android tests on macOS
|
|
52
|
+
if: matrix.os == 'android-arm'
|
|
53
|
+
run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV"
|
|
54
|
+
|
|
55
|
+
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
|
|
56
|
+
- name: Enable KVM for Android emulator
|
|
57
|
+
if: matrix.os == 'android-intel'
|
|
58
|
+
run: |
|
|
59
|
+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
|
60
|
+
sudo udevadm control --reload-rules
|
|
61
|
+
sudo udevadm trigger --name-match=kvm
|
|
62
|
+
|
|
63
|
+
- name: Build wheels
|
|
64
|
+
uses: pypa/cibuildwheel@v3.1.1
|
|
65
|
+
env:
|
|
66
|
+
CIBW_PLATFORM: ${{ matrix.platform || 'auto' }}
|
|
67
|
+
# Can also be configured directly, using `with:`
|
|
68
|
+
# with:
|
|
69
|
+
# package-dir: .
|
|
70
|
+
# output-dir: wheelhouse
|
|
71
|
+
# config-file: "{package}/pyproject.toml"
|
|
72
|
+
|
|
73
|
+
- uses: actions/upload-artifact@v4
|
|
74
|
+
with:
|
|
75
|
+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
|
|
76
|
+
path: ./wheelhouse/*.whl
|
|
77
|
+
|
|
78
|
+
build_sdist:
|
|
79
|
+
name: Build source distribution
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/checkout@v4
|
|
83
|
+
|
|
84
|
+
- name: Build sdist
|
|
85
|
+
run: pipx run build --sdist
|
|
86
|
+
|
|
87
|
+
- uses: actions/upload-artifact@v4
|
|
88
|
+
with:
|
|
89
|
+
name: cibw-sdist
|
|
90
|
+
path: dist/*.tar.gz
|
|
91
|
+
|
|
92
|
+
upload_pypi:
|
|
93
|
+
needs: [build_wheels, build_sdist]
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
environment: pypi
|
|
96
|
+
permissions:
|
|
97
|
+
id-token: write
|
|
98
|
+
# if: github.event_name == 'release' && github.event.action == 'published'
|
|
99
|
+
# # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
|
|
100
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
101
|
+
steps:
|
|
102
|
+
- uses: actions/download-artifact@v4
|
|
103
|
+
with:
|
|
104
|
+
# unpacks all CIBW artifacts into dist/
|
|
105
|
+
pattern: cibw-*
|
|
106
|
+
path: dist
|
|
107
|
+
merge-multiple: true
|
|
108
|
+
|
|
109
|
+
- name: Upload to PyPI
|
|
110
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
pyb2d3-0.5.3/.gitignore
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
*.d
|
|
3
|
+
|
|
4
|
+
# Compiled Object files
|
|
5
|
+
*.slo
|
|
6
|
+
*.lo
|
|
7
|
+
*.o
|
|
8
|
+
*.obj
|
|
9
|
+
|
|
10
|
+
# Precompiled Headers
|
|
11
|
+
*.gch
|
|
12
|
+
*.pch
|
|
13
|
+
|
|
14
|
+
# Compiled Dynamic libraries
|
|
15
|
+
*.so
|
|
16
|
+
*.dylib
|
|
17
|
+
*.dll
|
|
18
|
+
|
|
19
|
+
# Fortran module files
|
|
20
|
+
*.mod
|
|
21
|
+
*.smod
|
|
22
|
+
|
|
23
|
+
# Compiled Static libraries
|
|
24
|
+
*.lai
|
|
25
|
+
*.la
|
|
26
|
+
*.a
|
|
27
|
+
*.lib
|
|
28
|
+
|
|
29
|
+
# Executables
|
|
30
|
+
*.exe
|
|
31
|
+
*.out
|
|
32
|
+
*.app
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
.DS_Store
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
_pyb2d.cpython*
|
|
40
|
+
__pycache__/
|
|
41
|
+
|
|
42
|
+
# bld directory
|
|
43
|
+
bld/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# some testfonts
|
|
47
|
+
Minecraft.ttf
|
|
48
|
+
|
|
49
|
+
.pixi/
|
|
50
|
+
pixi.lock
|
|
51
|
+
build/
|
|
52
|
+
dist/
|
|
53
|
+
|
|
54
|
+
dependencies/
|
|
55
|
+
sandbox/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# jupyter notebook checkpoints
|
|
59
|
+
.ipynb_checkpoints/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# .vscode directory
|
|
63
|
+
.vscode/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# ignore benchmark directory
|
|
67
|
+
# (contains benchmark results and scripts)
|
|
68
|
+
benchmark/
|
|
69
|
+
|
|
70
|
+
# ignore custom scripts
|
|
71
|
+
run.sh
|
|
72
|
+
init.sh
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v5.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-yaml
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: trailing-whitespace
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
10
|
+
# Ruff version.
|
|
11
|
+
rev: v0.12.4
|
|
12
|
+
hooks:
|
|
13
|
+
# Run the linter.
|
|
14
|
+
- id: ruff-check
|
|
15
|
+
args: [ --fix ]
|
|
16
|
+
# Run the formatter.
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
|
|
19
|
+
- repo: https://github.com/pre-commit/mirrors-clang-format
|
|
20
|
+
rev: v20.1.3
|
|
21
|
+
hooks:
|
|
22
|
+
- id: clang-format
|
|
23
|
+
exclude_types: [javascript, json, python, yaml]
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.22)
|
|
2
|
+
project(pyb2d)
|
|
3
|
+
include(FetchContent)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
|
7
|
+
OPTION(PYB2D3_NO_THREADING "Disable threading support" OFF)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# this is only relevant if we are building box2d
|
|
11
|
+
# (ie if FETCH_BOX2D is ON)
|
|
12
|
+
OPTION(FETCH_BOX2D "Download/Fetch Box2D" ON)
|
|
13
|
+
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
|
14
|
+
|
|
15
|
+
if(FETCH_BOX2D)
|
|
16
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
17
|
+
FetchContent_Declare(
|
|
18
|
+
box2d
|
|
19
|
+
GIT_REPOSITORY https://github.com/erincatto/box2d.git
|
|
20
|
+
GIT_TAG v3.1.1
|
|
21
|
+
GIT_SHALLOW TRUE
|
|
22
|
+
GIT_PROGRESS TRUE
|
|
23
|
+
)
|
|
24
|
+
FetchContent_MakeAvailable(box2d)
|
|
25
|
+
else()
|
|
26
|
+
find_package(box2d REQUIRED)
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if(DEFINED SKBUILD)
|
|
31
|
+
SET(CMAKE_INSTALL_LIBDIR ${SKBUILD_PROJECT_NAME}/lib)
|
|
32
|
+
else()
|
|
33
|
+
SET(INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
|
|
34
|
+
SET(CMAKE_INSTALL_LIBDIR lib)
|
|
35
|
+
endif()
|
|
36
|
+
|
|
37
|
+
if(EMSCRIPTEN)
|
|
38
|
+
# set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
|
|
39
|
+
# set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
|
|
40
|
+
# set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
|
|
41
|
+
# set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules
|
|
42
|
+
|
|
43
|
+
# # Create a target that holds Python module information
|
|
44
|
+
# add_library(MyFakePythonModule INTERFACE)
|
|
45
|
+
|
|
46
|
+
# # Define the include directories
|
|
47
|
+
# set_target_properties(MyFakePythonModule PROPERTIES
|
|
48
|
+
# INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}"
|
|
49
|
+
# )
|
|
50
|
+
|
|
51
|
+
# # Define the link libraries (the actual Python library)
|
|
52
|
+
# set_target_properties(MyFakePythonModule PROPERTIES
|
|
53
|
+
# INTERFACE_LINK_LIBRARIES "${Python_LIBRARIES}"
|
|
54
|
+
# )
|
|
55
|
+
|
|
56
|
+
# # Optionally, if nanobind uses the Python executable path:
|
|
57
|
+
# set_target_properties(MyFakePythonModule PROPERTIES
|
|
58
|
+
# INTERFACE_COMPILE_DEFINITIONS "PYTHON_EXECUTABLE=\"${Python_EXECUTABLE}\""
|
|
59
|
+
# )
|
|
60
|
+
|
|
61
|
+
# # Attempt to create an alias (might not fully satisfy the check)
|
|
62
|
+
# add_library(Python::Module ALIAS MyFakePythonModule)
|
|
63
|
+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
|
64
|
+
else()
|
|
65
|
+
# Find Python
|
|
66
|
+
|
|
67
|
+
find_package(Python 3.10
|
|
68
|
+
REQUIRED COMPONENTS Interpreter Development.Module
|
|
69
|
+
OPTIONAL_COMPONENTS Development.SABIModule)
|
|
70
|
+
# Import nanobind through CMake's find_package mechanism
|
|
71
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
72
|
+
|
|
73
|
+
endif()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# find_package(box2d REQUIRED)
|
|
78
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
SET(PY_SOURCES
|
|
82
|
+
src/main.cpp
|
|
83
|
+
src/export_box2d_types.cpp
|
|
84
|
+
src/export_box2d_wrapper_structs.cpp
|
|
85
|
+
src/export_collision.cpp
|
|
86
|
+
src/export_math_functions.cpp
|
|
87
|
+
src/export_batch_api.cpp
|
|
88
|
+
src/export_world_to_canvas.cpp
|
|
89
|
+
src/py_debug_draw.cpp
|
|
90
|
+
)
|
|
91
|
+
if(NOT PYB2D3_NO_THREADING)
|
|
92
|
+
# if not emscripten, add the main.cpp file
|
|
93
|
+
list(APPEND PY_SOURCES src/export_threadpool.cpp)
|
|
94
|
+
endif()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if(NOT EMSCRIPTEN)
|
|
98
|
+
nanobind_add_module(_pyb2d3 STABLE_ABI ${PY_SOURCES})
|
|
99
|
+
else()
|
|
100
|
+
|
|
101
|
+
nanobind_add_module(_pyb2d3 ${PY_SOURCES})
|
|
102
|
+
endif()
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if(NOT PYB2D3_NO_THREADING)
|
|
106
|
+
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
107
|
+
find_package(Threads REQUIRED)
|
|
108
|
+
target_link_libraries(_pyb2d3 PRIVATE Threads::Threads)
|
|
109
|
+
endif()
|
|
110
|
+
|
|
111
|
+
# include directories
|
|
112
|
+
target_include_directories(_pyb2d3
|
|
113
|
+
PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
|
114
|
+
|
|
115
|
+
#add definitions
|
|
116
|
+
if(PYB2D3_NO_THREADING)
|
|
117
|
+
target_compile_definitions(_pyb2d3 PRIVATE PYB2D3_NO_THREADING)
|
|
118
|
+
endif()
|
|
119
|
+
|
|
120
|
+
# link box2d
|
|
121
|
+
target_link_libraries(_pyb2d3 PRIVATE box2d::box2d)
|
|
122
|
+
|
|
123
|
+
# after each build, copy the extension to the python package directory
|
|
124
|
+
add_custom_command(TARGET _pyb2d3 POST_BUILD
|
|
125
|
+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_pyb2d3> ${CMAKE_SOURCE_DIR}/src/module/pyb2d3
|
|
126
|
+
COMMENT "Copying _pyb2d3 to python package directory"
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
if(NOT DEFINED SKBUILD)
|
|
130
|
+
# on mac or linux, set the shared library suffix to .so
|
|
131
|
+
if(APPLE OR UNIX)
|
|
132
|
+
set_target_properties(_pyb2d3 PROPERTIES SUFFIX ".so")
|
|
133
|
+
endif()
|
|
134
|
+
else()
|
|
135
|
+
message(STATUS "using SKBUILD" ${SKBUILD})
|
|
136
|
+
endif()
|
|
137
|
+
|
|
138
|
+
# INSTALL
|
|
139
|
+
###################
|
|
140
|
+
# if SKBUILD is defined, install to the python package directory
|
|
141
|
+
if(DEFINED SKBUILD)
|
|
142
|
+
message(STATUS "using SKBUILD" ${SKBUILD})
|
|
143
|
+
install(TARGETS _pyb2d3 LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME})
|
|
144
|
+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/module/pyb2d3/ DESTINATION ${SKBUILD_PROJECT_NAME})
|
|
145
|
+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${SKBUILD_PROJECT_NAME}/include)
|
|
146
|
+
else()
|
|
147
|
+
message(STATUS "not using SKBUILD")
|
|
148
|
+
endif()
|
pyb2d3-0.5.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Thorsten Beier
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pyb2d3-0.5.3/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyb2d3
|
|
3
|
+
Version: 0.5.3
|
|
4
|
+
Summary: python box2d bindings for box2d >= 3.1
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: extra_licenses/LICENSE_BOX2D
|
|
8
|
+
License-File: extra_licenses/LICENSE_NANOBIND
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
|
pyb2d3-0.5.3/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# pyb2d3
|
|
2
|
+
python bindings for Box2D 3
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# badges
|
|
6
|
+
[](https://github.com/DerThorsten/pyb2d3/actions/workflows/pixi.yml)
|
|
7
|
+
[](https://github.com/DerThorsten/pyb2d3/actions/workflows/mm.yaml)
|
|
8
|
+
[](https://github.com/DerThorsten/pyb2d3/actions/workflows/raw-cmake.yaml)
|
|
9
|
+
|
|
10
|
+
# Building
|
|
11
|
+
This may not work on windows!
|
|
12
|
+
|
|
13
|
+
## micromamba + uv / pip
|
|
14
|
+
|
|
15
|
+
Create the development environment with:
|
|
16
|
+
```bash
|
|
17
|
+
micromamba create -f dev-environment.yml
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Activate the environment with:
|
|
21
|
+
```bash
|
|
22
|
+
micromamba activate pyb2d
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### pip
|
|
26
|
+
|
|
27
|
+
Install the python bindings with:
|
|
28
|
+
```bash
|
|
29
|
+
pip install .
|
|
30
|
+
```
|
|
31
|
+
### uv
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv pip install .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### raw cmake
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
mkdir build
|
|
42
|
+
cd build
|
|
43
|
+
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
|
|
44
|
+
-Dnanobind_DIR=$(python -m nanobind --cmake_dir)
|
|
45
|
+
make -j$(nproc)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Testing
|
|
50
|
+
## micromamba + uv / pip
|
|
51
|
+
Run the tests with:
|
|
52
|
+
```bash
|
|
53
|
+
pytest
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## raw cmake
|
|
57
|
+
Run the tests with:
|
|
58
|
+
```bash
|
|
59
|
+
PYTHONPATH=$(pwd)/src/module pytest
|
|
60
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
11
|
+
PYB2D3_SRC_DIR=$DIR
|
|
12
|
+
BUILD_TYPE=Release
|
|
13
|
+
|
|
14
|
+
if true; then
|
|
15
|
+
|
|
16
|
+
pushd $PYB2D3_SRC_DIR
|
|
17
|
+
mkdir -p build
|
|
18
|
+
pushd build
|
|
19
|
+
|
|
20
|
+
cmake .. \
|
|
21
|
+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
|
|
22
|
+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
|
23
|
+
-DFETCH_BOX2D=OFF \
|
|
24
|
+
-Dnanobind_DIR=$(python -m nanobind --cmake_dir)
|
|
25
|
+
|
|
26
|
+
make -j$(nproc)
|
|
27
|
+
popd
|
|
28
|
+
|
|
29
|
+
# PYTHONPATH="$PYTHONPATH:$PYB2D3_SRC_DIR/src/module" pytest
|
|
30
|
+
|
|
31
|
+
# PYTHONPATH="$PYTHONPATH:$PYB2D3_SRC_DIR/src/module" pytest benchmark
|
|
32
|
+
|
|
33
|
+
popd
|
|
34
|
+
|
|
35
|
+
fi
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# a conda env
|
|
2
|
+
name: pyb2d
|
|
3
|
+
channels:
|
|
4
|
+
- conda-forge
|
|
5
|
+
dependencies:
|
|
6
|
+
# Build tools
|
|
7
|
+
- cxx-compiler
|
|
8
|
+
- c-compiler
|
|
9
|
+
- cmake
|
|
10
|
+
- ninja
|
|
11
|
+
- scikit-build-core
|
|
12
|
+
- uv
|
|
13
|
+
# build deps
|
|
14
|
+
- python >=3.13
|
|
15
|
+
- nanobind
|
|
16
|
+
- box2d >=3.1.1
|
|
17
|
+
# run deps
|
|
18
|
+
- numpy
|
|
19
|
+
# Tests
|
|
20
|
+
- pytest
|
|
21
|
+
- pytest-sugarå
|
|
22
|
+
# utils
|
|
23
|
+
- pre-commit
|