pyb2d3 0.5.6__tar.gz → 0.7.2__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.7.2/.github/workflows/docs.yaml +84 -0
- pyb2d3-0.7.2/.github/workflows/emscripten.yaml +28 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/.gitignore +26 -1
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/.pre-commit-config.yaml +2 -2
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/CMakeLists.txt +8 -28
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/PKG-INFO +10 -1
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/README.md +30 -4
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyb2d3_sandbox/__init__.py +3 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyb2d3_sandbox/default_frontend.py +115 -0
- {pyb2d3-0.5.6/src/module/pyb2d3/samples/frontend → pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyb2d3_sandbox}/frontend_base.py +234 -276
- {pyb2d3-0.5.6/src/module/pyb2d3/samples → pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyb2d3_sandbox}/sample_base.py +39 -13
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyb2d3_sandbox/widgets.py +47 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox/pyproject.toml +26 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/__init__.py +1 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/debug_draw_offscreen.py +292 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/debug_draw_vanilla.py +288 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/init.js +294 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/ipycanvas_frontend.py +406 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/render_loop.py +31 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyb2d3_sandbox_ipycanvas/ui.py +395 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_ipycanvas/pyproject.toml +32 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/__init__.py +2 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/canvas_widget.js +557 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/canvas_widget.py +74 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/exp.ipynb +91 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/jupyter_debug_draw.py +263 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/jupyter_frontend.py +254 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/render_loop.py +43 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/ui.py +395 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyproject.toml +32 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/LICENSE-box2d-py +9 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/__init__.py +1 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/debug_draw_gl.py +248 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/draw.py +1063 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/opengl_frontend.py +548 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shader.py +128 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/background.fs +32 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/background.vs +10 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/circle.fs +23 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/circle.vs +29 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_capsule.fs +61 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_capsule.vs +44 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_circle.fs +56 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_circle.vs +34 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_polygon.fs +106 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_polygon.vs +79 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/shaders/solid_polygon_debug.vs +34 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyproject.toml +30 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_pygame/pyb2d3_sandbox_pygame/__init__.py +11 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_pygame/pyb2d3_sandbox_pygame/pygame_frontend.py +359 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_pygame/pyb2d3_sandbox_pygame/sample_to_video.py +123 -0
- pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_pygame/pyproject.toml +28 -0
- pyb2d3-0.7.2/dev-environment.yaml +55 -0
- pyb2d3-0.7.2/docs/.gitignore +10 -0
- pyb2d3-0.7.2/docs/Makefile +20 -0
- pyb2d3-0.7.2/docs/conf.py +61 -0
- pyb2d3-0.7.2/docs/doc_tools/__init__.py +109 -0
- pyb2d3-0.7.2/docs/index.rst +20 -0
- pyb2d3-0.7.2/docs/src/about_the_docs.rst +10 -0
- pyb2d3-0.7.2/docs/src/api.rst +11 -0
- pyb2d3-0.7.2/docs/src/differences.rst +96 -0
- pyb2d3-0.7.2/docs/src/installation.rst +40 -0
- pyb2d3-0.7.2/docs/src/samples/index.rst +14 -0
- pyb2d3-0.7.2/emscripten_forge/recipe/build_pkg.sh +17 -0
- pyb2d3-0.7.2/emscripten_forge/recipe/recipe.yaml.template +99 -0
- pyb2d3-0.7.2/emscripten_forge/recipe/test_pyb2d3.py +59 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/__init__.py +8 -1
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/billard.py +25 -35
- pyb2d3-0.7.2/examples/pyb2d3_samples/cast_ray_callback.py +148 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/chain_builder.py +8 -19
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/coupled_minigolf.py +17 -24
- pyb2d3-0.7.2/examples/pyb2d3_samples/examples_common/__init__.py +2 -0
- pyb2d3-0.7.2/examples/pyb2d3_samples/examples_common/ragdoll.py +481 -0
- pyb2d3-0.7.2/examples/pyb2d3_samples/examples_common/text.py +54 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/goo_game.py +47 -259
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/joints.py +2 -1
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/jump.py +11 -4
- pyb2d3-0.7.2/examples/pyb2d3_samples/meteor.py +108 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/mirror.py +9 -13
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/newtons_cradle.py +21 -2
- pyb2d3-0.7.2/examples/pyb2d3_samples/ragdoll.py +66 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/raycast.py +17 -15
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/shapes.py +6 -15
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/examples/pyb2d3_samples/soft_bodies.py +44 -13
- pyb2d3-0.7.2/examples/pyb2d3_samples/text.py +43 -0
- pyb2d3-0.7.2/examples/pyb2d3_samples/tumbler.py +128 -0
- pyb2d3-0.7.2/extra_licenses/LICENSE_BOX2D +21 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/pyproject.toml +17 -17
- pyb2d3-0.7.2/scripts/README.md +5 -0
- pyb2d3-0.7.2/scripts/build_emscripten_forge_pkg.sh +63 -0
- pyb2d3-0.7.2/scripts/build_lite_env.sh +45 -0
- pyb2d3-0.7.2/scripts/build_lite_page.sh +60 -0
- pyb2d3-0.7.2/scripts/examples_to_notebooks.sh +21 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_batch_api.cpp +0 -1
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_box2d_types.cpp +221 -44
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_box2d_wrapper_structs.cpp +30 -17
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_collision.cpp +80 -76
- pyb2d3-0.7.2/src/export_extras.cpp +107 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_math_functions.cpp +64 -6
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/main.cpp +2 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/module/pyb2d3/__init__.py +218 -36
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/py_debug_draw.hpp +9 -9
- pyb2d3-0.7.2/tests/__init__.py +10 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/tests/headless_test_frontend.py +63 -67
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/tests/test_samples.py +3 -0
- pyb2d3-0.5.6/dev-environment.yaml +0 -23
- pyb2d3-0.5.6/examples/notebooks/raycast.ipynb +0 -156
- pyb2d3-0.5.6/examples/pyb2d3_samples/tumbler.py +0 -183
- pyb2d3-0.5.6/src/module/pyb2d3/debug_draw/__init__.py +0 -1
- pyb2d3-0.5.6/src/module/pyb2d3/debug_draw/debug_draw.py +0 -36
- pyb2d3-0.5.6/src/module/pyb2d3/samples/__init__.py +0 -2
- pyb2d3-0.5.6/src/module/pyb2d3/samples/frontend/__init__.py +0 -22
- pyb2d3-0.5.6/src/module/pyb2d3/samples/frontend/default_frontend.py +0 -55
- pyb2d3-0.5.6/src/module/pyb2d3/samples/frontend/ipycanvas_frontend.py +0 -574
- pyb2d3-0.5.6/src/module/pyb2d3/samples/frontend/pygame_frontend.py +0 -342
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/.clang-format +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/.github/workflows/conda.yaml +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/.github/workflows/publish.yaml +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/LICENSE +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/build_pkg.sh +0 -0
- /pyb2d3-0.5.6/extra_licenses/README → /pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_jupyter/pyb2d3_sandbox_jupyter/canvas_widget.css +0 -0
- /pyb2d3-0.5.6/extra_licenses/LICENSE_BOX2D → /pyb2d3-0.7.2/companion_packages/pyb2d3_sandbox_opengl/pyb2d3_sandbox_opengl/LICENSE-Box2D +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/extra_licenses/LICENSE_NANOBIND +0 -0
- /pyb2d3-0.5.6/tests/__init__.py → /pyb2d3-0.7.2/extra_licenses/README +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/batch_api/batch_exporters.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/batch_api/ndarray_traits.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/batch_api.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/debug_draw.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/numpy_utils.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/py_chain_def.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/py_converter.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/threadpool.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/world_to_canvas.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/include/pyb2d3/wrapper_structs.hpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_threadpool.cpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/export_world_to_canvas.cpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/src/py_debug_draw.cpp +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/tests/conftest.py +0 -0
- {pyb2d3-0.5.6 → pyb2d3-0.7.2}/tests/test_pyb2d3.py +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
name: docs
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
jobs:
|
|
7
|
+
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout repo
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- uses: mamba-org/setup-micromamba@v2
|
|
20
|
+
with:
|
|
21
|
+
environment-file: dev-environment.yaml
|
|
22
|
+
init-shell: >-
|
|
23
|
+
bash
|
|
24
|
+
cache-environment: true
|
|
25
|
+
post-cleanup: 'all'
|
|
26
|
+
|
|
27
|
+
- name: build
|
|
28
|
+
shell: bash -el {0}
|
|
29
|
+
run: |
|
|
30
|
+
NANOBIND_CMAKE_DIR=$(python -m nanobind --cmake_dir)
|
|
31
|
+
mkdir -p build
|
|
32
|
+
cd build
|
|
33
|
+
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
|
|
34
|
+
-Dnanobind_DIR=$NANOBIND_CMAKE_DIR \
|
|
35
|
+
-DFETCH_BOX2D=OFF \
|
|
36
|
+
-DPYB2D_LINK_NANOBIND_STATICALLY=OFF \
|
|
37
|
+
|
|
38
|
+
cmake --build . --config Release
|
|
39
|
+
|
|
40
|
+
- name: emscripten-forge-package
|
|
41
|
+
shell: bash -el {0}
|
|
42
|
+
run: |
|
|
43
|
+
# skip tests here since there is a dedicated job for that
|
|
44
|
+
./scripts/build_emscripten_forge_pkg.sh --test=skip
|
|
45
|
+
|
|
46
|
+
- name: emscripten-forge-package
|
|
47
|
+
shell: bash -el {0}
|
|
48
|
+
run: |
|
|
49
|
+
./scripts/build_lite_env.sh
|
|
50
|
+
|
|
51
|
+
- name: convert examples to notebooks
|
|
52
|
+
shell: bash -el {0}
|
|
53
|
+
run: |
|
|
54
|
+
./scripts/examples_to_notebooks.sh
|
|
55
|
+
|
|
56
|
+
- name: build docs
|
|
57
|
+
shell: bash -el {0}
|
|
58
|
+
run: |
|
|
59
|
+
export PYTHONPATH=$(pwd)/src/module
|
|
60
|
+
cd docs
|
|
61
|
+
make html
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
- name: Upload artifact
|
|
65
|
+
uses: actions/upload-pages-artifact@v3
|
|
66
|
+
with:
|
|
67
|
+
path: docs/_build/html
|
|
68
|
+
|
|
69
|
+
deploy:
|
|
70
|
+
needs: build
|
|
71
|
+
if: github.ref == 'refs/heads/main'
|
|
72
|
+
permissions:
|
|
73
|
+
pages: write
|
|
74
|
+
id-token: write
|
|
75
|
+
|
|
76
|
+
environment:
|
|
77
|
+
name: github-pages
|
|
78
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
79
|
+
|
|
80
|
+
runs-on: ubuntu-latest
|
|
81
|
+
steps:
|
|
82
|
+
- name: Deploy to GitHub Pages
|
|
83
|
+
id: deployment
|
|
84
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
name: emscripten-forge-pkg
|
|
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: emscripten-forge
|
|
26
|
+
shell: bash -el {0}
|
|
27
|
+
run: |
|
|
28
|
+
./scripts/build_emscripten_forge_pkg.sh
|
|
@@ -42,7 +42,6 @@ __pycache__/
|
|
|
42
42
|
# bld directory
|
|
43
43
|
bld/
|
|
44
44
|
|
|
45
|
-
|
|
46
45
|
# some testfonts
|
|
47
46
|
Minecraft.ttf
|
|
48
47
|
|
|
@@ -70,3 +69,29 @@ benchmark/
|
|
|
70
69
|
# ignore custom scripts
|
|
71
70
|
run.sh
|
|
72
71
|
init.sh
|
|
72
|
+
|
|
73
|
+
.benchmarks/
|
|
74
|
+
.ruff_cache/
|
|
75
|
+
.pytest_cache/
|
|
76
|
+
.micromamba
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
# egg-info directories ALL OF THEM
|
|
80
|
+
**/*.egg-info/
|
|
81
|
+
|
|
82
|
+
# the notebooks atm
|
|
83
|
+
examples/notebooks/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# ignore the "output" directory for emscripten-forge builds
|
|
87
|
+
emscripten_forge/output/
|
|
88
|
+
|
|
89
|
+
# ignore the rendered recipe (ie where the template is replaced)
|
|
90
|
+
emscripten_forge/recipe/recipe.yaml
|
|
91
|
+
|
|
92
|
+
# ignore the variant file (we donwload it on the fly)
|
|
93
|
+
emscripten_forge/variant.yaml
|
|
94
|
+
|
|
95
|
+
emscripten_forge/recipe_src/
|
|
96
|
+
|
|
97
|
+
deploy
|
|
@@ -8,7 +8,7 @@ repos:
|
|
|
8
8
|
|
|
9
9
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
10
10
|
# Ruff version.
|
|
11
|
-
rev: v0.12.
|
|
11
|
+
rev: v0.12.7
|
|
12
12
|
hooks:
|
|
13
13
|
# Run the linter.
|
|
14
14
|
- id: ruff-check
|
|
@@ -17,7 +17,7 @@ repos:
|
|
|
17
17
|
- id: ruff-format
|
|
18
18
|
|
|
19
19
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
|
20
|
-
rev: v20.1.
|
|
20
|
+
rev: v20.1.8
|
|
21
21
|
hooks:
|
|
22
22
|
- id: clang-format
|
|
23
23
|
exclude_types: [javascript, json, python, yaml]
|
|
@@ -35,31 +35,7 @@ else()
|
|
|
35
35
|
endif()
|
|
36
36
|
|
|
37
37
|
if(EMSCRIPTEN)
|
|
38
|
-
|
|
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)
|
|
38
|
+
|
|
63
39
|
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
|
64
40
|
else()
|
|
65
41
|
# Find Python
|
|
@@ -86,6 +62,7 @@ SET(PY_SOURCES
|
|
|
86
62
|
src/export_math_functions.cpp
|
|
87
63
|
src/export_batch_api.cpp
|
|
88
64
|
src/export_world_to_canvas.cpp
|
|
65
|
+
src/export_extras.cpp
|
|
89
66
|
src/py_debug_draw.cpp
|
|
90
67
|
)
|
|
91
68
|
if(NOT PYB2D3_NO_THREADING)
|
|
@@ -97,11 +74,16 @@ endif()
|
|
|
97
74
|
if(NOT EMSCRIPTEN)
|
|
98
75
|
nanobind_add_module(_pyb2d3 STABLE_ABI ${PY_SOURCES})
|
|
99
76
|
else()
|
|
100
|
-
|
|
101
77
|
nanobind_add_module(_pyb2d3 ${PY_SOURCES})
|
|
102
78
|
endif()
|
|
103
79
|
|
|
104
80
|
|
|
81
|
+
# pass side module flags
|
|
82
|
+
if(EMSCRIPTEN)
|
|
83
|
+
set_target_properties(_pyb2d3 PROPERTIES LINK_FLAGS "-sSIDE_MODULE=1")
|
|
84
|
+
endif()
|
|
85
|
+
|
|
86
|
+
|
|
105
87
|
if(NOT PYB2D3_NO_THREADING)
|
|
106
88
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
107
89
|
find_package(Threads REQUIRED)
|
|
@@ -112,7 +94,6 @@ endif()
|
|
|
112
94
|
target_include_directories(_pyb2d3
|
|
113
95
|
PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
|
114
96
|
|
|
115
|
-
#add definitions
|
|
116
97
|
if(PYB2D3_NO_THREADING)
|
|
117
98
|
target_compile_definitions(_pyb2d3 PRIVATE PYB2D3_NO_THREADING)
|
|
118
99
|
endif()
|
|
@@ -142,7 +123,6 @@ if(DEFINED SKBUILD)
|
|
|
142
123
|
message(STATUS "using SKBUILD" ${SKBUILD})
|
|
143
124
|
install(TARGETS _pyb2d3 LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME})
|
|
144
125
|
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
126
|
else()
|
|
147
127
|
message(STATUS "not using SKBUILD")
|
|
148
128
|
endif()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyb2d3
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: python box2d bindings for box2d >= 3.1
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -13,4 +13,13 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
14
|
Requires-Python: >=3.9
|
|
15
15
|
Requires-Dist: numpy
|
|
16
|
+
Provides-Extra: frontend
|
|
17
|
+
Provides-Extra: frontend-pygame
|
|
18
|
+
Requires-Dist: pygame; extra == "frontend-pygame"
|
|
19
|
+
Provides-Extra: frontend-opengl
|
|
20
|
+
Requires-Dist: PyOpenGL; extra == "frontend-opengl"
|
|
21
|
+
Requires-Dist: PyOpenGL_accelerate; extra == "frontend-opengl"
|
|
22
|
+
Requires-Dist: imgui-bundle; extra == "frontend-opengl"
|
|
23
|
+
Provides-Extra: frontend-ipycanvas
|
|
24
|
+
Requires-Dist: ipycanvas; extra == "frontend-ipycanvas"
|
|
16
25
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
python bindings for Box2D 3
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
|
|
5
|
+
# Documentation
|
|
6
|
+
|
|
7
|
+
The documentation is avaialable at [derthorsten.github.io/pyb2d3](https://derthorsten.github.io/pyb2d3/).
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
# Installation
|
|
11
11
|
|
|
@@ -15,6 +15,8 @@ Install the python bindings with:
|
|
|
15
15
|
pip install pyb2d3
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
# conda based package
|
|
19
21
|
|
|
20
22
|
SOON!
|
|
@@ -60,3 +62,27 @@ That way, changes to the pure python code are immediately available without the
|
|
|
60
62
|
```bash
|
|
61
63
|
PYTHONPATH=$(pwd)/src/module pytest
|
|
62
64
|
```
|
|
65
|
+
|
|
66
|
+
# Testbed
|
|
67
|
+
|
|
68
|
+
To install the testbed use:
|
|
69
|
+
```bash
|
|
70
|
+
python -m pip install "pkg @ git+https://git@github.com/derthorsten/pyb2d3.git#subdirectory=companion_packages/pyb2d3_sandbox"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The testbed needs a frontend to run.
|
|
74
|
+
There are several frontends available, e.g.:
|
|
75
|
+
- opengl-based:
|
|
76
|
+
```bash
|
|
77
|
+
python -m pip install "pkg @ git+https://git@github.com/derthorsten/pyb2d3.git#subdirectory=companion_packages/pyb2d3_sandbox_opengl"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- pygame-based
|
|
81
|
+
```bash
|
|
82
|
+
python -m pip install "pkg @ git+https://git@github.com/derthorsten/pyb2d3.git#subdirectory=companion_packages/pyb2d3_sandbox_opengl"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- ipycanvas-based
|
|
86
|
+
```bash
|
|
87
|
+
python -m pip install "pkg @ git+https://git@github.com/derthorsten/pyb2d3.git#subdirectory=companion_packages/pyb2d3_sandbox_ipycanvas"
|
|
88
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
_CachedDefaultFrontend = None
|
|
5
|
+
|
|
6
|
+
has_pyjs = False
|
|
7
|
+
try:
|
|
8
|
+
import pyjs # noqa
|
|
9
|
+
|
|
10
|
+
has_pyjs = True
|
|
11
|
+
except ImportError:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def is_notebook() -> bool:
|
|
16
|
+
try:
|
|
17
|
+
shell = get_ipython().__class__.__name__
|
|
18
|
+
if shell == "ZMQInteractiveShell" or shell == "XPythonShell":
|
|
19
|
+
return True # Jupyter notebook or qtconsole
|
|
20
|
+
elif shell == "TerminalInteractiveShell":
|
|
21
|
+
return False # Terminal running IPython
|
|
22
|
+
else:
|
|
23
|
+
return False # Other type (?)
|
|
24
|
+
except NameError:
|
|
25
|
+
return False # Probably standard Python interpreter
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def compare_case_insensitive(a: str, b: str) -> bool:
|
|
29
|
+
"""
|
|
30
|
+
Compare two strings case-insensitively.
|
|
31
|
+
"""
|
|
32
|
+
return a.lower() == b.lower()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_default_frontend():
|
|
36
|
+
global _CachedDefaultFrontend
|
|
37
|
+
if _CachedDefaultFrontend is not None:
|
|
38
|
+
return _CachedDefaultFrontend
|
|
39
|
+
|
|
40
|
+
# check for certain env variables
|
|
41
|
+
PYB2D3_SANDBOX_DEFAULT_FRONTEND = os.environ.get("PYB2D3_SANDBOX_DEFAULT_FRONTEND", None)
|
|
42
|
+
if PYB2D3_SANDBOX_DEFAULT_FRONTEND:
|
|
43
|
+
if compare_case_insensitive(PYB2D3_SANDBOX_DEFAULT_FRONTEND, "OPENGL"):
|
|
44
|
+
from pyb2d3_sandbox_opengl import OpenglFrontend
|
|
45
|
+
|
|
46
|
+
_CachedDefaultFrontend = OpenglFrontend
|
|
47
|
+
return _CachedDefaultFrontend
|
|
48
|
+
elif compare_case_insensitive(PYB2D3_SANDBOX_DEFAULT_FRONTEND, "PYGAME"):
|
|
49
|
+
from pyb2d3_sandbox_pygame import PygameFrontend
|
|
50
|
+
|
|
51
|
+
_CachedDefaultFrontend = PygameFrontend
|
|
52
|
+
return _CachedDefaultFrontend
|
|
53
|
+
elif compare_case_insensitive(PYB2D3_SANDBOX_DEFAULT_FRONTEND, "IPYCANVAS"):
|
|
54
|
+
from pyb2d3_sandbox_ipycanvas import IpycanvasFrontend
|
|
55
|
+
|
|
56
|
+
_CachedDefaultFrontend = IpycanvasFrontend
|
|
57
|
+
return _CachedDefaultFrontend
|
|
58
|
+
|
|
59
|
+
tracebacks = []
|
|
60
|
+
|
|
61
|
+
if not is_notebook():
|
|
62
|
+
# Check if OpenglFrontend is available
|
|
63
|
+
has_opengl_frontend = True
|
|
64
|
+
try:
|
|
65
|
+
from pyb2d3_sandbox_opengl import OpenglFrontend
|
|
66
|
+
except ImportError:
|
|
67
|
+
has_opengl_frontend = False
|
|
68
|
+
tracebacks.append(traceback.format_exc())
|
|
69
|
+
if has_opengl_frontend:
|
|
70
|
+
_CachedDefaultFrontend = OpenglFrontend
|
|
71
|
+
return _CachedDefaultFrontend
|
|
72
|
+
|
|
73
|
+
# check if PygameFrontend is available
|
|
74
|
+
has_pygame_frontend = True
|
|
75
|
+
try:
|
|
76
|
+
from pyb2d3_sandbox_pygame import PygameFrontend
|
|
77
|
+
except ImportError:
|
|
78
|
+
has_pygame_frontend = False
|
|
79
|
+
tracebacks.append(traceback.format_exc())
|
|
80
|
+
if has_pygame_frontend:
|
|
81
|
+
_CachedDefaultFrontend = PygameFrontend
|
|
82
|
+
return _CachedDefaultFrontend
|
|
83
|
+
|
|
84
|
+
raise ImportError(f"""No default frontend available. Please install either pyb2d3-sandbox-opengl or pyb2d3-sandbox-pygame.
|
|
85
|
+
Tracebacks of the import errors:
|
|
86
|
+
{"".join(tracebacks)}""")
|
|
87
|
+
|
|
88
|
+
else:
|
|
89
|
+
# for vanilla-Jupyter we use "jupyter-frontend"
|
|
90
|
+
if not has_pyjs:
|
|
91
|
+
has_jupyter_frontend = True
|
|
92
|
+
try:
|
|
93
|
+
from pyb2d3_sandbox_jupyter import JupyterFrontend
|
|
94
|
+
except ImportError:
|
|
95
|
+
has_jupyter_frontend = False
|
|
96
|
+
tracebacks.append(traceback.format_exc())
|
|
97
|
+
if has_jupyter_frontend:
|
|
98
|
+
_CachedDefaultFrontend = JupyterFrontend
|
|
99
|
+
return _CachedDefaultFrontend
|
|
100
|
+
# for lite-Jupyter we use "ipycanvas-frontend"
|
|
101
|
+
else:
|
|
102
|
+
# Check if IpycanvasFrontend is available
|
|
103
|
+
has_ipycanvas_frontend = True
|
|
104
|
+
try:
|
|
105
|
+
from pyb2d3_sandbox_ipycanvas import IpycanvasFrontend
|
|
106
|
+
except ImportError:
|
|
107
|
+
has_ipycanvas_frontend = False
|
|
108
|
+
tracebacks.append(traceback.format_exc())
|
|
109
|
+
if has_ipycanvas_frontend:
|
|
110
|
+
_CachedDefaultFrontend = IpycanvasFrontend
|
|
111
|
+
return _CachedDefaultFrontend
|
|
112
|
+
|
|
113
|
+
raise ImportError(f"""No default frontend available. Please install pyb2d3-sandbox-ipycanvas for Jupyter notebook support.
|
|
114
|
+
Tracebacks of the import errors:
|
|
115
|
+
{"".join(tracebacks)}""")
|