Skip to content

Commit e8f16e2

Browse files
authored
docs: remove setup.py mentions, mention presets (#5677)
* docs: remove setup.py mentions, mention presets Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update .github/CONTRIBUTING.md --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 07d028f commit e8f16e2

File tree

3 files changed

+32
-83
lines changed

3 files changed

+32
-83
lines changed

.github/CONTRIBUTING.md

Lines changed: 31 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ the following rules to make the process as smooth as possible:
2525
* Make a new branch for every feature you're working on.
2626
* Make small and clean pull requests that are easy to review but make sure they
2727
do add value by themselves.
28-
* Add tests for any new functionality and run the test suite (`cmake --build
29-
build --target pytest`) to ensure that no existing features break.
28+
* Add tests for any new functionality and run the test suite (`cmake --workflow
29+
venv`) to ensure that no existing features break.
3030
* Please run [`pre-commit`][pre-commit] to check your code matches the
3131
project style. (Note that `gawk` is required.) Use `pre-commit run
3232
--all-files` before committing (or use installed-mode, check pre-commit docs)
@@ -84,8 +84,8 @@ To setup an ideal development environment, run the following commands on a
8484
system with CMake 3.15+:
8585

8686
```bash
87-
python3 -m venv venv
88-
source venv/bin/activate
87+
python3 -m venv .venv
88+
source .venv/bin/activate
8989
pip install -r tests/requirements.txt
9090
cmake -S . -B build -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON
9191
cmake --build build -j4
@@ -98,11 +98,31 @@ Tips:
9898
will be ignored by git.
9999
* If you don't have CMake 3.15+, just add "cmake" to the pip install command.
100100
* You can use `-DPYBIND11_FINDPYTHON=ON` to use FindPython.
101-
* In classic mode, you may need to set `-DPYTHON_EXECUTABLE=/path/to/python`.
102-
FindPython uses `-DPython_ROOT_DIR=/path/to` or
101+
* For a specific Python, you can use `-DPython_ROOT_DIR=/path/to` or
103102
`-DPython_EXECUTABLE=/path/to/python`.
104103

105-
### Configuration options
104+
## CMake presets
105+
106+
We also support CMake presets. If you have [uv](https://docs.astral.sh/uv/),
107+
you can use:
108+
109+
```bash
110+
cmake --workflow venv
111+
```
112+
113+
to setup a venv and run all tests. You can break this up into components
114+
if you want to use a specific version of Python (or any other config option) or
115+
build only one of the valid targets (listed below).
116+
117+
```bash
118+
cmake --preset venv -DPYBIND11_CREATE_WITH_UV=3.13t
119+
cmake --build --preset venv
120+
cmake --build --preset testsvenv -t cpptest
121+
```
122+
123+
The `default` preset will use an existing venv or Python install.
124+
125+
## Configuration options
106126

107127
In CMake, configuration options are given with "-D". Options are stored in the
108128
build directory, in the `CMakeCache.txt` file, so they are remembered for each
@@ -299,85 +319,15 @@ files inside the package, that you get access to via functions in the package,
299319
and a `pybind11-global` package that can be included via `pybind11[global]` if
300320
you want the more invasive but discoverable file locations.
301321

302-
If you want to install or package the GitHub source, it is best to have Pip 10
303-
or newer on Windows, macOS, or Linux (manylinux1 compatible, includes most
304-
distributions). You can then build the SDists, or run any procedure that makes
305-
SDists internally, like making wheels or installing.
306-
322+
If you want to package the GitHub source for the "global" package, you need
323+
to use nox. Normal packaging will only make the normal package.
307324

308-
```bash
309-
# Editable development install example
310-
python3 -m pip install -e .
311-
```
312-
313-
Since Pip itself does not have an `sdist` command (it does have `wheel` and
314-
`install`), you may want to use the upcoming `build` package:
315-
316-
```bash
317-
python3 -m pip install build
318-
319-
# Normal package
320-
python3 -m build -s .
321-
322-
# Global extra
323-
PYBIND11_GLOBAL_SDIST=1 python3 -m build -s .
324-
```
325-
326-
If you want to use the classic "direct" usage of `python setup.py`, you will
327-
need CMake 3.15+ and either `make` or `ninja` preinstalled (possibly via `pip
328-
install cmake ninja`), since directly running Python on `setup.py` cannot pick
329-
up and install `pyproject.toml` requirements. As long as you have those two
330-
things, though, everything works the way you would expect:
331325

332326
```bash
333-
# Normal package
334-
python3 setup.py sdist
335-
336-
# Global extra
337-
PYBIND11_GLOBAL_SDIST=1 python3 setup.py sdist
327+
nox -s build
328+
nox -s build_global
338329
```
339330

340-
A detailed explanation of the build procedure design for developers wanting to
341-
work on or maintain the packaging system is as follows:
342-
343-
#### 1. Building from the source directory
344-
345-
When you invoke any `setup.py` command from the source directory, including
346-
`pip wheel .` and `pip install .`, you will activate a full source build. This
347-
is made of the following steps:
348-
349-
1. If the tool is PEP 518 compliant, like Pip 10+, it will create a temporary
350-
virtual environment and install the build requirements (mostly CMake) into
351-
it. (if you are not on Windows, macOS, or a manylinux compliant system, you
352-
can disable this with `--no-build-isolation` as long as you have CMake 3.15+
353-
installed)
354-
2. The environment variable `PYBIND11_GLOBAL_SDIST` is checked - if it is set
355-
and truthy, this will be make the accessory `pybind11-global` package,
356-
instead of the normal `pybind11` package. This package is used for
357-
installing the files directly to your environment root directory, using
358-
`pybind11[global]`.
359-
2. `setup.py` reads the version from `pybind11/_version.py` and verifies it
360-
matches `includes/pybind11/detail/common.h`.
361-
3. CMake is run with `-DCMAKE_INSTALL_PREIFX=pybind11`. Since the CMake install
362-
procedure uses only relative paths and is identical on all platforms, these
363-
files are valid as long as they stay in the correct relative position to the
364-
includes. `pybind11/share/cmake/pybind11` has the CMake files, and
365-
`pybind11/include` has the includes. The build directory is discarded.
366-
4. Simpler files are placed in the SDist: `tools/setup_*.py.in`,
367-
`tools/pyproject.toml` (`main` or `global`)
368-
5. The package is created by running the setup function in the
369-
`tools/setup_*.py`. `setup_main.py` fills in Python packages, and
370-
`setup_global.py` fills in only the data/header slots.
371-
6. A context manager cleans up the temporary CMake install directory (even if
372-
an error is thrown).
373-
374-
### 2. Building from SDist
375-
376-
Since the SDist has the rendered template files in `tools` along with the
377-
includes and CMake files in the correct locations, the builds are completely
378-
trivial and simple. No extra requirements are required. You can even use Pip 9
379-
if you really want to.
380-
381331

382332
[pre-commit]: https://pre-commit.com
383333
[clang-format]: https://clang.llvm.org/docs/ClangFormat.html

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ if(PYBIND11_MASTER_PROJECT)
179179
endif()
180180
endif()
181181

182-
# NB: when adding a header don't forget to also add it to setup.py
183182
set(PYBIND11_HEADERS
184183
include/pybind11/detail/class.h
185184
include/pybind11/detail/common.h

docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ New and removed platforms:
285285
[#5304](https://github.com/pybind/pybind11/pull/5304)
286286
- Use scikit-build-core for the build backend for the PyPI `pybind11`.
287287
The CMake generation has been moved to the sdist-\>wheel step.
288-
`PYBIND11_GLOBAL_PREFIX` has been removed.
288+
`PYBIND11_GLOBAL_SDIST` has been removed.
289289
[#5598](https://github.com/pybind/pybind11/pull/5598)
290290

291291
## Version 2.13.6 (September 13, 2024)

0 commit comments

Comments
 (0)