Skip to content

Commit becb423

Browse files
Enable pymomentum on Windows
1 parent 84cd3a4 commit becb423

File tree

9 files changed

+4803
-4529
lines changed

9 files changed

+4803
-4529
lines changed

.github/workflows/ci_ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
environments: ${{ matrix.pixi_env }}
101101
cache: true
102102

103-
- name: Build PyMomentum
103+
- name: Build and test PyMomentum
104104
run: |
105105
pixi run -e ${{ matrix.pixi_env }} test_py
106106

.github/workflows/ci_windows.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- "**/website/**"
1414

1515
jobs:
16-
build:
16+
momentum:
1717
name: cpp-${{ matrix.mode == '' && 'opt' || 'dev' }}-win
1818
runs-on: windows-latest
1919
strategy:
@@ -43,3 +43,19 @@ jobs:
4343
--build momentum/examples/hello_world/build `
4444
--config Release `
4545
--parallel
46+
47+
pymomentum:
48+
name: py-win
49+
runs-on: windows-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Set up pixi
55+
uses: prefix-dev/[email protected]
56+
with:
57+
cache: true
58+
59+
- name: Build and test PyMomentum
60+
run: |
61+
pixi run test_py

momentum/io/urdf/urdf_io.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ bool loadUrdfSkeletonRecursive(
8282
joint.name = urdfLink->name; // Use link name or joint name?
8383
joint.parent = parentJointId;
8484

85-
const size_t jointId = data.skeleton.joints.size();
86-
const size_t jointParamsBaseIndex = jointId * kParametersPerJoint;
87-
const size_t modelParamsBaseIndex = data.totalDoFs;
85+
const Eigen::Index jointId = data.skeleton.joints.size();
86+
const Eigen::Index jointParamsBaseIndex = jointId * kParametersPerJoint;
87+
const Eigen::Index modelParamsBaseIndex = data.totalDoFs;
8888

8989
//---------------------------
9090
// Parse Parameter transform

pixi.lock

+4,729-4,503
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

+22-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ms-gsl = ">=4.1.0,<5"
4242
nlohmann_json = ">=3.11.3,<4"
4343
openfbx = ">=0.9,<0.10"
4444
openssl = ">=3.4.1,<4"
45+
pytorch = ">=2.6.0,<3"
4546
re2 = ">=2024.7.2,<2025"
4647
spdlog = ">=1.15.1,<2"
4748
tracy-profiler-client = ">=0.11.1,<0.12"
@@ -132,6 +133,23 @@ install = { cmd = "cmake --build build/$PIXI_ENVIRONMENT_NAME/cpp/release -j --t
132133
"build",
133134
] }
134135
tracy = { cmd = "tracy-profiler" }
136+
test_py = { cmd = """
137+
pytest \
138+
pymomentum/test/test_closest_points.py \
139+
pymomentum/test/test_fbx.py \
140+
pymomentum/test/test_parameter_transform.py \
141+
pymomentum/test/test_quaternion.py \
142+
pymomentum/test/test_skel_state.py \
143+
pymomentum/test/test_skeleton.py
144+
""", env = { MOMENTUM_MODELS_PATH = "momentum/" }, depends-on = [
145+
"build_py",
146+
] }
147+
doc_py = { cmd = "sphinx-build -a -E -b html pymomentum/doc build/python_api_doc", depends-on = [
148+
"build_py",
149+
] }
150+
open_doc_py = { cmd = "open build/python_api_doc/index.html", depends-on = [
151+
"doc_py",
152+
] }
135153

136154
#===========
137155
# linux-64
@@ -141,7 +159,6 @@ tracy = { cmd = "tracy-profiler" }
141159
nvtx-c = ">=3.1.0" # TODO: Add to pytorch as run dep
142160

143161
[target.linux-64.dependencies]
144-
pytorch = ">=2.6.0,<3"
145162
sysroot_linux-64 = ">=2.28"
146163

