IncludeCPP 1.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.
- includecpp-1.2.1/IncludeCPP.egg-info/PKG-INFO +182 -0
- includecpp-1.2.1/IncludeCPP.egg-info/SOURCES.txt +38 -0
- includecpp-1.2.1/IncludeCPP.egg-info/dependency_links.txt +1 -0
- includecpp-1.2.1/IncludeCPP.egg-info/entry_points.txt +2 -0
- includecpp-1.2.1/IncludeCPP.egg-info/requires.txt +3 -0
- includecpp-1.2.1/IncludeCPP.egg-info/top_level.txt +1 -0
- includecpp-1.2.1/LICENSE +21 -0
- includecpp-1.2.1/MANIFEST.in +6 -0
- includecpp-1.2.1/PKG-INFO +182 -0
- includecpp-1.2.1/README.md +146 -0
- includecpp-1.2.1/includecpp/__init__.py +4 -0
- includecpp-1.2.1/includecpp/__main__.py +4 -0
- includecpp-1.2.1/includecpp/cli/__init__.py +4 -0
- includecpp-1.2.1/includecpp/cli/commands.py +85 -0
- includecpp-1.2.1/includecpp/cli/config_parser.py +110 -0
- includecpp-1.2.1/includecpp/core/__init__.py +19 -0
- includecpp-1.2.1/includecpp/core/build_manager.py +592 -0
- includecpp-1.2.1/includecpp/core/cpp_api.py +146 -0
- includecpp-1.2.1/includecpp/core/exceptions.py +97 -0
- includecpp-1.2.1/includecpp/generator/__init__.py +1 -0
- includecpp-1.2.1/includecpp/generator/parser.cpp +590 -0
- includecpp-1.2.1/includecpp/generator/parser.h +107 -0
- includecpp-1.2.1/includecpp/templates/cpp.proj.template +18 -0
- includecpp-1.2.1/pyproject.toml +51 -0
- includecpp-1.2.1/requirements.txt +3 -0
- includecpp-1.2.1/setup.cfg +4 -0
- includecpp-1.2.1/setup.py +54 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: IncludeCPP
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: Professional C++ Python bindings with type-generic templates and native threading
|
|
5
|
+
Home-page: https://github.com/includecpp/includecpp
|
|
6
|
+
Author: IncludeCPP Team
|
|
7
|
+
Author-email: IncludeCPP Team <contact@includecpp.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/includecpp/includecpp
|
|
10
|
+
Project-URL: Documentation, https://includecpp.readthedocs.io
|
|
11
|
+
Project-URL: Repository, https://github.com/includecpp/includecpp
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/includecpp/includecpp/issues
|
|
13
|
+
Keywords: c++,python,bindings,pybind11,template,performance,threading
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: C++
|
|
24
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: pybind11>=2.11.0
|
|
30
|
+
Requires-Dist: click>=8.0.0
|
|
31
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
|
|
37
|
+
# IncludeCPP - Professional C++ Python Bindings
|
|
38
|
+
|
|
39
|
+
Professional C++ ↔ Python binding system with type-generic templates, native threading support, and maximum performance.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Type-Generic System**: Functions work with ANY type automatically
|
|
44
|
+
```python
|
|
45
|
+
algorithms.fast_sort([1,2,3]) # int version
|
|
46
|
+
algorithms.fast_sort([1.5, 2.3]) # float version
|
|
47
|
+
algorithms.fast_sort(["a","b"]) # string version
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **Native Threading with GIL Release**: True parallelism
|
|
51
|
+
```python
|
|
52
|
+
game = CPP.include("threading").GameEngine()
|
|
53
|
+
CPP.threadThis(game) # Runs in C++ thread with GIL released
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- **Dynamic Configuration**: `cpp.proj` JSON configuration
|
|
57
|
+
- **AppData Build System**: Clean separation of project and build artifacts
|
|
58
|
+
- **CLI Tool**: `includecpp --rebuild` for easy building
|
|
59
|
+
- **Zero Overhead**: Template instantiation eliminates runtime overhead
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install IncludeCPP
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### 1. Initialize Project
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd YourProject
|
|
73
|
+
includecpp init
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This creates:
|
|
77
|
+
- `cpp.proj` - Configuration file
|
|
78
|
+
- `include/` - Your C++ source files
|
|
79
|
+
- `plugins/` - Plugin definitions (.cp files)
|
|
80
|
+
|
|
81
|
+
### 2. Create C++ Module
|
|
82
|
+
|
|
83
|
+
**include/mymodule.cpp**:
|
|
84
|
+
```cpp
|
|
85
|
+
#include <vector>
|
|
86
|
+
#include <algorithm>
|
|
87
|
+
|
|
88
|
+
namespace includecpp {
|
|
89
|
+
|
|
90
|
+
std::vector<int> custom_sort(const std::vector<int>& data) {
|
|
91
|
+
std::vector<int> result = data;
|
|
92
|
+
std::sort(result.begin(), result.end());
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**plugins/mymodule.cp**:
|
|
100
|
+
```
|
|
101
|
+
SOURCE(include/mymodule.cpp) mymodule
|
|
102
|
+
|
|
103
|
+
PUBLIC(
|
|
104
|
+
mymodule FUNC(custom_sort)
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 3. Build
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
includecpp --rebuild
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Build artifacts go to:
|
|
115
|
+
- **Windows**: `%APPDATA%/YourProject&gcc-build-proj/`
|
|
116
|
+
- **Linux**: `~/.local/share/includecpp/YourProject&gcc-build-proj/`
|
|
117
|
+
|
|
118
|
+
### 4. Use in Python
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import IncludeCPP as cpp
|
|
122
|
+
|
|
123
|
+
CPP = cpp.CppApi()
|
|
124
|
+
CPP.noFeedback() # Disable warnings
|
|
125
|
+
|
|
126
|
+
mymodule = CPP.include("mymodule")
|
|
127
|
+
result = mymodule.custom_sort([5, 2, 9, 1])
|
|
128
|
+
print(result) # [1, 2, 5, 9]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Type-Generic Templates
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
# plugins/algorithms.cp
|
|
135
|
+
SOURCE(include/algorithms.cpp) && HEADER(include/algorithms.h) algorithms
|
|
136
|
+
|
|
137
|
+
PUBLIC(
|
|
138
|
+
algorithms TEMPLATE_FUNC(fast_sort) TYPES(int, float, double, string)
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
**cpp.proj** (auto-created by `includecpp init`):
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"project": "MyProject",
|
|
148
|
+
"version": "1.0.0",
|
|
149
|
+
"include": "/include",
|
|
150
|
+
"plugins": "/plugins",
|
|
151
|
+
"compiler": {
|
|
152
|
+
"standard": "c++17",
|
|
153
|
+
"optimization": "O3",
|
|
154
|
+
"flags": ["-Wall", "-pthread"]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Requirements
|
|
160
|
+
|
|
161
|
+
- Python >= 3.8
|
|
162
|
+
- C++ compiler (g++, clang++, or MSVC)
|
|
163
|
+
- pybind11 >= 2.11.0
|
|
164
|
+
- CMake >= 3.15
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT License
|
|
169
|
+
|
|
170
|
+
## Links
|
|
171
|
+
|
|
172
|
+
- **Documentation**: https://includecpp.readthedocs.io
|
|
173
|
+
- **GitHub**: https://github.com/includecpp/includecpp
|
|
174
|
+
- **PyPI**: https://pypi.org/project/IncludeCPP
|
|
175
|
+
|
|
176
|
+
## Example: Complete Module
|
|
177
|
+
|
|
178
|
+
See the `examples/` directory for complete working examples including:
|
|
179
|
+
- Type-generic algorithms
|
|
180
|
+
- Threading with GIL release
|
|
181
|
+
- Map and Array containers
|
|
182
|
+
- Custom C++ classes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
requirements.txt
|
|
6
|
+
setup.py
|
|
7
|
+
./includecpp/__init__.py
|
|
8
|
+
./includecpp/__main__.py
|
|
9
|
+
./includecpp/cli/__init__.py
|
|
10
|
+
./includecpp/cli/commands.py
|
|
11
|
+
./includecpp/cli/config_parser.py
|
|
12
|
+
./includecpp/core/__init__.py
|
|
13
|
+
./includecpp/core/build_manager.py
|
|
14
|
+
./includecpp/core/cpp_api.py
|
|
15
|
+
./includecpp/core/exceptions.py
|
|
16
|
+
./includecpp/generator/__init__.py
|
|
17
|
+
./includecpp/generator/parser.cpp
|
|
18
|
+
./includecpp/generator/parser.h
|
|
19
|
+
./includecpp/templates/cpp.proj.template
|
|
20
|
+
IncludeCPP.egg-info/PKG-INFO
|
|
21
|
+
IncludeCPP.egg-info/SOURCES.txt
|
|
22
|
+
IncludeCPP.egg-info/dependency_links.txt
|
|
23
|
+
IncludeCPP.egg-info/entry_points.txt
|
|
24
|
+
IncludeCPP.egg-info/requires.txt
|
|
25
|
+
IncludeCPP.egg-info/top_level.txt
|
|
26
|
+
includecpp/__init__.py
|
|
27
|
+
includecpp/__main__.py
|
|
28
|
+
includecpp/cli/__init__.py
|
|
29
|
+
includecpp/cli/commands.py
|
|
30
|
+
includecpp/cli/config_parser.py
|
|
31
|
+
includecpp/core/__init__.py
|
|
32
|
+
includecpp/core/build_manager.py
|
|
33
|
+
includecpp/core/cpp_api.py
|
|
34
|
+
includecpp/core/exceptions.py
|
|
35
|
+
includecpp/generator/__init__.py
|
|
36
|
+
includecpp/generator/parser.cpp
|
|
37
|
+
includecpp/generator/parser.h
|
|
38
|
+
includecpp/templates/cpp.proj.template
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
includecpp
|
includecpp-1.2.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 IncludeCPP Team
|
|
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,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: IncludeCPP
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: Professional C++ Python bindings with type-generic templates and native threading
|
|
5
|
+
Home-page: https://github.com/includecpp/includecpp
|
|
6
|
+
Author: IncludeCPP Team
|
|
7
|
+
Author-email: IncludeCPP Team <contact@includecpp.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/includecpp/includecpp
|
|
10
|
+
Project-URL: Documentation, https://includecpp.readthedocs.io
|
|
11
|
+
Project-URL: Repository, https://github.com/includecpp/includecpp
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/includecpp/includecpp/issues
|
|
13
|
+
Keywords: c++,python,bindings,pybind11,template,performance,threading
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: C++
|
|
24
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: pybind11>=2.11.0
|
|
30
|
+
Requires-Dist: click>=8.0.0
|
|
31
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
32
|
+
Dynamic: author
|
|
33
|
+
Dynamic: home-page
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
|
|
37
|
+
# IncludeCPP - Professional C++ Python Bindings
|
|
38
|
+
|
|
39
|
+
Professional C++ ↔ Python binding system with type-generic templates, native threading support, and maximum performance.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Type-Generic System**: Functions work with ANY type automatically
|
|
44
|
+
```python
|
|
45
|
+
algorithms.fast_sort([1,2,3]) # int version
|
|
46
|
+
algorithms.fast_sort([1.5, 2.3]) # float version
|
|
47
|
+
algorithms.fast_sort(["a","b"]) # string version
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **Native Threading with GIL Release**: True parallelism
|
|
51
|
+
```python
|
|
52
|
+
game = CPP.include("threading").GameEngine()
|
|
53
|
+
CPP.threadThis(game) # Runs in C++ thread with GIL released
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- **Dynamic Configuration**: `cpp.proj` JSON configuration
|
|
57
|
+
- **AppData Build System**: Clean separation of project and build artifacts
|
|
58
|
+
- **CLI Tool**: `includecpp --rebuild` for easy building
|
|
59
|
+
- **Zero Overhead**: Template instantiation eliminates runtime overhead
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install IncludeCPP
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### 1. Initialize Project
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd YourProject
|
|
73
|
+
includecpp init
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This creates:
|
|
77
|
+
- `cpp.proj` - Configuration file
|
|
78
|
+
- `include/` - Your C++ source files
|
|
79
|
+
- `plugins/` - Plugin definitions (.cp files)
|
|
80
|
+
|
|
81
|
+
### 2. Create C++ Module
|
|
82
|
+
|
|
83
|
+
**include/mymodule.cpp**:
|
|
84
|
+
```cpp
|
|
85
|
+
#include <vector>
|
|
86
|
+
#include <algorithm>
|
|
87
|
+
|
|
88
|
+
namespace includecpp {
|
|
89
|
+
|
|
90
|
+
std::vector<int> custom_sort(const std::vector<int>& data) {
|
|
91
|
+
std::vector<int> result = data;
|
|
92
|
+
std::sort(result.begin(), result.end());
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**plugins/mymodule.cp**:
|
|
100
|
+
```
|
|
101
|
+
SOURCE(include/mymodule.cpp) mymodule
|
|
102
|
+
|
|
103
|
+
PUBLIC(
|
|
104
|
+
mymodule FUNC(custom_sort)
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 3. Build
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
includecpp --rebuild
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Build artifacts go to:
|
|
115
|
+
- **Windows**: `%APPDATA%/YourProject&gcc-build-proj/`
|
|
116
|
+
- **Linux**: `~/.local/share/includecpp/YourProject&gcc-build-proj/`
|
|
117
|
+
|
|
118
|
+
### 4. Use in Python
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import IncludeCPP as cpp
|
|
122
|
+
|
|
123
|
+
CPP = cpp.CppApi()
|
|
124
|
+
CPP.noFeedback() # Disable warnings
|
|
125
|
+
|
|
126
|
+
mymodule = CPP.include("mymodule")
|
|
127
|
+
result = mymodule.custom_sort([5, 2, 9, 1])
|
|
128
|
+
print(result) # [1, 2, 5, 9]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Type-Generic Templates
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
# plugins/algorithms.cp
|
|
135
|
+
SOURCE(include/algorithms.cpp) && HEADER(include/algorithms.h) algorithms
|
|
136
|
+
|
|
137
|
+
PUBLIC(
|
|
138
|
+
algorithms TEMPLATE_FUNC(fast_sort) TYPES(int, float, double, string)
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Configuration
|
|
143
|
+
|
|
144
|
+
**cpp.proj** (auto-created by `includecpp init`):
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"project": "MyProject",
|
|
148
|
+
"version": "1.0.0",
|
|
149
|
+
"include": "/include",
|
|
150
|
+
"plugins": "/plugins",
|
|
151
|
+
"compiler": {
|
|
152
|
+
"standard": "c++17",
|
|
153
|
+
"optimization": "O3",
|
|
154
|
+
"flags": ["-Wall", "-pthread"]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Requirements
|
|
160
|
+
|
|
161
|
+
- Python >= 3.8
|
|
162
|
+
- C++ compiler (g++, clang++, or MSVC)
|
|
163
|
+
- pybind11 >= 2.11.0
|
|
164
|
+
- CMake >= 3.15
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT License
|
|
169
|
+
|
|
170
|
+
## Links
|
|
171
|
+
|
|
172
|
+
- **Documentation**: https://includecpp.readthedocs.io
|
|
173
|
+
- **GitHub**: https://github.com/includecpp/includecpp
|
|
174
|
+
- **PyPI**: https://pypi.org/project/IncludeCPP
|
|
175
|
+
|
|
176
|
+
## Example: Complete Module
|
|
177
|
+
|
|
178
|
+
See the `examples/` directory for complete working examples including:
|
|
179
|
+
- Type-generic algorithms
|
|
180
|
+
- Threading with GIL release
|
|
181
|
+
- Map and Array containers
|
|
182
|
+
- Custom C++ classes
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# IncludeCPP - Professional C++ Python Bindings
|
|
2
|
+
|
|
3
|
+
Professional C++ ↔ Python binding system with type-generic templates, native threading support, and maximum performance.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Type-Generic System**: Functions work with ANY type automatically
|
|
8
|
+
```python
|
|
9
|
+
algorithms.fast_sort([1,2,3]) # int version
|
|
10
|
+
algorithms.fast_sort([1.5, 2.3]) # float version
|
|
11
|
+
algorithms.fast_sort(["a","b"]) # string version
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- **Native Threading with GIL Release**: True parallelism
|
|
15
|
+
```python
|
|
16
|
+
game = CPP.include("threading").GameEngine()
|
|
17
|
+
CPP.threadThis(game) # Runs in C++ thread with GIL released
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **Dynamic Configuration**: `cpp.proj` JSON configuration
|
|
21
|
+
- **AppData Build System**: Clean separation of project and build artifacts
|
|
22
|
+
- **CLI Tool**: `includecpp --rebuild` for easy building
|
|
23
|
+
- **Zero Overhead**: Template instantiation eliminates runtime overhead
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install IncludeCPP
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### 1. Initialize Project
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd YourProject
|
|
37
|
+
includecpp init
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This creates:
|
|
41
|
+
- `cpp.proj` - Configuration file
|
|
42
|
+
- `include/` - Your C++ source files
|
|
43
|
+
- `plugins/` - Plugin definitions (.cp files)
|
|
44
|
+
|
|
45
|
+
### 2. Create C++ Module
|
|
46
|
+
|
|
47
|
+
**include/mymodule.cpp**:
|
|
48
|
+
```cpp
|
|
49
|
+
#include <vector>
|
|
50
|
+
#include <algorithm>
|
|
51
|
+
|
|
52
|
+
namespace includecpp {
|
|
53
|
+
|
|
54
|
+
std::vector<int> custom_sort(const std::vector<int>& data) {
|
|
55
|
+
std::vector<int> result = data;
|
|
56
|
+
std::sort(result.begin(), result.end());
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**plugins/mymodule.cp**:
|
|
64
|
+
```
|
|
65
|
+
SOURCE(include/mymodule.cpp) mymodule
|
|
66
|
+
|
|
67
|
+
PUBLIC(
|
|
68
|
+
mymodule FUNC(custom_sort)
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Build
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
includecpp --rebuild
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Build artifacts go to:
|
|
79
|
+
- **Windows**: `%APPDATA%/YourProject&gcc-build-proj/`
|
|
80
|
+
- **Linux**: `~/.local/share/includecpp/YourProject&gcc-build-proj/`
|
|
81
|
+
|
|
82
|
+
### 4. Use in Python
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import IncludeCPP as cpp
|
|
86
|
+
|
|
87
|
+
CPP = cpp.CppApi()
|
|
88
|
+
CPP.noFeedback() # Disable warnings
|
|
89
|
+
|
|
90
|
+
mymodule = CPP.include("mymodule")
|
|
91
|
+
result = mymodule.custom_sort([5, 2, 9, 1])
|
|
92
|
+
print(result) # [1, 2, 5, 9]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Type-Generic Templates
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# plugins/algorithms.cp
|
|
99
|
+
SOURCE(include/algorithms.cpp) && HEADER(include/algorithms.h) algorithms
|
|
100
|
+
|
|
101
|
+
PUBLIC(
|
|
102
|
+
algorithms TEMPLATE_FUNC(fast_sort) TYPES(int, float, double, string)
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
**cpp.proj** (auto-created by `includecpp init`):
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"project": "MyProject",
|
|
112
|
+
"version": "1.0.0",
|
|
113
|
+
"include": "/include",
|
|
114
|
+
"plugins": "/plugins",
|
|
115
|
+
"compiler": {
|
|
116
|
+
"standard": "c++17",
|
|
117
|
+
"optimization": "O3",
|
|
118
|
+
"flags": ["-Wall", "-pthread"]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Requirements
|
|
124
|
+
|
|
125
|
+
- Python >= 3.8
|
|
126
|
+
- C++ compiler (g++, clang++, or MSVC)
|
|
127
|
+
- pybind11 >= 2.11.0
|
|
128
|
+
- CMake >= 3.15
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT License
|
|
133
|
+
|
|
134
|
+
## Links
|
|
135
|
+
|
|
136
|
+
- **Documentation**: https://includecpp.readthedocs.io
|
|
137
|
+
- **GitHub**: https://github.com/includecpp/includecpp
|
|
138
|
+
- **PyPI**: https://pypi.org/project/IncludeCPP
|
|
139
|
+
|
|
140
|
+
## Example: Complete Module
|
|
141
|
+
|
|
142
|
+
See the `examples/` directory for complete working examples including:
|
|
143
|
+
- Type-generic algorithms
|
|
144
|
+
- Threading with GIL release
|
|
145
|
+
- Map and Array containers
|
|
146
|
+
- Custom C++ classes
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import subprocess
|
|
3
|
+
import shutil
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from .config_parser import CppProjectConfig
|
|
6
|
+
|
|
7
|
+
@click.group()
|
|
8
|
+
def cli():
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
@cli.command()
|
|
12
|
+
def init():
|
|
13
|
+
config_file = Path.cwd() / "cpp.proj"
|
|
14
|
+
if config_file.exists():
|
|
15
|
+
click.echo("cpp.proj already exists")
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
CppProjectConfig.create_default('cpp.proj')
|
|
19
|
+
click.echo("Created cpp.proj configuration")
|
|
20
|
+
click.echo("Created include/ directory")
|
|
21
|
+
click.echo("Created plugins/ directory")
|
|
22
|
+
|
|
23
|
+
@cli.command()
|
|
24
|
+
@click.option('--clean', is_flag=True, help='Clean build artifacts first')
|
|
25
|
+
@click.option('--verbose', is_flag=True, help='Verbose output')
|
|
26
|
+
def rebuild(clean, verbose):
|
|
27
|
+
from ..core.build_manager import BuildManager
|
|
28
|
+
|
|
29
|
+
project_root = Path.cwd()
|
|
30
|
+
config = CppProjectConfig()
|
|
31
|
+
|
|
32
|
+
compiler = detect_compiler()
|
|
33
|
+
build_dir = config.get_build_dir(compiler)
|
|
34
|
+
|
|
35
|
+
if clean and build_dir.exists():
|
|
36
|
+
shutil.rmtree(build_dir)
|
|
37
|
+
|
|
38
|
+
build_dir.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
config.update_base_dir(build_dir)
|
|
40
|
+
|
|
41
|
+
click.echo(f"Build directory: {build_dir}")
|
|
42
|
+
click.echo("Building C++ modules...")
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
builder = BuildManager(project_root, build_dir, config)
|
|
46
|
+
builder.rebuild_all(verbose=verbose)
|
|
47
|
+
click.echo("\nBuild completed successfully!")
|
|
48
|
+
except Exception as e:
|
|
49
|
+
click.echo(f"\nBuild failed: {e}", err=True)
|
|
50
|
+
raise click.Abort()
|
|
51
|
+
|
|
52
|
+
@cli.command()
|
|
53
|
+
@click.argument('module_name')
|
|
54
|
+
def add(module_name):
|
|
55
|
+
plugins_dir = Path("plugins")
|
|
56
|
+
if not plugins_dir.exists():
|
|
57
|
+
click.echo("Error: plugins/ directory not found")
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
cp_file = plugins_dir / f"{module_name}.cp"
|
|
61
|
+
if cp_file.exists():
|
|
62
|
+
click.echo(f"Module {module_name} already exists")
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
template = f"""SOURCE(include/{module_name}.cpp) && HEADER(include/{module_name}.h) {module_name}
|
|
66
|
+
|
|
67
|
+
PUBLIC(
|
|
68
|
+
ALL
|
|
69
|
+
)
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
with open(cp_file, 'w') as f:
|
|
73
|
+
f.write(template)
|
|
74
|
+
|
|
75
|
+
click.echo(f"Created {cp_file}")
|
|
76
|
+
click.echo(f"Now create include/{module_name}.cpp and include/{module_name}.h")
|
|
77
|
+
|
|
78
|
+
def detect_compiler():
|
|
79
|
+
for compiler in ['g++', 'clang++', 'cl']:
|
|
80
|
+
if shutil.which(compiler):
|
|
81
|
+
return compiler.replace('++', '').replace('cl', 'msvc')
|
|
82
|
+
return 'gcc'
|
|
83
|
+
|
|
84
|
+
if __name__ == '__main__':
|
|
85
|
+
cli()
|