cexec 1.0.2__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.
- cexec-1.0.2/LICENSE +21 -0
- cexec-1.0.2/PKG-INFO +66 -0
- cexec-1.0.2/README.md +43 -0
- cexec-1.0.2/cexec/__init__.py +54 -0
- cexec-1.0.2/cexec/libtcc.dll +0 -0
- cexec-1.0.2/cexec/tcc.exe +0 -0
- cexec-1.0.2/cexec.egg-info/PKG-INFO +66 -0
- cexec-1.0.2/cexec.egg-info/SOURCES.txt +10 -0
- cexec-1.0.2/cexec.egg-info/dependency_links.txt +1 -0
- cexec-1.0.2/cexec.egg-info/top_level.txt +1 -0
- cexec-1.0.2/setup.cfg +4 -0
- cexec-1.0.2/setup.py +28 -0
cexec-1.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suleiman
|
|
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.
|
cexec-1.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cexec
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: The C Executor in Python. Compile and run C code in real-time
|
|
5
|
+
Author: Suleiman
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: license
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
'# cexec โ The C Executor in Python
|
|
25
|
+
|
|
26
|
+
**cexec** is a lightweight Python library that allows you to **compile and run C code on the fly** directly from Python.
|
|
27
|
+
|
|
28
|
+
## โจ Features
|
|
29
|
+
|
|
30
|
+
* **Zero Dependencies**: Uses only the Python standard library.
|
|
31
|
+
* **On-the-fly Execution**: Compile and run C code in a single function call.
|
|
32
|
+
* **Windows Support**: Optimized for 64-bit Windows systems.
|
|
33
|
+
|
|
34
|
+
## ๐ Quick Start
|
|
35
|
+
|
|
36
|
+
Make sure you have Python 3.6+ installed on **Windows** (this package currently supports only Windows).
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import cexec
|
|
40
|
+
|
|
41
|
+
c_code = """
|
|
42
|
+
#include <stdio.h>
|
|
43
|
+
|
|
44
|
+
int main() {
|
|
45
|
+
printf("Hello from C Executor!\\n");
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
output = cexec.execute(c_code)
|
|
51
|
+
print(output)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
โ ๏ธ Important Notes
|
|
55
|
+
|
|
56
|
+
ยท Windows Only: This package uses tcc.exe, which is a Windows binary. It will not work on Linux, macOS, or Android.
|
|
57
|
+
|
|
58
|
+
๐ฆ Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install cexec
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
๐ License
|
|
65
|
+
|
|
66
|
+
This project is distributed under the MIT License. See the LICENSE file for details.'
|
cexec-1.0.2/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'# cexec โ The C Executor in Python
|
|
2
|
+
|
|
3
|
+
**cexec** is a lightweight Python library that allows you to **compile and run C code on the fly** directly from Python.
|
|
4
|
+
|
|
5
|
+
## โจ Features
|
|
6
|
+
|
|
7
|
+
* **Zero Dependencies**: Uses only the Python standard library.
|
|
8
|
+
* **On-the-fly Execution**: Compile and run C code in a single function call.
|
|
9
|
+
* **Windows Support**: Optimized for 64-bit Windows systems.
|
|
10
|
+
|
|
11
|
+
## ๐ Quick Start
|
|
12
|
+
|
|
13
|
+
Make sure you have Python 3.6+ installed on **Windows** (this package currently supports only Windows).
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import cexec
|
|
17
|
+
|
|
18
|
+
c_code = """
|
|
19
|
+
#include <stdio.h>
|
|
20
|
+
|
|
21
|
+
int main() {
|
|
22
|
+
printf("Hello from C Executor!\\n");
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
output = cexec.execute(c_code)
|
|
28
|
+
print(output)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
โ ๏ธ Important Notes
|
|
32
|
+
|
|
33
|
+
ยท Windows Only: This package uses tcc.exe, which is a Windows binary. It will not work on Linux, macOS, or Android.
|
|
34
|
+
|
|
35
|
+
๐ฆ Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install cexec
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
๐ License
|
|
42
|
+
|
|
43
|
+
This project is distributed under the MIT License. See the LICENSE file for details.'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
cexec - The C Executor in Python.
|
|
3
|
+
|
|
4
|
+
Using the built-in to source TCC for compile C and Run Compiled Machine Code.
|
|
5
|
+
|
|
6
|
+
Copyright (c) Suleiman 2026
|
|
7
|
+
License: MIT
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__license__ = "MIT"
|
|
11
|
+
__author__ = "Suleiman"
|
|
12
|
+
__version__ = "1.0.2"
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
import platform
|
|
17
|
+
import tempfile
|
|
18
|
+
import subprocess
|
|
19
|
+
|
|
20
|
+
system = platform.system().lower()
|
|
21
|
+
if "windows" not in system: raise OSError(f"This Python Package only supports on 'windows' OS, not in '{system}'")
|
|
22
|
+
|
|
23
|
+
TCC_EXE = os.path.join(os.path.dirname(__file__), "tcc.exe")
|
|
24
|
+
if not os.path.exists(TCC_EXE):
|
|
25
|
+
TCC_EXE = "tcc.exe"
|
|
26
|
+
|
|
27
|
+
def execute(code, args=None):
|
|
28
|
+
if not code or not isinstance(code, str):
|
|
29
|
+
raise ValueError("Expected a string of C code")
|
|
30
|
+
|
|
31
|
+
if platform.architecture()[0] != "64bit":
|
|
32
|
+
raise RuntimeError("cexec supports only 64-bit systems")
|
|
33
|
+
|
|
34
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
35
|
+
c_file = os.path.join(tmpdir, "main.c")
|
|
36
|
+
exe_file = os.path.join(tmpdir, "main.exe")
|
|
37
|
+
|
|
38
|
+
with open(c_file, "w", encoding="utf-8") as f:
|
|
39
|
+
f.write(code)
|
|
40
|
+
|
|
41
|
+
compile_cmd = [TCC_EXE, c_file, "-o", exe_file]
|
|
42
|
+
try:
|
|
43
|
+
subprocess.run(compile_cmd, capture_output=True, text=True, check=True)
|
|
44
|
+
except subprocess.CalledProcessError as e:
|
|
45
|
+
raise RuntimeError(f"Compilation error:\n{e.stderr}")
|
|
46
|
+
except FileNotFoundError:
|
|
47
|
+
raise RuntimeError(f"TCC not found. Ensure {TCC_EXE} exists.")
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
run_cmd = [exe_file] + (args or [])
|
|
51
|
+
run_result = subprocess.run(run_cmd, capture_output=True, text=True, check=True)
|
|
52
|
+
return run_result.stdout
|
|
53
|
+
except subprocess.CalledProcessError as e:
|
|
54
|
+
raise RuntimeError(f"Execution error:\n{e.stderr}")
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cexec
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: The C Executor in Python. Compile and run C code in real-time
|
|
5
|
+
Author: Suleiman
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
10
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: license
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
'# cexec โ The C Executor in Python
|
|
25
|
+
|
|
26
|
+
**cexec** is a lightweight Python library that allows you to **compile and run C code on the fly** directly from Python.
|
|
27
|
+
|
|
28
|
+
## โจ Features
|
|
29
|
+
|
|
30
|
+
* **Zero Dependencies**: Uses only the Python standard library.
|
|
31
|
+
* **On-the-fly Execution**: Compile and run C code in a single function call.
|
|
32
|
+
* **Windows Support**: Optimized for 64-bit Windows systems.
|
|
33
|
+
|
|
34
|
+
## ๐ Quick Start
|
|
35
|
+
|
|
36
|
+
Make sure you have Python 3.6+ installed on **Windows** (this package currently supports only Windows).
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import cexec
|
|
40
|
+
|
|
41
|
+
c_code = """
|
|
42
|
+
#include <stdio.h>
|
|
43
|
+
|
|
44
|
+
int main() {
|
|
45
|
+
printf("Hello from C Executor!\\n");
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
output = cexec.execute(c_code)
|
|
51
|
+
print(output)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
โ ๏ธ Important Notes
|
|
55
|
+
|
|
56
|
+
ยท Windows Only: This package uses tcc.exe, which is a Windows binary. It will not work on Linux, macOS, or Android.
|
|
57
|
+
|
|
58
|
+
๐ฆ Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install cexec
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
๐ License
|
|
65
|
+
|
|
66
|
+
This project is distributed under the MIT License. See the LICENSE file for details.'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cexec
|
cexec-1.0.2/setup.cfg
ADDED
cexec-1.0.2/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="cexec",
|
|
8
|
+
version="1.0.2",
|
|
9
|
+
author="Suleiman",
|
|
10
|
+
description="The C Executor in Python. Compile and run C code in real-time",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
license="MIT",
|
|
14
|
+
packages=find_packages(),
|
|
15
|
+
package_data={
|
|
16
|
+
"": ["tcc.exe", "libtcc.dll", "include/*", "lib/*"],
|
|
17
|
+
},
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
classifiers=[
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Topic :: Software Development :: Compilers",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
],
|
|
26
|
+
python_requires=">=3.6",
|
|
27
|
+
install_requires=[],
|
|
28
|
+
)
|