PyCxx11Bindings 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ # Adjusted workflow from: https://github.com/mitmproxy/pdoc/blob/25f325d06aaacba9711f957f48e770029f608f6a/.github/workflows/docs.yml
2
+
3
+ name: Generate documentation using pdoc and deploy as gh page.
4
+
5
+ # build the documentation whenever there are new commits on main
6
+ on:
7
+ push:
8
+ branches:
9
+ tags:
10
+ - '*'
11
+
12
+ # security: restrict permissions for CI jobs.
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ # Build the documentation and upload the static HTML files as an artifact.
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: '3.11'
25
+
26
+ # Install all dependencies (including pdoc)
27
+ - run: pip install -e .[docs]
28
+ - run: pdoc -d numpy -o docs cxx11bindings
29
+ - uses: actions/upload-pages-artifact@v3
30
+ with:
31
+ path: docs/
32
+
33
+ # Deploy the artifact to GitHub pages.
34
+ # This is a separate job so that only actions/deploy-pages has the necessary permissions.
35
+ deploy:
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ permissions:
39
+ pages: write
40
+ id-token: write
41
+ environment:
42
+ name: github-pages
43
+ url: ${{ steps.deployment.outputs.page_url }}
44
+ steps:
45
+ - id: deployment
46
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,11 @@
1
+ name: run pre-commit hooks
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ pre-commit:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - uses: actions/setup-python@v5
11
+ - uses: pre-commit/action@v3.0.1
@@ -0,0 +1,118 @@
1
+ # Inspired by: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
+
3
+ name: Publish Python Distribution to PyPI and TestPyPI
4
+
5
+ on: push
6
+
7
+ jobs:
8
+ build:
9
+ name: Build
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v5
16
+ with:
17
+ python-version: 3.x
18
+ - name: Install pypa/build
19
+ run: >-
20
+ python3 -m
21
+ pip install
22
+ build
23
+ --user
24
+ - name: Build a binary wheel and a source tarball
25
+ run: python3 -m build
26
+ - name: Store the distribution packages
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: python-package-distributions
30
+ path: dist/
31
+
32
+ publish-to-pypi:
33
+ name: Publish to PyPi
34
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
35
+ needs:
36
+ - build
37
+ runs-on: ubuntu-latest
38
+ environment:
39
+ name: pypi
40
+ url: https://pypi.org/p/PyCxx11Bindings
41
+ permissions:
42
+ id-token: write # IMPORTANT: mandatory for trusted publishing
43
+ steps:
44
+ - name: Download all the dists
45
+ uses: actions/download-artifact@v4
46
+ with:
47
+ name: python-package-distributions
48
+ path: dist/
49
+ - name: Publish distribution to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
51
+
52
+ github-release:
53
+ name: >-
54
+ Sign the Python distribution with Sigstore
55
+ and upload them to GitHub Release
56
+ needs:
57
+ - publish-to-pypi
58
+ runs-on: ubuntu-latest
59
+
60
+ permissions:
61
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
62
+ id-token: write # IMPORTANT: mandatory for sigstore
63
+
64
+ steps:
65
+ - name: Download all the dists
66
+ uses: actions/download-artifact@v4
67
+ with:
68
+ name: python-package-distributions
69
+ path: dist/
70
+ - name: Sign the dists with Sigstore
71
+ uses: sigstore/gh-action-sigstore-python@v3.0.0
72
+ with:
73
+ inputs: >-
74
+ ./dist/*.tar.gz
75
+ ./dist/*.whl
76
+ - name: Create GitHub Release
77
+ env:
78
+ GITHUB_TOKEN: ${{ github.token }}
79
+ run: >-
80
+ gh release create
81
+ '${{ github.ref_name }}'
82
+ --repo '${{ github.repository }}'
83
+ --notes ""
84
+ - name: Upload artifact signatures to GitHub Release
85
+ env:
86
+ GITHUB_TOKEN: ${{ github.token }}
87
+ # Upload to GitHub Release using the `gh` CLI.
88
+ # `dist/` contains the built packages, and the
89
+ # sigstore-produced signatures and certificates.
90
+ run: >-
91
+ gh release upload
92
+ '${{ github.ref_name }}' dist/**
93
+ --repo '${{ github.repository }}'
94
+
95
+ publish-to-testpypi:
96
+ name: Publish Python distribution to TestPyPI
97
+ needs:
98
+ - build
99
+ runs-on: ubuntu-latest
100
+
101
+ environment:
102
+ name: testpypi
103
+ url: https://test.pypi.org/p/PyCxx11Bindings
104
+
105
+ permissions:
106
+ id-token: write # IMPORTANT: mandatory for trusted publishing
107
+
108
+ steps:
109
+ - name: Download all the dists
110
+ uses: actions/download-artifact@v4
111
+ with:
112
+ name: python-package-distributions
113
+ path: dist/
114
+ - name: Publish distribution to TestPyPI
115
+ uses: pypa/gh-action-pypi-publish@release/v1
116
+ with:
117
+ skip-existing: true
118
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,26 @@
1
+ name: Run tests
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ strategy:
9
+ matrix:
10
+ platform: [ubuntu-latest, windows-latest]
11
+ python-version: [3.8, 3.9, '3.10', '3.11', '3.13']
12
+
13
+ runs-on: ${{ matrix.platform }}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Set up Python ${{ matrix.python-version }}
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install .[test]
25
+ - name: Test with pytest
26
+ run: pytest -n auto
@@ -0,0 +1,301 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks,emacs,linux,macos,windows
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python,jupyternotebooks,emacs,linux,macos,windows
3
+
4
+ ### Emacs ###
5
+ # -*- mode: gitignore; -*-
6
+ *~
7
+ \#*\#
8
+ /.emacs.desktop
9
+ /.emacs.desktop.lock
10
+ *.elc
11
+ auto-save-list
12
+ tramp
13
+ .\#*
14
+
15
+ # Org-mode
16
+ .org-id-locations
17
+ *_archive
18
+
19
+ # flymake-mode
20
+ *_flymake.*
21
+
22
+ # eshell files
23
+ /eshell/history
24
+ /eshell/lastdir
25
+
26
+ # elpa packages
27
+ /elpa/
28
+
29
+ # reftex files
30
+ *.rel
31
+
32
+ # AUCTeX auto folder
33
+ /auto/
34
+
35
+ # cask packages
36
+ .cask/
37
+ dist/
38
+
39
+ # Flycheck
40
+ flycheck_*.el
41
+
42
+ # server auth directory
43
+ /server/
44
+
45
+ # projectiles files
46
+ .projectile
47
+
48
+ # directory configuration
49
+ .dir-locals.el
50
+
51
+ # network security
52
+ /network-security.data
53
+
54
+
55
+ ### JupyterNotebooks ###
56
+ # gitignore template for Jupyter Notebooks
57
+ # website: http://jupyter.org/
58
+
59
+ .ipynb_checkpoints
60
+ */.ipynb_checkpoints/*
61
+
62
+ # IPython
63
+ profile_default/
64
+ ipython_config.py
65
+
66
+ # Remove previous ipynb_checkpoints
67
+ # git rm -r .ipynb_checkpoints/
68
+
69
+ ### Linux ###
70
+
71
+ # temporary files which can be created if a process still has a handle open of a deleted file
72
+ .fuse_hidden*
73
+
74
+ # KDE directory preferences
75
+ .directory
76
+
77
+ # Linux trash folder which might appear on any partition or disk
78
+ .Trash-*
79
+
80
+ # .nfs files are created when an open file is removed but is still being accessed
81
+ .nfs*
82
+
83
+ ### macOS ###
84
+ # General
85
+ .DS_Store
86
+ .AppleDouble
87
+ .LSOverride
88
+
89
+ # Icon must end with two \r
90
+ Icon
91
+
92
+ # Thumbnails
93
+ ._*
94
+
95
+ # Files that might appear in the root of a volume
96
+ .DocumentRevisions-V100
97
+ .fseventsd
98
+ .Spotlight-V100
99
+ .TemporaryItems
100
+ .Trashes
101
+ .VolumeIcon.icns
102
+ .com.apple.timemachine.donotpresent
103
+
104
+ # Directories potentially created on remote AFP share
105
+ .AppleDB
106
+ .AppleDesktop
107
+ Network Trash Folder
108
+ Temporary Items
109
+ .apdisk
110
+
111
+ ### macOS Patch ###
112
+ # iCloud generated files
113
+ *.icloud
114
+
115
+ ### Python ###
116
+ # Byte-compiled / optimized / DLL files
117
+ __pycache__/
118
+ *.py[cod]
119
+ *$py.class
120
+
121
+ # C extensions
122
+ *.so
123
+
124
+ # Distribution / packaging
125
+ .Python
126
+ build/
127
+ develop-eggs/
128
+ downloads/
129
+ eggs/
130
+ .eggs/
131
+ lib/
132
+ lib64/
133
+ parts/
134
+ sdist/
135
+ var/
136
+ wheels/
137
+ share/python-wheels/
138
+ *.egg-info/
139
+ .installed.cfg
140
+ *.egg
141
+ MANIFEST
142
+
143
+ # PyInstaller
144
+ # Usually these files are written by a python script from a template
145
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
146
+ *.manifest
147
+ *.spec
148
+
149
+ # Installer logs
150
+ pip-log.txt
151
+ pip-delete-this-directory.txt
152
+
153
+ # Unit test / coverage reports
154
+ htmlcov/
155
+ .tox/
156
+ .nox/
157
+ .coverage
158
+ .coverage.*
159
+ .cache
160
+ nosetests.xml
161
+ coverage.xml
162
+ *.cover
163
+ *.py,cover
164
+ .hypothesis/
165
+ .pytest_cache/
166
+ cover/
167
+
168
+ # Translations
169
+ *.mo
170
+ *.pot
171
+
172
+ # Django stuff:
173
+ *.log
174
+ local_settings.py
175
+ db.sqlite3
176
+ db.sqlite3-journal
177
+
178
+ # Flask stuff:
179
+ instance/
180
+ .webassets-cache
181
+
182
+ # Scrapy stuff:
183
+ .scrapy
184
+
185
+ # Sphinx documentation
186
+ docs/_build/
187
+
188
+ # PyBuilder
189
+ .pybuilder/
190
+ target/
191
+
192
+ # Jupyter Notebook
193
+
194
+ # IPython
195
+
196
+ # pyenv
197
+ # For a library or package, you might want to ignore these files since the code is
198
+ # intended to run in multiple environments; otherwise, check them in:
199
+ # .python-version
200
+
201
+ # pipenv
202
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
203
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
204
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
205
+ # install all needed dependencies.
206
+ #Pipfile.lock
207
+
208
+ # poetry
209
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
210
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
211
+ # commonly ignored for libraries.
212
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
213
+ #poetry.lock
214
+
215
+ # pdm
216
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
217
+ #pdm.lock
218
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
219
+ # in version control.
220
+ # https://pdm.fming.dev/#use-with-ide
221
+ .pdm.toml
222
+
223
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
224
+ __pypackages__/
225
+
226
+ # Celery stuff
227
+ celerybeat-schedule
228
+ celerybeat.pid
229
+
230
+ # SageMath parsed files
231
+ *.sage.py
232
+
233
+ # Environments
234
+ .env
235
+ .venv
236
+ env/
237
+ venv/
238
+ ENV/
239
+ env.bak/
240
+ venv.bak/
241
+
242
+ # Spyder project settings
243
+ .spyderproject
244
+ .spyproject
245
+
246
+ # Rope project settings
247
+ .ropeproject
248
+
249
+ # mkdocs documentation
250
+ /site
251
+
252
+ # mypy
253
+ .mypy_cache/
254
+ .dmypy.json
255
+ dmypy.json
256
+
257
+ # Pyre type checker
258
+ .pyre/
259
+
260
+ # pytype static type analyzer
261
+ .pytype/
262
+
263
+ # Cython debug symbols
264
+ cython_debug/
265
+
266
+ # PyCharm
267
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
268
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
269
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
270
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
271
+ #.idea/
272
+
273
+ ### Windows ###
274
+ # Windows thumbnail cache files
275
+ Thumbs.db
276
+ Thumbs.db:encryptable
277
+ ehthumbs.db
278
+ ehthumbs_vista.db
279
+
280
+ # Dump file
281
+ *.stackdump
282
+
283
+ # Folder config file
284
+ [Dd]esktop.ini
285
+
286
+ # Recycle Bin used on file shares
287
+ $RECYCLE.BIN/
288
+
289
+ # Windows Installer files
290
+ *.cab
291
+ *.msi
292
+ *.msix
293
+ *.msm
294
+ *.msp
295
+
296
+ # Windows shortcuts
297
+ *.lnk
298
+
299
+ # End of https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks,emacs,linux,macos,windows
300
+ artifacts/
301
+ mlruns/
@@ -0,0 +1,41 @@
1
+ repos:
2
+ - hooks:
3
+ - args:
4
+ - --fix
5
+ id: ruff
6
+ - id: ruff-format
7
+ repo: https://github.com/astral-sh/ruff-pre-commit
8
+ rev: v0.6.5
9
+ - hooks:
10
+ - id: check-added-large-files
11
+ - id: check-executables-have-shebangs
12
+ - id: check-merge-conflict
13
+ - id: check-shebang-scripts-are-executable
14
+ - id: check-toml
15
+ - id: check-yaml
16
+ - id: end-of-file-fixer
17
+ - id: mixed-line-ending
18
+ - id: trailing-whitespace
19
+ repo: https://github.com/pre-commit/pre-commit-hooks
20
+ rev: v4.6.0
21
+ - hooks:
22
+ - args:
23
+ - --autofix
24
+ - --indent
25
+ - '2'
26
+ id: pretty-format-yaml
27
+ - args:
28
+ - --autofix
29
+ id: pretty-format-toml
30
+ - args:
31
+ - --autofix
32
+ id: pretty-format-ini
33
+ repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
34
+ rev: v2.14.0
35
+ - hooks:
36
+ - id: commitizen
37
+ - id: commitizen-branch
38
+ stages:
39
+ - push
40
+ repo: https://github.com/commitizen-tools/commitizen
41
+ rev: v3.29.0
@@ -0,0 +1,17 @@
1
+ Changelog
2
+ =========
3
+
4
+
5
+ (unreleased)
6
+ ------------
7
+ - Release v1.0.0. [Mathieu Malaterre]
8
+ - Start main module. [Mathieu Malaterre]
9
+ - Update documentation. [Mathieu Malaterre]
10
+ - Adapt to project and remove 3.7. [Mathieu Malaterre]
11
+
12
+ Original project at:
13
+
14
+ * https://github.com/MArpogaus/minimal_python_project_skeleton
15
+ - Initial commit. [Mathieu Malaterre]
16
+
17
+
@@ -0,0 +1,80 @@
1
+ <!-- This file has been heavily inspired by https://github.com/probabilists/zuko/blob/master/CONTRIBUTING.md -->
2
+
3
+ # Contributing guidelines
4
+
5
+ First off, thank you for taking the time to contribute! 🎉
6
+
7
+ This document is a set of guidelines for contributing to this package, which includes how to ask questions, report issues, suggest enhancements, contribute code, etc.
8
+
9
+ ## I just have a question
10
+
11
+ Please **don't file an issue** to ask a question. We use GitHub discussions as community forum for people to ask questions, share ideas or seek help. Before submitting your question, check whether it has already been asked in the discussions. If it has but the answer does not satisfy you, add a comment to the existing discussion instead of opening a new one.
12
+
13
+ ## Submit an issue
14
+
15
+ Bugs and enhancements are tracked as GitHub issues. For common issues, such as bug reports and feature requests, templates are provided. It is strongly recommended to use them as it helps understand and resolve issues faster. A clear and concise title (e.g. "RuntimeError with X when Y") also helps other users and developers to find relevant issues.
16
+
17
+ Before submitting any issue, please perform a thorough search to see if your problem or a similar one has already been reported. If it has and the issue is still open, add a comment to the existing issue instead of opening a new one. If you only find closed issues related to your problem, open a new one and include links to the closed issues in the description.
18
+
19
+ ## Contribute code
20
+
21
+ If you like the project and wish to contribute, you can start by looking at issues labeled `good first issue` (should only require a few lines of code) or `help wanted` (more involved). If you found a bug and want to fix it, please create an issue reporting the bug before creating a pull request. Similarly, if you want to add a new feature, first create a feature request issue. This allows to separate the discussions related to the bug/feature, from the discussions related to the fix/implementation.
22
+
23
+ To get started with contributing code, we recommend to install zuko in editable mode with its development dependencies.
24
+
25
+ ```
26
+ pip install -e ".[dev]"
27
+ ```
28
+
29
+ Optionally, we also provide [pre-commit hooks](#pre-commit-hooks) to ensure that the code you commit adheres to our conventions.
30
+
31
+ ```
32
+ pre-commit install
33
+ ```
34
+
35
+ After installation, pre-commit will automatically execute the configured hooks before each commit and provide instructions on how to fix detected issues.
36
+
37
+ ### Testing
38
+
39
+ We use [pytest](https://docs.pytest.org) to test our code base. If your contribution introduces new components, you should write new tests to make sure your code doesn't crash under normal circumstances. After installing `pytest`, add the tests to the [tests/](tests) directory and run them with
40
+
41
+ ```
42
+ pytest tests
43
+ ```
44
+
45
+ When you submit a pull request, tests are automatically (upon approval) executed for several versions of Python.
46
+
47
+ ### Code conventions
48
+
49
+ We use [Ruff](https://github.com/astral-sh/ruff) to lint and format all Python code. After installing `ruff`, you can check if your code follows our conventions with
50
+
51
+ ```
52
+ ruff check .
53
+ ruff format --check .
54
+ ```
55
+
56
+ ### Pre-Commit Hooks
57
+
58
+ To make it as easy as possible to comply with the conventions defined above, we offer pre-configured hooks for the [pre-commit framework](https://pre-commit.com/).
59
+ These hooks serve to ensure that all commits strictly comprise syntactically accurate and well-formatted code, and prevent potential issues such as accidental inclusion of large files.
60
+
61
+ Here's a quick overview of the hook used in the provided [configuration file](./.pre-commit-config.yaml) and their respective repository links:
62
+
63
+ - [ruff](https://github.com/astral-sh/ruff): This hook checks for formatting and linting errors in Python files.
64
+
65
+ - [pre-commit-hooks](https://github.com/pre-commit/pre-commit-hooks): These hooks validate YAML and TOML files, detect trailing whitespace, identify accidentally added large files, and pinpoint merge conflicts.
66
+
67
+ You can manually run pre-commit on the entire repository by using the command:
68
+
69
+ ```
70
+ pre-commit run --all-files
71
+ ```
72
+
73
+ This command is useful if you want to check all files in your repository without making a commit.
74
+
75
+ ### Commits
76
+
77
+ We kindly ask to follow the [conventional commits specification](https://www.conventionalcommits.org/) for your commit messages.
78
+
79
+ Please make sure your description is short informative and dos not exceed the limit of =68= characters in the many git UIs.
80
+ For the same reason the body text line lengths should be limited to 80 characters.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dicomstudio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyCxx11Bindings
3
+ Version: 1.0.0
4
+ License: MIT
5
+ Project-URL: Changelog, https://github.com/dicomstudio/PyCxx11Bindings/blob/dev/CHANGELOG.md
6
+ Project-URL: Documentation, https://dicomstudio.github.io/PyCxx11Bindings
7
+ Project-URL: Issues, https://github.com/dicomstudio/PyCxx11Bindings/issues
8
+ Project-URL: Repository, https://github.com/dicomstudio/PyCxx11Bindings
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: <3.14,>=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: develop
18
+ Requires-Dist: PyCxx11Bindings[test]; extra == "develop"
19
+ Requires-Dist: commitizen; extra == "develop"
20
+ Requires-Dist: ipykernel; extra == "develop"
21
+ Requires-Dist: pre-commit; extra == "develop"
22
+ Requires-Dist: pylsp-rope; extra == "develop"
23
+ Requires-Dist: python-lsp-ruff; extra == "develop"
24
+ Requires-Dist: python-lsp-server[all]; extra == "develop"
25
+ Requires-Dist: ruff; extra == "develop"
26
+ Provides-Extra: docs
27
+ Requires-Dist: pdoc; extra == "docs"
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest; extra == "test"
30
+ Requires-Dist: pytest-xdist; extra == "test"
31
+ Dynamic: license-file
32
+
33
+ [![img](https://img.shields.io/github/contributors/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/graphs/contributors)
34
+ [![img](https://img.shields.io/github/forks/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/network/members)
35
+ [![img](https://img.shields.io/github/stars/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/stargazers)
36
+ [![img](https://img.shields.io/github/issues/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/issues)
37
+ [![img](https://img.shields.io/github/license/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/LICENSE)
38
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/test.yaml.svg?label=test&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/test.yaml)
39
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/release.yaml.svg?label=release&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/release.yaml)
40
+ [![img](https://img.shields.io/badge/pre--commit-enabled-brightgreen.svg?logo=pre-commit&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/.pre-commit-config.yaml)
41
+
42
+ [![img](https://img.shields.io/pypi/v/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
43
+ [![img](https://img.shields.io/pypi/pyversions/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
44
+
45
+
46
+ # PyCxx11Bindings
47
+
48
+ ## About The Project
49
+
50
+ P/Invoke provides a set of marshaling capabilities for C-style APIs, but it does not support C++ Stream/APIs directly.
51
+
52
+ ### Installation
53
+
54
+ This package is available on [PyPI](https://pypi.org/project/PyCxx11Bindings/). You install it using pip:
55
+
56
+ pip install PyCxx11Bindings
57
+
58
+ ## Contributing
59
+
60
+ Any Contributions are greatly appreciated! If you have a question, an issue or would like to contribute, please read our [contributing guidelines](CONTRIBUTING.md).
61
+
62
+ ## License
63
+
64
+ Distributed under the [MIT License](LICENSE)
65
+
66
+ ## References
67
+
68
+ * https://github.com/dicomstudio/Cxx11Bindings
@@ -0,0 +1,36 @@
1
+ [![img](https://img.shields.io/github/contributors/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/graphs/contributors)
2
+ [![img](https://img.shields.io/github/forks/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/network/members)
3
+ [![img](https://img.shields.io/github/stars/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/stargazers)
4
+ [![img](https://img.shields.io/github/issues/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/issues)
5
+ [![img](https://img.shields.io/github/license/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/LICENSE)
6
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/test.yaml.svg?label=test&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/test.yaml)
7
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/release.yaml.svg?label=release&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/release.yaml)
8
+ [![img](https://img.shields.io/badge/pre--commit-enabled-brightgreen.svg?logo=pre-commit&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/.pre-commit-config.yaml)
9
+
10
+ [![img](https://img.shields.io/pypi/v/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
11
+ [![img](https://img.shields.io/pypi/pyversions/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
12
+
13
+
14
+ # PyCxx11Bindings
15
+
16
+ ## About The Project
17
+
18
+ P/Invoke provides a set of marshaling capabilities for C-style APIs, but it does not support C++ Stream/APIs directly.
19
+
20
+ ### Installation
21
+
22
+ This package is available on [PyPI](https://pypi.org/project/PyCxx11Bindings/). You install it using pip:
23
+
24
+ pip install PyCxx11Bindings
25
+
26
+ ## Contributing
27
+
28
+ Any Contributions are greatly appreciated! If you have a question, an issue or would like to contribute, please read our [contributing guidelines](CONTRIBUTING.md).
29
+
30
+ ## License
31
+
32
+ Distributed under the [MIT License](LICENSE)
33
+
34
+ ## References
35
+
36
+ * https://github.com/dicomstudio/Cxx11Bindings
@@ -0,0 +1,64 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+ requires = ["setuptools >= 61", "setuptools_scm>=7"]
4
+
5
+ [project]
6
+ classifiers = [
7
+ "Programming Language :: Python :: 3.8",
8
+ "Programming Language :: Python :: 3.9",
9
+ "Programming Language :: Python :: 3.10",
10
+ "Programming Language :: Python :: 3.11",
11
+ "Programming Language :: Python :: 3.13"
12
+ ]
13
+ dependencies = []
14
+ dynamic = ["version"]
15
+ license = {text = "MIT"}
16
+ name = "PyCxx11Bindings"
17
+ readme = "README.md"
18
+ requires-python = ">=3.8, <3.14"
19
+
20
+ [project.optional-dependencies]
21
+ develop = [
22
+ 'PyCxx11Bindings[test]',
23
+ 'commitizen',
24
+ 'ipykernel',
25
+ 'pre-commit',
26
+ 'pylsp-rope',
27
+ 'python-lsp-ruff',
28
+ 'python-lsp-server[all]',
29
+ 'ruff'
30
+ ]
31
+ docs = [
32
+ 'pdoc'
33
+ ]
34
+ test = [
35
+ 'pytest',
36
+ 'pytest-xdist'
37
+ ]
38
+
39
+ [project.urls]
40
+ Changelog = "https://github.com/dicomstudio/PyCxx11Bindings/blob/dev/CHANGELOG.md"
41
+ Documentation = "https://dicomstudio.github.io/PyCxx11Bindings"
42
+ Issues = "https://github.com/dicomstudio/PyCxx11Bindings/issues"
43
+ Repository = "https://github.com/dicomstudio/PyCxx11Bindings"
44
+
45
+ [tool.commitizen]
46
+ major_version_zero = true
47
+ name = "cz_conventional_commits"
48
+ tag_format = "v$version"
49
+ update_changelog_on_bump = true
50
+ version_provider = "scm"
51
+ version_scheme = "pep440"
52
+
53
+ [tool.ruff]
54
+ indent-width = 4
55
+ line-length = 88
56
+ target-version = "py37"
57
+
58
+ [tool.ruff.lint]
59
+ select = ["I", "E", "F"]
60
+
61
+ [tool.setuptools_scm]
62
+ # https://stackoverflow.com/a/74404703
63
+ # omits local version, useful because pypi does not support it
64
+ local_scheme = "no-local-version"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyCxx11Bindings
3
+ Version: 1.0.0
4
+ License: MIT
5
+ Project-URL: Changelog, https://github.com/dicomstudio/PyCxx11Bindings/blob/dev/CHANGELOG.md
6
+ Project-URL: Documentation, https://dicomstudio.github.io/PyCxx11Bindings
7
+ Project-URL: Issues, https://github.com/dicomstudio/PyCxx11Bindings/issues
8
+ Project-URL: Repository, https://github.com/dicomstudio/PyCxx11Bindings
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: <3.14,>=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: develop
18
+ Requires-Dist: PyCxx11Bindings[test]; extra == "develop"
19
+ Requires-Dist: commitizen; extra == "develop"
20
+ Requires-Dist: ipykernel; extra == "develop"
21
+ Requires-Dist: pre-commit; extra == "develop"
22
+ Requires-Dist: pylsp-rope; extra == "develop"
23
+ Requires-Dist: python-lsp-ruff; extra == "develop"
24
+ Requires-Dist: python-lsp-server[all]; extra == "develop"
25
+ Requires-Dist: ruff; extra == "develop"
26
+ Provides-Extra: docs
27
+ Requires-Dist: pdoc; extra == "docs"
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest; extra == "test"
30
+ Requires-Dist: pytest-xdist; extra == "test"
31
+ Dynamic: license-file
32
+
33
+ [![img](https://img.shields.io/github/contributors/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/graphs/contributors)
34
+ [![img](https://img.shields.io/github/forks/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/network/members)
35
+ [![img](https://img.shields.io/github/stars/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/stargazers)
36
+ [![img](https://img.shields.io/github/issues/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/issues)
37
+ [![img](https://img.shields.io/github/license/dicomstudio/PyCxx11Bindings.svg?style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/LICENSE)
38
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/test.yaml.svg?label=test&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/test.yaml)
39
+ [![img](https://img.shields.io/github/actions/workflow/status/dicomstudio/PyCxx11Bindings/release.yaml.svg?label=release&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/actions/workflows/release.yaml)
40
+ [![img](https://img.shields.io/badge/pre--commit-enabled-brightgreen.svg?logo=pre-commit&style=flat-square)](https://github.com/dicomstudio/PyCxx11Bindings/blob/main/.pre-commit-config.yaml)
41
+
42
+ [![img](https://img.shields.io/pypi/v/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
43
+ [![img](https://img.shields.io/pypi/pyversions/PyCxx11Bindings.svg?style=flat-square)](https://pypi.org/project/PyCxx11Bindings)
44
+
45
+
46
+ # PyCxx11Bindings
47
+
48
+ ## About The Project
49
+
50
+ P/Invoke provides a set of marshaling capabilities for C-style APIs, but it does not support C++ Stream/APIs directly.
51
+
52
+ ### Installation
53
+
54
+ This package is available on [PyPI](https://pypi.org/project/PyCxx11Bindings/). You install it using pip:
55
+
56
+ pip install PyCxx11Bindings
57
+
58
+ ## Contributing
59
+
60
+ Any Contributions are greatly appreciated! If you have a question, an issue or would like to contribute, please read our [contributing guidelines](CONTRIBUTING.md).
61
+
62
+ ## License
63
+
64
+ Distributed under the [MIT License](LICENSE)
65
+
66
+ ## References
67
+
68
+ * https://github.com/dicomstudio/Cxx11Bindings
@@ -0,0 +1,18 @@
1
+ .gitignore
2
+ .pre-commit-config.yaml
3
+ CHANGELOG.md
4
+ CONTRIBUTING.md
5
+ LICENSE
6
+ README.md
7
+ pyproject.toml
8
+ .github/workflows/docs.yaml
9
+ .github/workflows/pre-commit.yaml
10
+ .github/workflows/release.yaml
11
+ .github/workflows/test.yaml
12
+ src/PyCxx11Bindings.egg-info/PKG-INFO
13
+ src/PyCxx11Bindings.egg-info/SOURCES.txt
14
+ src/PyCxx11Bindings.egg-info/dependency_links.txt
15
+ src/PyCxx11Bindings.egg-info/requires.txt
16
+ src/PyCxx11Bindings.egg-info/top_level.txt
17
+ src/cxx11bindings/__init__.py
18
+ test/test_func.py
@@ -0,0 +1,17 @@
1
+
2
+ [develop]
3
+ PyCxx11Bindings[test]
4
+ commitizen
5
+ ipykernel
6
+ pre-commit
7
+ pylsp-rope
8
+ python-lsp-ruff
9
+ python-lsp-server[all]
10
+ ruff
11
+
12
+ [docs]
13
+ pdoc
14
+
15
+ [test]
16
+ pytest
17
+ pytest-xdist
@@ -0,0 +1,97 @@
1
+ """.. include:: ../../README.md"""
2
+
3
+ import ctypes
4
+
5
+
6
+ class C11Stream(ctypes.Structure): # forward declaration
7
+ pass
8
+
9
+
10
+ # Define the function pointer type
11
+ READ_CB = ctypes.CFUNCTYPE(
12
+ ctypes.c_int32,
13
+ ctypes.POINTER(C11Stream),
14
+ ctypes.POINTER(ctypes.c_uint8),
15
+ ctypes.c_int32,
16
+ )
17
+ WRITE_CB = ctypes.CFUNCTYPE(
18
+ ctypes.c_int32,
19
+ ctypes.POINTER(C11Stream),
20
+ ctypes.POINTER(ctypes.c_uint8),
21
+ ctypes.c_int32,
22
+ )
23
+ SEEK_CB = ctypes.CFUNCTYPE(
24
+ ctypes.c_int64, ctypes.POINTER(C11Stream), ctypes.c_int64, ctypes.c_int
25
+ )
26
+ FLUSH_CB = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(C11Stream))
27
+ TRUNC_CB = ctypes.CFUNCTYPE(ctypes.c_int64, ctypes.POINTER(C11Stream), ctypes.c_int64)
28
+
29
+
30
+ # now that callbacks are defined, we can define the structure:
31
+ class C11Stream(ctypes.Structure):
32
+ _fields_ = [
33
+ ("read", READ_CB), #
34
+ ("write", WRITE_CB), #
35
+ ("seek", SEEK_CB), #
36
+ ("flush", FLUSH_CB), #
37
+ ("trunc", TRUNC_CB),
38
+ ]
39
+
40
+
41
+ class PyC11Stream:
42
+ def __init__(self, file_like):
43
+ """doc."""
44
+ self._file_like = file_like
45
+ self._c11_stream = C11Stream()
46
+
47
+ def py_buf_read(_, out_buffer, count):
48
+ try:
49
+ data = self._file_like.read(count)
50
+ ctypes.memmove(out_buffer, data, len(data))
51
+ # short-read ok
52
+ return len(data)
53
+ except Exception as e:
54
+ print("Read error occurred: ", e)
55
+ return -1
56
+
57
+ def py_buf_write(_, in_buffer, count):
58
+ try:
59
+ data = ctypes.string_at(in_buffer, count)
60
+ self._file_like.write(data)
61
+ return count
62
+ except Exception as e:
63
+ print("Write error occurred: ", e)
64
+ return -1
65
+
66
+ def py_seek(_, offset, seek_dir):
67
+ try:
68
+ return self._file_like.seek(offset, seek_dir)
69
+ except Exception as e:
70
+ print("Seek error occurred: ", e)
71
+ return -1
72
+
73
+ def py_flush(_):
74
+ try:
75
+ self._file_like.flush()
76
+ return 0
77
+ except Exception as e:
78
+ print("Flush error occurred: ", e)
79
+ return -1
80
+
81
+ def py_trunc(_, new_size):
82
+ try:
83
+ self._file_like.truncate(new_size)
84
+ return new_size
85
+ except Exception as e:
86
+ print("Trunc error occurred: ", e)
87
+ return -1
88
+
89
+ self._c11_stream.read = READ_CB(py_buf_read)
90
+ self._c11_stream.write = WRITE_CB(py_buf_write)
91
+ self._c11_stream.seek = SEEK_CB(py_seek)
92
+ self._c11_stream.flush = FLUSH_CB(py_flush)
93
+ self._c11_stream.trunc = TRUNC_CB(py_trunc)
94
+
95
+ def get_stream_ptr(self):
96
+ """return the internal stream pointer"""
97
+ return ctypes.byref(self._c11_stream)
@@ -0,0 +1,12 @@
1
+ from cxx11bindings import PyC11Stream
2
+
3
+
4
+ def test_default():
5
+ filename = "default.bin"
6
+ try:
7
+ with open(filename, "wb") as f:
8
+ stream = PyC11Stream(f)
9
+ assert stream is not None
10
+ except Exception as e:
11
+ print("Error occurred: ", e)
12
+ assert False, "Failed to create PyC11Stream"