pysystemc 0.2.1__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.
- pysystemc-0.2.1/LICENSE +21 -0
- pysystemc-0.2.1/PKG-INFO +122 -0
- pysystemc-0.2.1/README.md +105 -0
- pysystemc-0.2.1/build_backend/backend.py +122 -0
- pysystemc-0.2.1/pyproject.toml +56 -0
- pysystemc-0.2.1/pyproject.toml.orig +56 -0
- pysystemc-0.2.1/src/amal/eda/systemc/__init__.py +186 -0
- pysystemc-0.2.1/src/amal/eda/systemc/_logging.py +51 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_core/__init__.py +289 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_core/binding_log.h +54 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_core/runner_log.h +38 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_core/sc_main.cpp +47 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_core/sc_module_new.cpp +116 -0
- pysystemc-0.2.1/src/amal/eda/systemc/sc_dt/__init__.py +92 -0
pysystemc-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Amal Khailtash
|
|
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.
|
pysystemc-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pysystemc
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: SystemC Python Binding using cppyy
|
|
5
|
+
Author: Amal Khailtash
|
|
6
|
+
Author-email: Amal Khailtash <amal.khailtash@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: cppyy>=3.5
|
|
10
|
+
Requires-Dist: loguru>=0.7
|
|
11
|
+
Requires-Dist: rich>=14
|
|
12
|
+
Requires-Python: >=3.14
|
|
13
|
+
Project-URL: Homepage, https://github.com/amal-khailtash/pysystemc
|
|
14
|
+
Project-URL: Documentation, https://pysystemc.readthedocs.io/
|
|
15
|
+
Project-URL: Issues, https://github.com/amal-khailtash/pysystemc/issues
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# pysystemc - SystemC python binding using cppyy
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<img src="https://raw.githubusercontent.com/amal-khailtash/pysystemc/main/docs/_static/logo-256x256.svg" alt="pysystemc — Python and SystemC with logic gates in a simulation chip" width="256"/>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
| | |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| CI/CD | [](https://github.com/amal-khailtash/pysystemc/actions/workflows/publish.yml) [](https://github.com/amal-khailtash/pysystemc/actions/workflows/readthedocs.yml) |
|
|
27
|
+
| Project | [](https://github.com/amal-khailtash/pysystemc) [](https://pypi.org/project/pysystemc/) [](https://github.com/amal-khailtash/pysystemc/tags) |
|
|
28
|
+
| Docs | [](https://pysystemc.readthedocs.io/en/latest/) |
|
|
29
|
+
| Meta | [](https://github.com/amal-khailtash/pysystemc/blob/main/LICENSE) [](https://github.com/amal-khailtash/pysystemc/stargazers) [](https://github.com/amal-khailtash/pysystemc/forks) [](https://github.com/amal-khailtash/pysystemc/graphs/contributors) |
|
|
30
|
+
| Standards | [](https://www.python.org/) [](https://semver.org/) [](https://keepachangelog.com/en/1.1.0/) |
|
|
31
|
+
|
|
32
|
+
Python bindings for [SystemC](https://systemc.org/overview/systemc/) using
|
|
33
|
+
[cppyy](https://github.com/wlav/cppyy). Write Python testbenches and modules while
|
|
34
|
+
using the native C++ simulation kernel and on-demand template instantiation.
|
|
35
|
+
The PyPI distribution is `pysystemc`; the Python import namespace is
|
|
36
|
+
`amal.eda.systemc`.
|
|
37
|
+
|
|
38
|
+
## Why Python and cppyy?
|
|
39
|
+
|
|
40
|
+
SystemC provides a C++ simulation kernel, typed channels, and a rich modeling
|
|
41
|
+
library. Python adds a convenient way to assemble models and experiment with
|
|
42
|
+
them. You can change stimulus, testbench logic, logging, waveform selection, and
|
|
43
|
+
model connections in Python, then rerun the simulation without rebuilding the
|
|
44
|
+
existing C++ model libraries.
|
|
45
|
+
|
|
46
|
+
cppyy makes native C++ classes and templates accessible from Python. For example,
|
|
47
|
+
`sc_uint[17]`, `sc_biguint[137]`, and `sc_signal[sc_uint[17]]` can be requested
|
|
48
|
+
when a script runs, rather than requiring a binding library with a predefined
|
|
49
|
+
list of types and widths. Its Cling interpreter compiles the necessary template
|
|
50
|
+
specializations and bridge code on demand. This still involves compilation, but
|
|
51
|
+
it happens within the running Python environment instead of a separate C++
|
|
52
|
+
build-and-link cycle.
|
|
53
|
+
|
|
54
|
+
Python modules can register methods and threads with the native SystemC kernel,
|
|
55
|
+
while existing C++ models continue to execute as C++. This lets a testbench load
|
|
56
|
+
configuration files, generate parameterized stimulus, inspect results, and use
|
|
57
|
+
Python analysis tools around the same simulation. SystemC still controls time,
|
|
58
|
+
delta cycles, and process scheduling; Python callbacks add overhead when the
|
|
59
|
+
simulation crosses the language boundary.
|
|
60
|
+
|
|
61
|
+
This flexibility is especially useful during exploration and verification:
|
|
62
|
+
change a test scenario or a traced signal in a script and rerun it. Changes to
|
|
63
|
+
the implementation of a compiled C++ model still require rebuilding that model.
|
|
64
|
+
SystemC's elaboration rules also still apply: most structural connections are
|
|
65
|
+
made before simulation starts. Dynamic processes can be spawned during a run,
|
|
66
|
+
but arbitrary structural changes and Python process reset are not currently
|
|
67
|
+
supported by these bindings.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Quickstart
|
|
71
|
+
|
|
72
|
+
Load Python 3.14 and install [uv](https://docs.astral.sh/uv/), then run:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
make setup
|
|
76
|
+
make example-hello-py
|
|
77
|
+
make example-counter-py
|
|
78
|
+
make test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Setup installs dependencies and builds SystemC 2.3.4 with pthreads. Existing
|
|
82
|
+
`UV_*` environment settings are honored. To run the C++ hello example, use
|
|
83
|
+
`make example-hello-cpp`.
|
|
84
|
+
|
|
85
|
+
Detailed setup, validation, and logging instructions are in the
|
|
86
|
+
[documentation](https://pysystemc.readthedocs.io/en/latest/).
|
|
87
|
+
|
|
88
|
+
## Examples
|
|
89
|
+
|
|
90
|
+
`examples/run_sysc_cpp.py` loads C++ source files and runs them through the
|
|
91
|
+
native SystemC startup wrapper.
|
|
92
|
+
|
|
93
|
+
There are a few C++ and Python examples in `examples/` directory.
|
|
94
|
+
|
|
95
|
+
Some examples adapted from:
|
|
96
|
+
* [Learn SystemC with Examples](https://www.learnsystemc.com/)
|
|
97
|
+
* [Brief SystemC getting started tutorial](https://github.com/AleksandarKostovic/SystemC-tutorial/)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
For build options, header repair, logging controls, and validation, see the
|
|
101
|
+
[development guide](https://pysystemc.readthedocs.io/en/latest/intro/development.html).
|
|
102
|
+
|
|
103
|
+
## References
|
|
104
|
+
|
|
105
|
+
* [Accellera](https://accellera.org/)
|
|
106
|
+
* [SystemC](https://github.com/accellera-official/systemc)
|
|
107
|
+
* [PySysC](https://github.com/accellera-official/PySysC) - A Python package to make SystemC usable from Python using conan/cppyy
|
|
108
|
+
* [Python and SystemC](https://workspace.accellera.org/document/dl/10968)
|
|
109
|
+
* [systemc_python](https://github.com/YouHui1/systemc_python) - use systemc through cppyy
|
|
110
|
+
* [pysc](https://github.com/ethanrobbins/pysc) - Python bindings for SystemC using pure Python API
|
|
111
|
+
* [pysc](https://github.com/socrocket/pysc) - Python SystemC implementation of USI (Universal Scripting Interface) using swig
|
|
112
|
+
* [Transparent SystemC Model Factory for
|
|
113
|
+
Scripting Languages](https://dvcon-proceedings.org/wp-content/uploads/transparent-systemc-model-factory-for-scripting-languages.pdf)
|
|
114
|
+
* [bsmedit](https://github.com/tianzhuqiao/bsmedit) - C/C++/SystemC Visualizer [docs](http://bsmedit.feiyilin.com/)
|
|
115
|
+
* [gsysc](https://github.com/werneazc/gsysc) - Graphical environment for SystemC
|
|
116
|
+
* Python binding generators
|
|
117
|
+
* [swig](https://www.swig.org/Doc1.3/Python.html) - build Python extension
|
|
118
|
+
* [cppyy](https://github.com/wlav/cppyy) - Python-C++ bindings interface based on Cling/LLVM
|
|
119
|
+
* [pybind11](https://pybind11.readthedocs.io/en/stable)
|
|
120
|
+
* [CFFI](https://cffi.readthedocs.io/en/stable/)
|
|
121
|
+
* [Boost.Python](https://www.boost.org/doc/libs/1_86_0/libs/python/doc/html/index.html)
|
|
122
|
+
* [Shiboken](https://doc.qt.io/qtforpython-6/shiboken6/index.html)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# pysystemc - SystemC python binding using cppyy
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/amal-khailtash/pysystemc/main/docs/_static/logo-256x256.svg" alt="pysystemc — Python and SystemC with logic gates in a simulation chip" width="256"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| CI/CD | [](https://github.com/amal-khailtash/pysystemc/actions/workflows/publish.yml) [](https://github.com/amal-khailtash/pysystemc/actions/workflows/readthedocs.yml) |
|
|
10
|
+
| Project | [](https://github.com/amal-khailtash/pysystemc) [](https://pypi.org/project/pysystemc/) [](https://github.com/amal-khailtash/pysystemc/tags) |
|
|
11
|
+
| Docs | [](https://pysystemc.readthedocs.io/en/latest/) |
|
|
12
|
+
| Meta | [](https://github.com/amal-khailtash/pysystemc/blob/main/LICENSE) [](https://github.com/amal-khailtash/pysystemc/stargazers) [](https://github.com/amal-khailtash/pysystemc/forks) [](https://github.com/amal-khailtash/pysystemc/graphs/contributors) |
|
|
13
|
+
| Standards | [](https://www.python.org/) [](https://semver.org/) [](https://keepachangelog.com/en/1.1.0/) |
|
|
14
|
+
|
|
15
|
+
Python bindings for [SystemC](https://systemc.org/overview/systemc/) using
|
|
16
|
+
[cppyy](https://github.com/wlav/cppyy). Write Python testbenches and modules while
|
|
17
|
+
using the native C++ simulation kernel and on-demand template instantiation.
|
|
18
|
+
The PyPI distribution is `pysystemc`; the Python import namespace is
|
|
19
|
+
`amal.eda.systemc`.
|
|
20
|
+
|
|
21
|
+
## Why Python and cppyy?
|
|
22
|
+
|
|
23
|
+
SystemC provides a C++ simulation kernel, typed channels, and a rich modeling
|
|
24
|
+
library. Python adds a convenient way to assemble models and experiment with
|
|
25
|
+
them. You can change stimulus, testbench logic, logging, waveform selection, and
|
|
26
|
+
model connections in Python, then rerun the simulation without rebuilding the
|
|
27
|
+
existing C++ model libraries.
|
|
28
|
+
|
|
29
|
+
cppyy makes native C++ classes and templates accessible from Python. For example,
|
|
30
|
+
`sc_uint[17]`, `sc_biguint[137]`, and `sc_signal[sc_uint[17]]` can be requested
|
|
31
|
+
when a script runs, rather than requiring a binding library with a predefined
|
|
32
|
+
list of types and widths. Its Cling interpreter compiles the necessary template
|
|
33
|
+
specializations and bridge code on demand. This still involves compilation, but
|
|
34
|
+
it happens within the running Python environment instead of a separate C++
|
|
35
|
+
build-and-link cycle.
|
|
36
|
+
|
|
37
|
+
Python modules can register methods and threads with the native SystemC kernel,
|
|
38
|
+
while existing C++ models continue to execute as C++. This lets a testbench load
|
|
39
|
+
configuration files, generate parameterized stimulus, inspect results, and use
|
|
40
|
+
Python analysis tools around the same simulation. SystemC still controls time,
|
|
41
|
+
delta cycles, and process scheduling; Python callbacks add overhead when the
|
|
42
|
+
simulation crosses the language boundary.
|
|
43
|
+
|
|
44
|
+
This flexibility is especially useful during exploration and verification:
|
|
45
|
+
change a test scenario or a traced signal in a script and rerun it. Changes to
|
|
46
|
+
the implementation of a compiled C++ model still require rebuilding that model.
|
|
47
|
+
SystemC's elaboration rules also still apply: most structural connections are
|
|
48
|
+
made before simulation starts. Dynamic processes can be spawned during a run,
|
|
49
|
+
but arbitrary structural changes and Python process reset are not currently
|
|
50
|
+
supported by these bindings.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Quickstart
|
|
54
|
+
|
|
55
|
+
Load Python 3.14 and install [uv](https://docs.astral.sh/uv/), then run:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
make setup
|
|
59
|
+
make example-hello-py
|
|
60
|
+
make example-counter-py
|
|
61
|
+
make test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Setup installs dependencies and builds SystemC 2.3.4 with pthreads. Existing
|
|
65
|
+
`UV_*` environment settings are honored. To run the C++ hello example, use
|
|
66
|
+
`make example-hello-cpp`.
|
|
67
|
+
|
|
68
|
+
Detailed setup, validation, and logging instructions are in the
|
|
69
|
+
[documentation](https://pysystemc.readthedocs.io/en/latest/).
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
`examples/run_sysc_cpp.py` loads C++ source files and runs them through the
|
|
74
|
+
native SystemC startup wrapper.
|
|
75
|
+
|
|
76
|
+
There are a few C++ and Python examples in `examples/` directory.
|
|
77
|
+
|
|
78
|
+
Some examples adapted from:
|
|
79
|
+
* [Learn SystemC with Examples](https://www.learnsystemc.com/)
|
|
80
|
+
* [Brief SystemC getting started tutorial](https://github.com/AleksandarKostovic/SystemC-tutorial/)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
For build options, header repair, logging controls, and validation, see the
|
|
84
|
+
[development guide](https://pysystemc.readthedocs.io/en/latest/intro/development.html).
|
|
85
|
+
|
|
86
|
+
## References
|
|
87
|
+
|
|
88
|
+
* [Accellera](https://accellera.org/)
|
|
89
|
+
* [SystemC](https://github.com/accellera-official/systemc)
|
|
90
|
+
* [PySysC](https://github.com/accellera-official/PySysC) - A Python package to make SystemC usable from Python using conan/cppyy
|
|
91
|
+
* [Python and SystemC](https://workspace.accellera.org/document/dl/10968)
|
|
92
|
+
* [systemc_python](https://github.com/YouHui1/systemc_python) - use systemc through cppyy
|
|
93
|
+
* [pysc](https://github.com/ethanrobbins/pysc) - Python bindings for SystemC using pure Python API
|
|
94
|
+
* [pysc](https://github.com/socrocket/pysc) - Python SystemC implementation of USI (Universal Scripting Interface) using swig
|
|
95
|
+
* [Transparent SystemC Model Factory for
|
|
96
|
+
Scripting Languages](https://dvcon-proceedings.org/wp-content/uploads/transparent-systemc-model-factory-for-scripting-languages.pdf)
|
|
97
|
+
* [bsmedit](https://github.com/tianzhuqiao/bsmedit) - C/C++/SystemC Visualizer [docs](http://bsmedit.feiyilin.com/)
|
|
98
|
+
* [gsysc](https://github.com/werneazc/gsysc) - Graphical environment for SystemC
|
|
99
|
+
* Python binding generators
|
|
100
|
+
* [swig](https://www.swig.org/Doc1.3/Python.html) - build Python extension
|
|
101
|
+
* [cppyy](https://github.com/wlav/cppyy) - Python-C++ bindings interface based on Cling/LLVM
|
|
102
|
+
* [pybind11](https://pybind11.readthedocs.io/en/stable)
|
|
103
|
+
* [CFFI](https://cffi.readthedocs.io/en/stable/)
|
|
104
|
+
* [Boost.Python](https://www.boost.org/doc/libs/1_86_0/libs/python/doc/html/index.html)
|
|
105
|
+
* [Shiboken](https://doc.qt.io/qtforpython-6/shiboken6/index.html)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""PEP 517 backend: build native dependencies, then package through uv_build."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import sysconfig
|
|
7
|
+
import tarfile
|
|
8
|
+
import zipfile
|
|
9
|
+
import csv
|
|
10
|
+
import hashlib
|
|
11
|
+
import base64
|
|
12
|
+
import io
|
|
13
|
+
import uv_build
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
16
|
+
NATIVE = ROOT / "build/package-native"
|
|
17
|
+
VERSIONS = {"fmt": "11.2.0", "spdlog": "1.15.3", "systemc": "2.3.4"}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _run(*args):
|
|
21
|
+
"""Execute a native build command and propagate failures."""
|
|
22
|
+
subprocess.run(args, check=True)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _source(name):
|
|
26
|
+
"""Fetch a pinned source archive into the local build cache."""
|
|
27
|
+
version = VERSIONS[name]
|
|
28
|
+
cache = ROOT / "build/deps"
|
|
29
|
+
cache.mkdir(parents=True, exist_ok=True)
|
|
30
|
+
directory = cache / f"{name}-{version}"
|
|
31
|
+
if not directory.exists():
|
|
32
|
+
repositories = {"fmt": "fmtlib/fmt", "spdlog": "gabime/spdlog",
|
|
33
|
+
"systemc": "accellera-official/systemc"}
|
|
34
|
+
tag = f"v{version}" if name == "spdlog" else version
|
|
35
|
+
archive = cache / f"{name}-{version}.tar.gz"
|
|
36
|
+
if not archive.exists():
|
|
37
|
+
_run("curl", "--fail", "--location", "--retry", "3",
|
|
38
|
+
f"https://github.com/{repositories[name]}/archive/refs/tags/{tag}.tar.gz",
|
|
39
|
+
"--output", str(archive))
|
|
40
|
+
with tarfile.open(archive) as stream:
|
|
41
|
+
stream.extractall(cache, filter="data")
|
|
42
|
+
return directory
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _native():
|
|
46
|
+
"""Compile/install fmt, spdlog and pthreads SystemC into package resources."""
|
|
47
|
+
NATIVE.mkdir(parents=True, exist_ok=True)
|
|
48
|
+
for name in VERSIONS:
|
|
49
|
+
source = _source(name)
|
|
50
|
+
build = ROOT / "build/deps" / f"package-{name}"
|
|
51
|
+
options = [f"-DCMAKE_INSTALL_PREFIX={NATIVE}", "-DCMAKE_INSTALL_LIBDIR=lib",
|
|
52
|
+
"-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_CXX_STANDARD=17",
|
|
53
|
+
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
|
|
54
|
+
"-DCMAKE_SKIP_RPATH=ON",
|
|
55
|
+
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5"]
|
|
56
|
+
if name == "systemc":
|
|
57
|
+
options += ["-DENABLE_PTHREADS=ON", "-DBUILD_SHARED_LIBS=ON"]
|
|
58
|
+
elif name == "fmt":
|
|
59
|
+
options += ["-DFMT_TEST=OFF", "-DFMT_DOC=OFF"]
|
|
60
|
+
else:
|
|
61
|
+
options += ["-DSPDLOG_FMT_EXTERNAL=ON", f"-DCMAKE_PREFIX_PATH={NATIVE}",
|
|
62
|
+
"-DSPDLOG_BUILD_TESTS=OFF", "-DSPDLOG_BUILD_EXAMPLE=OFF"]
|
|
63
|
+
_run("cmake", "-S", str(source), "-B", str(build), *options)
|
|
64
|
+
_run("cmake", "--build", str(build), "-j", os.environ.get("BUILD_JOBS", "4"))
|
|
65
|
+
_run("cmake", "--install", str(build))
|
|
66
|
+
notices = NATIVE / "licenses" / name
|
|
67
|
+
notices.mkdir(parents=True, exist_ok=True)
|
|
68
|
+
for file in ("LICENSE", "LICENSE.rst", "NOTICE"):
|
|
69
|
+
if (source / file).exists():
|
|
70
|
+
shutil.copy2(source / file, notices / file)
|
|
71
|
+
if name == "systemc":
|
|
72
|
+
target = NATIVE / "src/sysc/kernel"
|
|
73
|
+
target.mkdir(parents=True, exist_ok=True)
|
|
74
|
+
shutil.copy2(source / "src/sysc/kernel/sc_main_main.cpp", target)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
|
|
78
|
+
"""Build native resources and emit a platform-specific wheel with uv_build."""
|
|
79
|
+
_native()
|
|
80
|
+
original = uv_build.build_wheel(wheel_directory, config_settings, metadata_directory)
|
|
81
|
+
path = Path(wheel_directory) / original
|
|
82
|
+
tag = "py3-none-" + sysconfig.get_platform().replace("-", "_").replace(".", "_")
|
|
83
|
+
target = path.with_name(original.replace("py3-none-any", tag))
|
|
84
|
+
with zipfile.ZipFile(path) as archive:
|
|
85
|
+
# Directory entries are ZIP structure, not installed files. Including
|
|
86
|
+
# them in RECORD makes auditwheel attempt to read a directory as ELF.
|
|
87
|
+
files = {name: archive.read(name) for name in archive.namelist()
|
|
88
|
+
if not name.endswith(("/", "/RECORD"))}
|
|
89
|
+
for resource in NATIVE.rglob("*"):
|
|
90
|
+
if resource.is_file():
|
|
91
|
+
# Installed CMake/pkg-config files refer to the build prefix and
|
|
92
|
+
# are unnecessary for cppyy's runtime header/library discovery.
|
|
93
|
+
if any(part in ("cmake", "pkgconfig") for part in resource.relative_to(NATIVE).parts):
|
|
94
|
+
continue
|
|
95
|
+
files["amal/eda/systemc/_native/" + resource.relative_to(NATIVE).as_posix()] = resource.read_bytes()
|
|
96
|
+
for name in files:
|
|
97
|
+
if name.endswith("/WHEEL"):
|
|
98
|
+
files[name] = files[name].replace(b"Root-Is-Purelib: true", b"Root-Is-Purelib: false").replace(b"py3-none-any", tag.encode())
|
|
99
|
+
records = io.StringIO()
|
|
100
|
+
writer = csv.writer(records, lineterminator="\n")
|
|
101
|
+
for name, data in files.items():
|
|
102
|
+
digest = base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b"=").decode()
|
|
103
|
+
writer.writerow([name, "sha256=" + digest, len(data)])
|
|
104
|
+
record = next(name.rsplit("/", 1)[0] + "/RECORD" for name in files if name.endswith("/WHEEL"))
|
|
105
|
+
writer.writerow([record, "", ""])
|
|
106
|
+
with zipfile.ZipFile(target, "w", zipfile.ZIP_DEFLATED) as archive:
|
|
107
|
+
for name, data in files.items():
|
|
108
|
+
archive.writestr(name, data)
|
|
109
|
+
archive.writestr(record, records.getvalue())
|
|
110
|
+
path.unlink()
|
|
111
|
+
return target.name
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def build_sdist(sdist_directory, config_settings=None):
|
|
115
|
+
"""Ship portable source/build instructions; compile on wheel construction."""
|
|
116
|
+
return uv_build.build_sdist(sdist_directory, config_settings)
|
|
117
|
+
|
|
118
|
+
build_editable = uv_build.build_editable
|
|
119
|
+
prepare_metadata_for_build_wheel = uv_build.prepare_metadata_for_build_wheel
|
|
120
|
+
get_requires_for_build_wheel = uv_build.get_requires_for_build_wheel
|
|
121
|
+
get_requires_for_build_sdist = uv_build.get_requires_for_build_sdist
|
|
122
|
+
get_requires_for_build_editable = uv_build.get_requires_for_build_editable
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pysystemc"
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "SystemC Python Binding using cppyy"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.14"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"cppyy>=3.5",
|
|
11
|
+
"loguru>=0.7",
|
|
12
|
+
"rich>=14",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[[project.authors]]
|
|
16
|
+
name = "Amal Khailtash"
|
|
17
|
+
email = "amal.khailtash@gmail.com"
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/amal-khailtash/pysystemc"
|
|
21
|
+
Documentation = "https://pysystemc.readthedocs.io/"
|
|
22
|
+
Issues = "https://github.com/amal-khailtash/pysystemc/issues"
|
|
23
|
+
|
|
24
|
+
[tool.uv.build-backend]
|
|
25
|
+
module-name = "amal"
|
|
26
|
+
namespace = true
|
|
27
|
+
source-include = ["build_backend/**"]
|
|
28
|
+
source-exclude = ["src/amal/eda/systemc/_native/**"]
|
|
29
|
+
|
|
30
|
+
[tool.coverage.run]
|
|
31
|
+
source = ["amal.eda.systemc"]
|
|
32
|
+
patch = ["subprocess"]
|
|
33
|
+
disable_warnings = [
|
|
34
|
+
"module-not-imported",
|
|
35
|
+
"no-data-collected",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = [
|
|
40
|
+
"uv_build>=0.9,<0.14",
|
|
41
|
+
"cmake>=3.20",
|
|
42
|
+
]
|
|
43
|
+
build-backend = "backend"
|
|
44
|
+
backend-path = ["build_backend"]
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"pytest>=8.3.4",
|
|
49
|
+
"pytest-cov>=7.0",
|
|
50
|
+
{ include-group = "docs" },
|
|
51
|
+
]
|
|
52
|
+
docs = [
|
|
53
|
+
"sphinx>=8",
|
|
54
|
+
"myst-parser>=4",
|
|
55
|
+
"sphinx-rtd-theme>=3",
|
|
56
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pysystemc"
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "SystemC Python Binding using cppyy"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Amal Khailtash", email = "amal.khailtash@gmail.com" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.14"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"cppyy>=3.5",
|
|
14
|
+
"loguru>=0.7",
|
|
15
|
+
"rich>=14",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/amal-khailtash/pysystemc"
|
|
20
|
+
Documentation = "https://pysystemc.readthedocs.io/"
|
|
21
|
+
Issues = "https://github.com/amal-khailtash/pysystemc/issues"
|
|
22
|
+
|
|
23
|
+
# [project.scripts]
|
|
24
|
+
# pysystemc = "amal.eda.systemc:main"
|
|
25
|
+
|
|
26
|
+
[tool.uv.build-backend]
|
|
27
|
+
module-name = "amal"
|
|
28
|
+
namespace = true
|
|
29
|
+
source-include = ["build_backend/**"]
|
|
30
|
+
source-exclude = ["src/amal/eda/systemc/_native/**"]
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = ["uv_build>=0.9,<0.14", "cmake>=3.20"]
|
|
34
|
+
build-backend = "backend"
|
|
35
|
+
backend-path = ["build_backend"]
|
|
36
|
+
|
|
37
|
+
[dependency-groups]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=8.3.4",
|
|
40
|
+
"pytest-cov>=7.0",
|
|
41
|
+
{ include-group = "docs" },
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
docs = [
|
|
45
|
+
"sphinx>=8",
|
|
46
|
+
"myst-parser>=4",
|
|
47
|
+
"sphinx-rtd-theme>=3",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
# Simulation tests spawn fresh interpreters to isolate SystemC kernel state.
|
|
51
|
+
[tool.coverage.run]
|
|
52
|
+
source = ["amal.eda.systemc"]
|
|
53
|
+
patch = ["subprocess"]
|
|
54
|
+
# The pytest parent intentionally never imports the singleton native kernel;
|
|
55
|
+
# coverage data is collected by its simulation subprocesses instead.
|
|
56
|
+
disable_warnings = ["module-not-imported", "no-data-collected"]
|