Open krunaldodiya opened 8 months ago
here is the setup.py
import os
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
def get_ext(package: str, package_path: str, file: str) -> Extension:
name = f"{package}.{file}".replace(".py", "")
file = os.path.join(package_path, file)
return Extension(name=name, sources=[file], language="c++")
packages = find_packages(exclude=["some_directory_to_exclude"])
ext_modules = []
for package in packages:
package_path = package.replace(".", os.path.sep)
ext_modules.extend(
[
get_ext(package, package_path, file)
for file in os.listdir(package_path)
if file.endswith(".py") and file != "__init__.py"
]
)
setup(
name="my_package",
ext_modules=cythonize(ext_modules),
)
Hi there,
I am also using the same approach to protect my python source code, I am using cython to build shared object file .so, for each python file it's create .so file, and put it right beside the actual file and then i build python package only using .so file and not actual file
can you please validate that this approach will work or any chances to leak source code ?
i have to manage two repository for that
1) repository 1
first i cythonize it to create .so file for each python file
2) repository 2 now i only take .so file with init.py
and then create a python package to distribute
so that user can do
thanks