py2pyd 0.1.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.
- py2pyd-0.1.0/LICENSE +0 -0
- py2pyd-0.1.0/PKG-INFO +36 -0
- py2pyd-0.1.0/README.md +23 -0
- py2pyd-0.1.0/py2pyd/__init__.py +1 -0
- py2pyd-0.1.0/py2pyd/compiler.py +86 -0
- py2pyd-0.1.0/py2pyd.egg-info/PKG-INFO +36 -0
- py2pyd-0.1.0/py2pyd.egg-info/SOURCES.txt +11 -0
- py2pyd-0.1.0/py2pyd.egg-info/dependency_links.txt +1 -0
- py2pyd-0.1.0/py2pyd.egg-info/entry_points.txt +2 -0
- py2pyd-0.1.0/py2pyd.egg-info/requires.txt +1 -0
- py2pyd-0.1.0/py2pyd.egg-info/top_level.txt +1 -0
- py2pyd-0.1.0/setup.cfg +4 -0
- py2pyd-0.1.0/setup.py +26 -0
py2pyd-0.1.0/LICENSE
ADDED
|
File without changes
|
py2pyd-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: py2pyd
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple and easy Python to PYD compiler using Cython
|
|
5
|
+
Home-page: https://github.com/sachadee/PythonPydGenerator
|
|
6
|
+
Author: Sacha Dehe
|
|
7
|
+
Author-email: sachadehe@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# py2pyd
|
|
15
|
+
|
|
16
|
+
**py2pyd** is a tool to compile Python scripts (`.py`) into `.pyd` files using Cython.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```cmd
|
|
21
|
+
pip install .
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#Usage:
|
|
25
|
+
|
|
26
|
+
To compile a Python file to a PYD DLL:
|
|
27
|
+
|
|
28
|
+
```cmd
|
|
29
|
+
py2pyd myscript.py
|
|
30
|
+
|
|
31
|
+
#License
|
|
32
|
+
MIT License
|
|
33
|
+
|
|
34
|
+
Run:
|
|
35
|
+
```cmd
|
|
36
|
+
pip install -e .
|
py2pyd-0.1.0/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# py2pyd
|
|
2
|
+
|
|
3
|
+
**py2pyd** is a tool to compile Python scripts (`.py`) into `.pyd` files using Cython.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```cmd
|
|
8
|
+
pip install .
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
#Usage:
|
|
12
|
+
|
|
13
|
+
To compile a Python file to a PYD DLL:
|
|
14
|
+
|
|
15
|
+
```cmd
|
|
16
|
+
py2pyd myscript.py
|
|
17
|
+
|
|
18
|
+
#License
|
|
19
|
+
MIT License
|
|
20
|
+
|
|
21
|
+
Run:
|
|
22
|
+
```cmd
|
|
23
|
+
pip install -e .
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .compiler import convert
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import shutil
|
|
4
|
+
import sysconfig
|
|
5
|
+
|
|
6
|
+
def get_pyd_filename(module_name):
|
|
7
|
+
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") # Get platform-specific suffix
|
|
8
|
+
if ext_suffix is None:
|
|
9
|
+
raise RuntimeError("Could not determine .pyd extension")
|
|
10
|
+
return f"{module_name}{ext_suffix}"
|
|
11
|
+
|
|
12
|
+
def testAndCut(py_file):
|
|
13
|
+
genPyd = get_pyd_filename(py_file.split(".")[0])
|
|
14
|
+
finPyd = genPyd.split(".")[0] + ".pyd" if os.path.exists(genPyd) else None
|
|
15
|
+
if finPyd:
|
|
16
|
+
rem_files([finPyd])
|
|
17
|
+
os.rename(genPyd, finPyd)
|
|
18
|
+
return finPyd
|
|
19
|
+
|
|
20
|
+
def create_pyx(py_file):
|
|
21
|
+
pyx_file = py_file.replace(".py", ".pyx")
|
|
22
|
+
shutil.copy(py_file, pyx_file)
|
|
23
|
+
return pyx_file
|
|
24
|
+
|
|
25
|
+
def create_setup(pyx_file):
|
|
26
|
+
module_name = os.path.splitext(os.path.basename(pyx_file))[0]
|
|
27
|
+
setup_code = f"""
|
|
28
|
+
from setuptools import setup
|
|
29
|
+
from Cython.Build import cythonize
|
|
30
|
+
|
|
31
|
+
setup(
|
|
32
|
+
ext_modules=cythonize("{pyx_file}", language_level='3')
|
|
33
|
+
)
|
|
34
|
+
"""
|
|
35
|
+
return setup_code
|
|
36
|
+
|
|
37
|
+
def compile_pyd(py_file):
|
|
38
|
+
try:
|
|
39
|
+
pyx_file = create_pyx(py_file)
|
|
40
|
+
setup_code = create_setup(pyx_file)
|
|
41
|
+
|
|
42
|
+
setup_path = "setup.py"
|
|
43
|
+
with open(setup_path, "w") as f:
|
|
44
|
+
f.write(setup_code)
|
|
45
|
+
|
|
46
|
+
os.system(f"python {setup_path} build_ext --inplace")
|
|
47
|
+
|
|
48
|
+
compiled_pyd = pyx_file.replace(".pyx", ".pyd")
|
|
49
|
+
return compiled_pyd
|
|
50
|
+
except Exception as e:
|
|
51
|
+
print(f"Compilation error: {e} - for module: {py_file.split('.')[0]}")
|
|
52
|
+
|
|
53
|
+
def rem_files(arr_files):
|
|
54
|
+
for fi in arr_files:
|
|
55
|
+
if os.path.exists(fi):
|
|
56
|
+
os.remove(fi)
|
|
57
|
+
else:
|
|
58
|
+
print(f"The file: {fi} does not exist")
|
|
59
|
+
|
|
60
|
+
def convert(py_file=None):
|
|
61
|
+
if py_file is None:
|
|
62
|
+
if len(sys.argv) < 2:
|
|
63
|
+
print("Usage: py2pyd <your_script.py>")
|
|
64
|
+
sys.exit(1)
|
|
65
|
+
py_file = sys.argv[1] # Get the first argument from the command line
|
|
66
|
+
|
|
67
|
+
if not os.path.exists(py_file):
|
|
68
|
+
print(f"Error: File '{py_file}' not found.")
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
compiled_pyd = compile_pyd(py_file)
|
|
73
|
+
compiled_pyd = testAndCut(py_file)
|
|
74
|
+
|
|
75
|
+
if compiled_pyd is not None:
|
|
76
|
+
print(f"Successfully created {compiled_pyd}")
|
|
77
|
+
arr_files = [py_file.replace(".py", ".pyx"), py_file.replace(".py", ".c"), "setup.py"]
|
|
78
|
+
rem_files(arr_files)
|
|
79
|
+
shutil.rmtree("./build")
|
|
80
|
+
return compiled_pyd
|
|
81
|
+
except Exception as e:
|
|
82
|
+
print(f"Compilation error: {e} - for module: {py_file.split('.')[0]}")
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
if __name__ == "__main__":
|
|
86
|
+
convert() # This ensur
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: py2pyd
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple and easy Python to PYD compiler using Cython
|
|
5
|
+
Home-page: https://github.com/sachadee/PythonPydGenerator
|
|
6
|
+
Author: Sacha Dehe
|
|
7
|
+
Author-email: sachadehe@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# py2pyd
|
|
15
|
+
|
|
16
|
+
**py2pyd** is a tool to compile Python scripts (`.py`) into `.pyd` files using Cython.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```cmd
|
|
21
|
+
pip install .
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
#Usage:
|
|
25
|
+
|
|
26
|
+
To compile a Python file to a PYD DLL:
|
|
27
|
+
|
|
28
|
+
```cmd
|
|
29
|
+
py2pyd myscript.py
|
|
30
|
+
|
|
31
|
+
#License
|
|
32
|
+
MIT License
|
|
33
|
+
|
|
34
|
+
Run:
|
|
35
|
+
```cmd
|
|
36
|
+
pip install -e .
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
py2pyd/__init__.py
|
|
5
|
+
py2pyd/compiler.py
|
|
6
|
+
py2pyd.egg-info/PKG-INFO
|
|
7
|
+
py2pyd.egg-info/SOURCES.txt
|
|
8
|
+
py2pyd.egg-info/dependency_links.txt
|
|
9
|
+
py2pyd.egg-info/entry_points.txt
|
|
10
|
+
py2pyd.egg-info/requires.txt
|
|
11
|
+
py2pyd.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Cython
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
py2pyd
|
py2pyd-0.1.0/setup.cfg
ADDED
py2pyd-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="py2pyd",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
license_file="LICENCE",
|
|
7
|
+
packages=find_packages(),
|
|
8
|
+
install_requires=["Cython"],
|
|
9
|
+
entry_points={
|
|
10
|
+
"console_scripts": [
|
|
11
|
+
"py2pyd=py2pyd.compiler:convert"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
author="Sacha Dehe",
|
|
15
|
+
author_email="sachadehe@gmail.com",
|
|
16
|
+
description="A simple and easy Python to PYD compiler using Cython",
|
|
17
|
+
long_description=open("README.md").read(),
|
|
18
|
+
long_description_content_type="text/markdown",
|
|
19
|
+
url="https://github.com/sachadee/PythonPydGenerator",
|
|
20
|
+
classifiers=[
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
],
|
|
25
|
+
python_requires=">=3.6",
|
|
26
|
+
)
|