Skip to content

Commit b48b99a

Browse files
committed
Update documentation
1 parent 0d0920a commit b48b99a

17 files changed

+302
-427
lines changed

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020 Dustin Spicuzza <[email protected]>, All rights reserved.
1+
Copyright (c) 2020-2025 Dustin Spicuzza <[email protected]>, All rights reserved.
22

33
Redistribution and use in source and binary forms, with or without
44
modification, are permitted provided that the following conditions are met:

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
semiwrap
22
========
33

4-
This is a build tool intended to be generally useful for any python project
5-
that has binary dependencies. It is especially designed to meet the needs
6-
of RobotPy's various wrapper libraries, chiefly around:
4+
semiwrap is a build tool that makes it simpler to wrap C/C++ libraries with
5+
pybind11 by automating large portions of the wrapping process and handling some
6+
of the more complex aspects of creating pybind11 based wrappers (especially with
7+
trampolines to allow inheriting from C++ classes from Python).
78

8-
* Managing upstream binary dependencies
9-
* Autogenerating pybind11 wrappers around those dependencies
10-
* Building wheels from those generated wrappers
9+
semiwrap includes a hatchling plugin that autogenerates `meson.build` files that
10+
can be built using meson, and those build files parse your wrapped headers and
11+
generate/compile pybind11 based wrappers into python extension modules.
1112

1213
Requires Python 3.8+
1314

@@ -21,8 +22,8 @@ Author
2122

2223
Dustin Spicuzza is the primary author of semiwrap.
2324

24-
Semiwrap is a direct decendant of the robotpy-build project, and is
25-
culmination of many years of experimentation with automated wrapper
26-
generation by members of the RobotPy community.
25+
Semiwrap is a direct decendant of the robotpy-build project, and is culmination
26+
of many years of experimentation with automated wrapper generation by members of
27+
the RobotPy community.
2728

2829
semiwrap is available under the BSD 3-clause license.

docs/autowrap.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Automated C++ header wrapping
55
=============================
66

7-
robotpy-build can be told to parse C/C++ headers and automatically generate
7+
semiwrap can be told to parse C/C++ headers and automatically generate
88
:std:doc:`pybind11 <pybind11:basics>` wrappers around the functions
99
and objects found in that header.
1010

@@ -15,9 +15,9 @@ and objects found in that header.
1515
C++ Features
1616
------------
1717

18-
robotpy-build uses a pure python C++ parser and macro processor to attempt to
18+
semiwrap uses a pure python C++ parser and macro processor to attempt to
1919
parse header files. As a result, a full AST of the header files is not created.
20-
This means particularly opaque code might confuse the parser, as robotpy-build
20+
This means particularly opaque code might confuse the parser, as semiwrap
2121
only receives the names, not the actual type information.
2222

2323
However, most basic features typically work without needing to coerce the
@@ -34,6 +34,7 @@ generator into working correctly, including:
3434
* final classes/methods - cannot be overridden from Python code
3535
* Enumerations
3636
* Global variables
37+
* Many many more weird edge cases too
3738

3839
Additionally, the following features are supported, but require some manual
3940
intervention:
@@ -46,22 +47,22 @@ to your package in ``pyproject.toml``:
4647

4748
.. code-block:: toml
4849
49-
[tool.robotpy-build.wrappers."MYPACKAGE".autogen_headers]
50+
[tool.semiwrap.extension_modules."PACKAGE.NAME".headers]
5051
demo = "demo.h"
5152
5253
That causes ``demo.h`` to be parsed and wrapped.
5354

5455
.. note:: If you're importing a large number of headers, the
55-
``robotpy-build scan-headers`` tool can generate this for you
56+
``semiwrap scan-headers`` tool can generate this list for you
5657
automatically.
5758

5859
Documentation
5960
-------------
6061

61-
robotpy-build will find doxygen documentation comments on many types of elements
62-
and use sphinxify to translate them into python docstrings. All elements that
63-
support documentation strings can have their docstrings set explicitly using
64-
a ``doc`` value in the YAML file.
62+
semiwrap will find doxygen documentation comments on many types of elements
63+
and use sphinxify to translate them into python docstrings. If this is not
64+
sufficient, all elements that support documentation strings can have their
65+
docstrings set explicitly using a ``doc`` value in the YAML file.
6566

