@@ -64,6 +64,12 @@ pip-install-dependency-groups dev
6464pip install -ve.
6565```
6666
67+ Or if you use uv:
68+
69+ ``` bash
70+ uv sync
71+ ```
72+
6773<details ><summary >Optional: External Jupyter kernel (click to expand)</summary >
6874
6975You can set up a kernel for external Jupyter then deactivate your environment:
@@ -87,16 +93,11 @@ a rebuild.
8793CMake is common for C++ development, and ties nicely to many C++ tools, like
8894IDEs. If you want to use it for building, you can. Make a build directory and
8995run 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
9197help installing the latest CMake version, [ visit this
9298page] ( https://cliutils.gitlab.io/modern-cmake/chapters/intro/installing.html ) ;
9399one option is to use pip to install CMake.
94100
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-
100101You have three options for running code in python:
101102
1021031 . Run from the build directory (only works with some commands, like `python -m
@@ -105,25 +106,20 @@ pytest`, and not others, like `pytest`
1051063 . Set ` CMAKE_INSTALL_PREFIX ` to your site-packages and install (recommended
106107 for virtual environments).
107108
108- Here is the recommendation for a CMake install:
109+ Here is the recommendation for a CMake install, using uv :
109110
110111``` 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))" )
120118```
121119
122120Note that option 3 will require reinstalling if the python files change, while
123121options 1-2 will not if you have a recent version of CMake (symlinks are made).
124122
125- This could be simplified if pybind11 supported the new CMake FindPython tools.
126-
127123## Testing
128124
129125Run the unit tests (requires pytest and NumPy).
@@ -132,8 +128,7 @@ Run the unit tests (requires pytest and NumPy).
132128python3 -m pytest
133129```
134130
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).
137132
138133The build requires ` setuptools_scm ` . The tests require ` numpy ` , ` pytest ` , and
139134` pytest-benchmark ` . ` pytest-sugar ` adds some nice formatting.
0 commit comments