56 Commits

Author SHA1 Message Date
Joao Paulo Magalhaes
10848239d1 refactor error API: use the new exceptions in the swig file 2025-12-28 19:17:25 +00:00
Joao Paulo Magalhaes
209c487e1d refactor error API: update swig file 2025-12-28 19:17:25 +00:00
Joao Paulo Magalhaes
5e7596d97f Improve python API:
- expose `to_arena()`
- improve type handling in Tree methods accepting scalars
2025-12-28 13:13:57 +00:00
Joao Paulo Magalhaes
0febd0fa65 Improve behaviour of tree creation and Tree::root_id().
`Tree` is now non-empty by default, and `Tree::root_id()` will no longer modify the tree when it is empty. To create an empty tree now it is necessary to use the capacity constructor with a capacity of zero:
  ```c++
  // default-constructed tree is now non-empty
  Tree tree;
  assert(!tree.empty()); // MODIFIED! was empty on previous version
  id_type root = tree.root_id(); // OK. default-constructed tree is now non-empty

  // to create an empty tree:
  Tree tree(0); // pass capacity of zero
  assert(tree.empty()); // as expected
  // but watchout, this is no longer possible:
  //id_type root = tree.root_id(); // ERROR: cannot get root of empty tree.
  ```
This changeset also enables the python library to call `root_id()` on a default-constructed tree

re #556
2025-12-02 21:03:48 +00:00
Joao Paulo Magalhaes
940d9f76b2 Fix wheel import problem in macosx
Kudos to @davidrudlstorfer for identifying the fix in #516.
2025-04-09 15:19:13 +01:00
Joao Paulo Magalhaes
9e9ab5eb50 Fix python wheel build and workflows 2025-04-09 15:19:12 +01:00
Joao Paulo Magalhaes
3b3ad1e093 re #513: fix python README example, run as test 2025-04-02 23:26:45 +01:00
Joao Paulo Magalhaes
97133810c3 event-based parser policy pt5: API 2024-05-05 18:53:14 +02:00
Joao Paulo Magalhaes
93d76be507 fix #428: ensure SWIG API raises exception 2024-04-28 19:10:52 +01:00
Joao Paulo Magalhaes
6fe06404a6 [ci] disable creation of python packages for Windows (except 3.6/3.7) and MacOSX
Here's an example log of the problem for Windows:
see https://github.com/biojppm/rapidyaml/actions/runs/3686238289/jobs/6238204139

```
+ pip install -v dist/rapidyaml-0.4.1.post139-cp311-cp311-win_amd64.whl
Using pip 22.3.1 from C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\site-packages\pip (python 3.11)
Processing d:\a\rapidyaml\rapidyaml\dist\rapidyaml-0.4.1.post139-cp311-cp311-win_amd64.whl
Installing collected packages: rapidyaml
Successfully installed rapidyaml-0.4.1.post139
+ pip show -f rapidyaml
Name: rapidyaml
Version: 0.4.1.post139
Summary: Rapid YAML - a library to parse and emit YAML, and do it fast
Home-page: https://github.com/biojppm/rapidyaml
Author: Joao Paulo Magalhaes
Author-email: dev@jpmag.me
License: MIT
Location: C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\site-packages
Requires:
Required-by:
Files:
  rapidyaml-0.4.1.post139.dist-info\INSTALLER
  rapidyaml-0.4.1.post139.dist-info\LICENSE.txt
  rapidyaml-0.4.1.post139.dist-info\METADATA
  rapidyaml-0.4.1.post139.dist-info\RECORD
  rapidyaml-0.4.1.post139.dist-info\REQUESTED
  rapidyaml-0.4.1.post139.dist-info\WHEEL
  rapidyaml-0.4.1.post139.dist-info\direct_url.json
  rapidyaml-0.4.1.post139.dist-info\top_level.txt
  ryml\__init__.py
  ryml\__pycache__\__init__.cpython-311.pyc
  ryml\__pycache__\ryml.cpython-311.pyc
  ryml\__pycache__\version.cpython-311.pyc
  ryml\_ryml.pyd
  ryml\ryml.py
  ryml\tests\__pycache__\parse_bm.cpython-311.pyc
  ryml\tests\__pycache__\test_parse.cpython-311.pyc
  ryml\tests\parse_bm.py
  ryml\tests\test_parse.py
  ryml\version.py
+ python -c 'import ryml'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\site-packages\ryml\__init__.py", line 1, in <module>
    from ryml.ryml import *
  File "C:\hostedtoolcache\windows\Python\3.11.0\x64\Lib\site-packages\ryml\ryml.py", line 13, in <module>
    from . import _ryml
ImportError: DLL load failed while importing _ryml: The specified module could not be found.
Error: Process completed with exit code 1.
```
2022-12-15 10:56:19 +00:00
Joao Paulo Magalhaes
40077106fa [bm] python: add emit benchmarks 2022-09-14 23:14:37 +01:00
Joao Paulo Magalhaes
49302a2bd8 [fix] update python API: deprecate emit() et al 2022-09-14 22:43:27 +01:00
Joao Paulo Magalhaes
b4a603911b [breaking] rename parse() to either parse_in_place() or parse_in_arena() 2022-01-04 15:33:09 +00:00
Simon Gerber
cafe9ca50f Change Python API test make target to use nose
This ensures that running the Python API tests locally with `make test`
uses the same tooling as the GitHub action.
2021-11-01 23:24:53 +01:00
Simon Gerber
305754e385 Update Python API test case to have a quoted key and value 2021-11-01 19:13:35 +01:00
Simon Gerber
d36df949aa Add missing node predicates in SWIG API definition 2021-11-01 19:12:55 +01:00
Joao Paulo Magalhaes
a035301384 [fix] ensure that predefined CPU macros are forwarded to SWIG 2021-09-25 14:52:14 +01:00
Joao Paulo Magalhaes
27bd209dfa [fix] update python test after file rename 2021-09-25 01:30:46 +01:00
Joao Paulo Magalhaes
6b04bf5b9a [chore] github actions: refactor release action 2021-09-25 00:21:54 +01:00
Joao Paulo Magalhaes
13361f3dd9 [chore] re #146: create python release packages in github action 2021-09-16 16:10:05 +02:00
Tim 'mithro' Ansell
0940431d80 Don't use litghost's cmake-build-extension. 2021-03-23 00:21:19 -07:00
Tim 'mithro' Ansell
ce39680601 Reworking Python packaging.
* Move `setup.py` and `pyproject.toml` to root directory otherwise
   everything breaks.
 * Use `setuptool_scm` for version.
 * Build wheels from sdist files using pip.