6667
.. code-block:: yaml
6768

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# -- Project information -----------------------------------------------------
2727

2828
project = "semiwrap"
29-
copyright = "2020, RobotPy Development Team"
29+
copyright = "2025, RobotPy Development Team"
3030
author = "RobotPy Development Team"
3131

3232
# The full version, including alpha/beta/rc tags

docs/config/autowrap.rst

+29-27
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,68 @@
44
Generator Customization
55
=======================
66

7-
Because robotpy-build's code generation is intended to be a semi-automated
7+
Because semiwrap's code generation is intended to be a semi-automated
88
process (except for simple C++ code), a rich set of per-{class/function/parameter}
99
configuration options can be specified in per-file YAML configurations.
1010

1111
Additionally, some headers are too complex for the autogenerator to
1212
completely process, so when this occurs you must manually specify required
1313
information in the YAML file.
1414

15-
Most files generated by robotpy-build are customizable.
15+
Most files generated by semiwrap are customizable.
1616

17-
.. note:: robotpy-build is designed for the RobotPy project and may contain
17+
.. note:: semiwrap is designed for the RobotPy project and may contain
1818
defaults that aren't appropriate for all projects. If you find that
1919
you need more customization, file an issue on github and let's talk
2020
about it!
2121

2222
Location of customization file
2323
------------------------------
2424

25-
In your ``pyproject.toml``, you can specify either a single YAML file with
26-
customizations, or you can specify a directory that robotpy-build will search
27-
for YAML files.
28-
29-
Single file:
30-
31-
.. code-block:: toml
32-
33-
[tool.robotpy-build.wrappers."PACKAGENAME"]
34-
generation_data = "gen/data.yml"
35-
36-
Multiple files:
25+
By default customization files are located in the ``semiwrap`` directory. The name
26+
of the YAML file is the ``key`` in the extension module headers table:
3727

3828
.. code-block:: toml
3929
40-
[tool.robotpy-build.wrappers."PACKAGENAME"]
41-
generation_data = "gen"
42-
43-
When a directory is specified, pybind11 will search for YAML files in the
44-
directory based on the header filename. In the above example, customization
45-
data for ``header.h`` could be specified in ``gen/header.yml``.
30+
[tool.semiwrap.extension_modules."PACKAGE.NAME".headers]
31+
# yaml file is `semiwrap/demo.yml`
32+
demo = "include/demo.h"
4633
4734
4835
Autogeneration
4936
--------------
5037

51-
The default values for these YAML files can be generated via the robotpy-build
52-
command line tool:
38+
The default values for these YAML files should be generated via the semiwrap command
39+
line tool:
5340

5441
.. code-block:: sh
5542
56-
robotpy-build create-gen --write
43+
semiwrap create-yaml --write
5744
5845
This can be a good way to get the boilerplate out of the way when you need to
5946
provide customizations.
6047

48+
Manual pybind11 APIs
49+
--------------------
50+
51+
You can write your own custom .cpp files and add them to the python extensions
52+
generated by semiwrap. In your ``meson.build`` after you include the generated
53+
``semiwrap`` subdir, add files to ``NAME_sources``.
54+
55+
.. code-block:: meson
56+
57+
subdir('semiwrap')
58+
59+
my_module_sources += files(
60+
'src/my_module/main.cpp',
61+
)
62+
63+
6164
Reference
6265
---------
6366

6467
The following strctures describe the dictionaries that are read from the YAML
65-
file. The toplevel structure is :class:`.AutowrapConfigYaml`.
68+
files. The toplevel structure is :class:`.AutowrapConfigYaml`.
6669

67-
.. automodule:: robotpy_build.config.autowrap_yml
70+
.. automodule:: semiwrap.config.autowrap_yml
6871
:members:
69-
:undoc-members:

docs/config/pyproject.rst

+13-88
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
11

22
.. _pyproject:
33

4-
setup.py and pyproject.toml
5-
===========================
6-
7-
setup.py
8-
--------
9-
10-
Projects that use robotpy-build must use the setup function provided by
11-
robotpy-build. Your project's setup.py should look like this:
12-
13-
.. code-block:: py
14-
15-
#!/usr/bin/env python3
16-
from robotpy_build.setup import setup
17-
setup()
18-
194
pyproject.toml
20-
--------------
5+
==============
216

