@@ -64,6 +64,12 @@ pip-install-dependency-groups dev
64
64
pip install -ve.
65
65
```
66
66
67
+ Or if you use uv:
68
+
69
+ ``` bash
70
+ uv sync
71
+ ```
72
+
67
73
<details ><summary >Optional: External Jupyter kernel (click to expand)</summary >
68
74
69
75
You can set up a kernel for external Jupyter then deactivate your environment:
@@ -87,16 +93,11 @@ a rebuild.
87
93
CMake is common for C++ development, and ties nicely to many C++ tools, like
88
94
IDEs. If you want to use it for building, you can. Make a build directory and
89
95
run CMake. If you have a specific Python you want to use, add
90
- ` -DPYTHON_EXECUTABLE =$(which python) ` or similar to the CMake line. If you need
96
+ ` -DPython_EXECUTABLE =$(which python) ` or similar to the CMake line. If you need
91
97
help installing the latest CMake version, [ visit this
92
98
page] ( https://cliutils.gitlab.io/modern-cmake/chapters/intro/installing.html ) ;
93
99
one option is to use pip to install CMake.
94
100
95
- > Note: Since setuptools uses a subdirectory called ` build ` , it is _ slightly_
96
- > better to avoid making your CMake directory ` build ` as well. Also, you will
97
- > often have multiple CMake directories (` build-release ` , ` build-debug ` , etc.),
98
- > so avoiding the descriptive name ` build ` is not a bad idea.
99
-
100
101
You have three options for running code in python:
101
102
102
103
1 . Run from the build directory (only works with some commands, like `python -m
@@ -105,25 +106,20 @@ pytest`, and not others, like `pytest`
105
106
3 . Set ` CMAKE_INSTALL_PREFIX ` to your site-packages and install (recommended
106
107
for virtual environments).
107
108
108
- Here is the recommendation for a CMake install:
109
+ Here is the recommendation for a CMake install, using uv :
109
110
110
111
``` bash
111
- python3 -m venv env_cmake
112
- source ./env_cmake/bin/activate
113
- pip install dependency-groups
114
- pip-install-dependency-groups dev
115
- cmake -S . -B build-debug \
116
- -GNinja \
117
- -DCMAKE_INSTALL_PREFIX=$( python -c " import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False))" )
118
- cmake --build build-debug -j4
119
- cmake --install build-debug # Option 3 only
112
+ uv venv
113
+ uv pip install --group dev
114
+ cmake --workflow default
115
+
116
+ # Option 3 only:
117
+ cmake --install --preset default --prefix $( python -c " import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False))" )
120
118
```
121
119
122
120
Note that option 3 will require reinstalling if the python files change, while
123
121
options 1-2 will not if you have a recent version of CMake (symlinks are made).
124
122
125
- This could be simplified if pybind11 supported the new CMake FindPython tools.
126
-
127
123
## Testing
128
124
129
125
Run the unit tests (requires pytest and NumPy).
@@ -132,8 +128,7 @@ Run the unit tests (requires pytest and NumPy).
132
128
python3 -m pytest
133
129
```
134
130
135
- For CMake, you can also use the ` test ` target from anywhere, or use `python3 -m
136
- pytest` or ` ctest` from the build directory.
131
+ For CMake, you can use ` ctest --preset default ` (the workflow above will run the tests).
137
132
138
133
The build requires ` setuptools_scm ` . The tests require ` numpy ` , ` pytest ` , and
139
134
` pytest-benchmark ` . ` pytest-sugar ` adds some nice formatting.
0 commit comments