Commit Graph

12 Commits

Author SHA1 Message Date
6889e97c28 Declare CMake for isolated source builds
Some checks failed
Build / wheels (x86_64, ubuntu-latest) (push) Failing after 2s
Build / source (push) Failing after 1s
Build / lint (push) Failing after 1s
Build / wheels (aarch64, ubuntu-24.04-arm) (push) Has been cancelled
Build / wheels (arm64, macos-15) (push) Has been cancelled
2026-09-21 22:57:46 -05:00
05cc505ef4 Optimize numeric array conversion and serialize directly into Python bytes
Some checks failed
Build / wheels (x86_64, ubuntu-latest) (push) Failing after 1s
Build / source (push) Failing after 1s
Build / lint (push) Failing after 1s
Build / wheels (aarch64, ubuntu-24.04-arm) (push) Has been cancelled
Build / wheels (arm64, macos-15) (push) Has been cancelled
2026-09-21 22:48:21 -05:00
Adeeb Shihadeh
caee18aeef Vendor minimal capnproto 2026-09-21 20:05:46 -07:00
Adeeb Shihadeh
5befba15f3 Minimal pycapnp 2026-09-21 18:57:37 -07:00
Trey Moen
8d80f4d69e ci: pin ruff to the latest passing release (#408)
* ci: pin ruff to the passing baseline

* ci: use the latest passing ruff release

* ci: share the ruff pin through a lint dependency group

* ci: note follow-up to update lint and unpin ruff
2026-09-21 17:25:17 -07:00
Jacob Alexander
9594d43e77 Fix uv sync / uv venv with pytest
uv sync
source .venv/bin/activate
cd test
python -m pytest .

- Update default bundled capnproto to 1.4.0
- Cleanup pyproject.toml
- Remove Pipfile and requirements.txt
2026-07-01 23:47:26 -07:00
Jacob Alexander
162fddbcf6 Replace black and flake8 with ruff for linting and formatting
- Remove .flake8; add [tool.ruff] and [tool.ruff.format] config in pyproject.toml
  (line-length 120, excludes, ignore list, per-file-ignores, mccabe complexity)
- Update GitHub workflow lint job to run `ruff check .` and `ruff format --check .`
- Swap black and flake8 for ruff in requirements.txt and Pipfile
- Change capnp/__init__.py to ruff-style noqa comment
- Move max-complexity into [tool.ruff.lint.mccabe], lint options into [tool.ruff.lint]
- Add per-file-ignores for capnp/__init__.py (F401, F403, F405), remove inline noqa
- Run ruff format across codebase (24 files) for consistent style
2026-05-30 11:59:52 -07:00
Lasse Blaauwbroek
983719fde9 Upgrade Cython to version 3
While looking at #333, I hypothesized that upgrading Cython might solve the
issue. It didn't. But upgrading should still happen at some point. This is my
work in progress on that. The tests pass, but there are two main things missing:

Problem (1):
Starting with Cython 3, you can only do `except+` or `except
+reraise_kj_exception` on `extern` functions coming from C++. (This makes sense,
and the way things were declared in Pycapnp wasn't too good.) As a result, I had
to remove a lot of these declaration. This results in some segmentation faults,
because Cython no longer detects C++ exceptions and converts them to Python
exceptions in some places.

To solve this, all `extern` declarations in `.pxd` files have to be examined and
`except +reraise_kj_exception` clauses need to be added to anything that might
throw. Previously, this was done really inconsistently. The lazy solution would
be to just add the clause everywhere, but I'm not sure what the performance
implications are.

Problem (2):
The compilation output of `python setup.py build_ext --inplace` is now full of messages like these:
```
capnp/lib/capnp.cpp: In function ‘PyObject* __pyx_f_5capnp_3lib_5capnp_18_DynamicListReader__get(__pyx_obj_5capnp_3lib_5capnp__DynamicListReader*, int64_t, int)’:
capnp/lib/capnp.cpp:4871:51: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
 4871 |   #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x)
      |                                          ~~~~~~~~~^~~
capnp/lib/capnp.cpp:20944:59: note: in expansion of macro ‘__PYX_STD_MOVE_IF_SUPPORTED’
20944 |   __pyx_t_2 = __pyx_f_5capnp_3lib_5capnp_to_python_reader(__PYX_STD_MOVE_IF_SUPPORTED((( ::capnp::DynamicValue::Reader)__pyx_t_7)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
capnp/lib/capnp.cpp:4871:51: note: remove ‘std::move’ call
 4871 |   #define __PYX_STD_MOVE_IF_SUPPORTED(x) std::move(x)
      |                                          ~~~~~~~~~^~~
capnp/lib/capnp.cpp:20944:59: note: in expansion of macro ‘__PYX_STD_MOVE_IF_SUPPORTED’
20944 |   __pyx_t_2 = __pyx_f_5capnp_3lib_5capnp_to_python_reader(__PYX_STD_MOVE_IF_SUPPORTED((( ::capnp::DynamicValue::Reader)__pyx_t_7)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 419, __pyx_L1_error)
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
```
There are to many `move` calls inserted. I'm not sure if this is a Cython issue,
or if we are somehow annotating things wrong. Might be worth asking the Cython
people.

I'm not planning on working on this further in the short term. If someone wants
to take over on this, feel free.
2025-05-12 15:54:19 -07:00
Tobias Ahrens
d48ffea939 Add custom build backend to support build args (#328)
This implements a custom build backend, inspired by the
[solution used by Pillow.](https://github.com/python-pillow/Pillow/pull/7171)

install-option is deprecated and was removed with pip 23.1. The
comonly accepted solution seems to be to define a custom build
backend for now
https://github.com/pypa/setuptools/issues/2491#issuecomment-1589764230

This commit changes the usage from `--install-option` to `--config-settings`.
2023-10-02 22:30:51 -07:00
Karl
db26d60283 Pin cython to below version 3, Python 3.11 support (#320)
* Pin cython to below version 3

Cython 3 includes backwards incompatible changes so it's no longer
possible to install pycapnp from source.

* Add py311 environment

I'm not sure if this is necessary, but 3.11 is out so might as well?
2023-07-21 01:40:49 -07:00
Lasse Blaauwbroek
97bdeaea12 Disable option to run capnp without asyncio 2023-06-08 02:27:38 +02:00
Keith Rothman
4381e1f299 Add pyproject.yaml.
This file describes the dependencies needed to load the `setup.py` file.

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2020-12-16 12:21:58 -08:00