22-
Projects that use robotpy-build must add a ``pyproject.toml`` to the root of
7+
Projects that use semiwrap must add a ``pyproject.toml`` to the root of
238
their project as specified in `PEP 518 <https://www.python.org/dev/peps/pep-0518>`_.
249

25-
It is recommended that projects include the standard ``build-system`` section to
26-
tell pip to install robotpy-build (and any other dependencies) before starting
27-
a build.
10+
Because semiwrap is a hatchling plugin, you should add semiwrap and hatchling
11+
to your ``build-system.requires``. You need meson to build the project, so we
12+
recommend also using ``hatch-meson`` to do so.
2813

2914
.. code-block:: toml
3015
3116
[build-system]
32-
requires = ["robotpy-build>=2020.1.0,<2021.0.0"]
17+
build-backend = "hatchling.build"
18+
requires = ["semiwrap", "hatch-meson", "hatchling"]
3319
34-
Projects must include robotpy-build specific sections in their pyproject.toml.
35-
robotpy-build takes ``pyproject.toml`` and converts it to a python dictionary
36-
using ``toml.load``. The resulting dictionary is given to pydantic, which
37-
validates the structure of the dictionary against the objects described below.
20+
Projects must include semiwrap specific sections in their pyproject.toml.
21+
semiwrap takes ``pyproject.toml`` and converts it to a python dictionary
22+
using ``toml.load``. The resulting dictionary is converted to the dataclasses
23+
described below.
3824

3925
Required sections:
4026

@@ -49,73 +35,12 @@ Optional sections:
4935
* :class:`.PatchInfo` - patch downloaded sources
5036

5137

52-
.. note:: For a complete example pyproject.toml file, see ``tests/cpp/pyproject.toml.tmpl``
53-
54-
.. _pyproject_overrides:
55-
56-
Overrides
57-
---------
58-
59-
You can define 'override' sections that will be grafted onto the configuration
60-
if they match a particular platform. For example, to change the dependencies
61-
for a wrapper section on Windows:
62-
63-
.. code-block:: toml
64-
65-
[tool.robotpy-build.wrappers."PACKAGENAME".override.os_windows]
66-
depends = ["windows-thing"]
67-
68-
Any element in the robotpy-build section of pyproject.toml can be overridden
69-
by specifying the identical section as '.override.KEYNAME'. If the key matches
70-
the current configuration, the override will be written to the original section.
71-
The matched keys are generated at runtime. Current supported platform override
72-
keys are:
73-
74-
* ``arch_{platform_arch}``
75-
* ``os_{platform_os}``
76-
* ``platform_{platform_os}_{platform_arch}``
77-
78-
To get information about the current platform, you can run:
79-
80-
.. code-block:: sh
81-
82-
robotpy-build platform-info
83-
84-
To show the available platforms:
85-
86-
.. code-block:: sh
87-
88-
robotpy-build platform-info --list
89-
90-
To process a pyproject.toml and see the result of applying various overrides,
91-
you can use this tool to process for the current platform:
92-
93-
.. code-block:: sh
94-
95-
robotpy-build show-override
96-
97-
To show what would be processed for a different platform:
98-
99-
.. code-block:: sh
100-
101-
robotpy-build show-override -p linux-athena
102-
103-
.. _platforms:
104-
105-
Current supported platform/os/arch combinations are:
106-
107-
* OS: windows/osx/linux
108-
* Arch: x86/x86-64/armv7l/aarch64
109-
110-
For ARM linux distributions we support:
38+
.. note:: For a complete example pyproject.toml file, see ``tests/cpp/*/pyproject.toml``
11139

112-
* armv7l + nilrt (RoboRIO)
113-
* armv7l + raspbian (Raspbian 10)
114-
* aarch64 + bionic (Ubuntu 18.04)
11540

11641
Reference
11742
---------
11843

119-
.. automodule:: robotpy_build.config.pyproject_toml
44+
.. automodule:: semiwrap.config.pyproject_toml
12045
:members:
12146
:exclude-members: __init__, Config

0 commit comments

Comments
 (0)