147164
[target.linux-64.tasks]
@@ -226,7 +243,6 @@ open_doc_py = { cmd = "open build/python_api_doc/index.html", depends-on = [
226243
[target.osx.build-dependencies]
227244

228245
[target.osx.dependencies]
229-
pytorch = ">=2.6.0,<3"
230246

231247
[target.osx.tasks]
232248
build_py = { cmd = "pip install . -vv", env = { CMAKE_ARGS = """
@@ -252,7 +268,6 @@ open_doc_py = { cmd = "open build/python_api_doc/index.html", depends-on = [
252268
[target.osx-arm64.build-dependencies]
253269

254270
[target.osx-arm64.dependencies]
255-
pytorch = ">=2.6.0,<3"
256271

257272
[target.osx-arm64.tasks]
258273
build_py = { cmd = "pip install . -vv", env = { CMAKE_ARGS = """
@@ -340,6 +355,10 @@ install = { cmd = "cmake --build build/$PIXI_ENVIRONMENT_NAME/cpp -j --target in
340355
"build",
341356
] }
342357
tracy = { cmd = "tracy-profiler.exe" }
358+
build_py = { cmd = "pip install . -vv", env = { CMAKE_ARGS = """
359+
-DMOMENTUM_BUILD_IO_FBX=$MOMENTUM_BUILD_IO_FBX \
360+
-DMOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD
361+
""", MOMENTUM_BUILD_IO_FBX = "OFF", MOMENTUM_ENABLE_SIMD = "ON" } }
343362

344363
#==============
345364
# Feature: CPU

pymomentum/CMakeLists.txt

+21-14
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,31 @@
77
# Find dependencies
88
#===============================================================================
99

10+
if(NOT DEFINED ENV{CONDA_PREFIX})
11+
message(FATAL_ERROR
12+
"CONDA_PREFIX is not set. pymomentum currently only supports building"
13+
"with Conda/Pixi. Please ensure you are using a Conda or Pixi environment."
14+
)
15+
endif()
16+
1017
set(ENV{NVTOOLSEXT_PATH} "$ENV{CONDA_PREFIX}/include")
1118

12-
find_package(ATen CONFIG REQUIRED
13-
HINTS
14-
$ENV{CONDA_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/torch/
15-
)
19+
if(WIN32)
20+
set(libtorch_base_path $ENV{CONDA_PREFIX}/Lib/site-packages/torch)
21+
else()
22+
set(libtorch_base_path $ENV{CONDA_PREFIX})
23+
endif()
1624

17-
find_package(Torch CONFIG REQUIRED
18-
HINTS
19-
$ENV{CONDA_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/torch/
20-
)
25+
if(NOT EXISTS "${libtorch_base_path}")
26+
message(FATAL_ERROR
27+
"PyTorch not found in the expected location: ${libtorch_base_path}"
28+
"Please ensure PyTorch is installed in your Conda/Pixi environment."
29+
)
30+
endif()
2131

22-
find_library(torch_python
23-
NAMES torch_python
24-
HINTS
25-
$ENV{CONDA_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/torch/lib/
26-
REQUIRED
27-
)
32+
find_package(ATen CONFIG REQUIRED HINTS ${libtorch_base_path})
33+
find_package(Torch CONFIG REQUIRED HINTS ${libtorch_base_path})
34+
find_library(torch_python NAMES torch_python HINTS ${libtorch_base_path}/lib/ REQUIRED)
2835

2936
#===============================================================================
3037
# Find build dependencies

pymomentum/tensor_momentum/tensor_skeleton_state.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ void computeSkelStateBackward(
112112
for (int d = 0; d < momentum::kParametersPerJoint; ++d) {
113113
Eigen::VectorX<JetType> jointParams_cur =
114114
jointParameters
115-
.template segment(
116-
kParametersPerJoint * curJoint, kParametersPerJoint)
115+
.segment(kParametersPerJoint * curJoint, kParametersPerJoint)
117116
.template cast<JetType>();
118117
jointParams_cur(d).v[0] = 1;
119118

@@ -189,8 +188,7 @@ void computeLocalSkelStateBackward(
189188
for (int d = 0; d < momentum::kParametersPerJoint; ++d) {
190189
Eigen::VectorX<JetType> jointParams_cur =
191190
jointParameters
192-
.template segment(
193-
kParametersPerJoint * iJoint, kParametersPerJoint)
191+
.segment(kParametersPerJoint * iJoint, kParametersPerJoint)
194192
.template cast<JetType>();
195193
jointParams_cur(d).v[0] = 1;
196194

pymomentum/tensor_utility/tensor_utility.h

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#include <ATen/ATen.h>
1111
#include <torch/torch.h>
1212
#include <Eigen/Core>
13+
14+
#if defined(_MSC_VER)
15+
#include <BaseTsd.h>
16+
using ssize_t = SSIZE_T;
17+
#endif
18+
1319
#include <optional>
1420
#include <unordered_map>
1521

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmake.args = [
2727
"-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON",
2828
"-DMOMENTUM_USE_SYSTEM_PYBIND11=OFF",
2929
"-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON",
30+
"-DUSE_SYSTEM_NVTX=ON",
3031
]
3132
minimum-version = "0.10"
3233
sdist.exclude = [
@@ -51,4 +52,5 @@ cmake.args = [
5152
"-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON",
5253
"-DMOMENTUM_USE_SYSTEM_PYBIND11=ON",
5354
"-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON",
55+
"-DUSE_SYSTEM_NVTX=ON",
5456
]

0 commit comments

Comments
 (0)