2021-03-23 00:21:02 -07:00
Tim 'mithro' Ansell
4042e72f11 Move tests into package. 2021-03-22 23:59:41 -07:00
Tim 'mithro' Ansell
924563859a Adding Python .gitignore file. 2021-03-22 23:59:41 -07:00
Tim 'mithro' Ansell
4acd71c5de Fix version. 2021-03-22 23:59:41 -07:00
Keith Rothman
71ff6aa08d Use new[] instead of malloc, because SWIG uses delete[] rather than free.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-15 18:17:27 -08:00
Keith Rothman
5a245999e9 Use python from venv for testing.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-14 16:53:21 -08:00
Keith Rothman
073b1fe5f2 INCREF Py_NONE as required.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-14 15:27:54 -08:00
Keith Rothman
05a79741d5 Return None for empty csubstr.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-14 14:39:29 -08:00
Keith Rothman
6daabad213 Add ninja to build requirement.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-14 13:22:34 -08:00
Keith Rothman
27d5c654e6 Don't require cmake_component.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-14 12:59:35 -08:00
Keith Rothman
3230e5f7b3 Tighten up CMake python test invocations.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
ada136ae8b Move tests into test folder.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
d3626d86ab Add in place emit methods.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
2ff442eb67 Avoid use of std::string.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
8ace20a5d9 Enable Python emission and add methods to set either key or value.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
881da6fdd9 Try to fix CI?
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
54c09fd1a0 Add emit method to python SWIG.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
f2717db162 Initial attempt to create python packaging for ryml module.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Keith Rothman
2ebdb0c398 Initial attempt at CMake / setup.py integration.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
2021-01-13 09:50:15 -08:00
Joao Paulo Magalhaes
231b1088e3 [wip] api generation in windows 2020-11-01 18:02:19 +00:00
Joao Paulo Magalhaes
a5bd9ccf14 update c4proj 2020-01-22 00:02:10 +01:00
Joao Paulo Magalhaes
eab9050064 c4proj: fix install of incorporated targets 2020-01-15 01:23:40 +01:00
Joao Paulo Magalhaes
48da84dd66 api: add tests modifying the tree 2019-03-21 14:32:46 +00:00
Joao Paulo Magalhaes
df5a095753 api tests require that the api is added at the end 2019-03-21 14:25:20 +00:00
Joao Paulo Magalhaes
c54b97776a create dev branch to make master the stable branch 2019-03-20 21:30:49 +00:00
Joao Paulo Magalhaes
b8096460a1 API: fix creation of csubstr from python str 2019-03-20 21:24:11 +00:00
Joao Paulo Magalhaes
7afb30a524 python API: unit tests, benchmark 2019-03-19 00:26:21 +00:00
Joao Paulo Magalhaes
6d0c042647 improve the python test case 2019-03-18 20:30:25 +00:00
Joao Paulo Magalhaes
d1dd12839a python API is working 2019-03-18 20:17:35 +00:00