I need to obfuscate my python code, to achieve it I am using cythonize extension, I am able to achieve it and get the binary compiled a.so files from a.py files but after doing bdist_wheel the .whl package only packages the a.so files and ignores the resource_folder.
My project file structure is
|main_project
|__,setup.py
|__,main_folder
|____,a.py
|____,__init__.py
|____resource_folder
|__,a.model
|__,a.json
I used following links to make obfuscated python wheel package,
https://bucharjan.cz/blog/using-cython-to-protect-a-python-codebase.html
https://medium.com/@xpl/protecting-python-sources-using-cython-dcd940bb188e
Package only binary compiled .so files of a python library compiled with Cython
Following is the snippet from my setup.py
packages = find_packages(exclude=('tests',))
def get_package_files_in_directory(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join('..', path, filename))
return paths
setup(
packages=[],
ext_modules=cythonize(
[
Extension("main_folder.*", ["main_folder/*.py"])
],
build_dir="build",
compiler_directives=dict(
always_allow_keywords=True
)),
package_data={p: package_files + get_package_files_in_directory(os.path.join(here, p, 'resources')) for p in packages},
,....
,...
)
To package I am using following command
python setup.py build_ext
python setup.py bdist_wheel
expected result is .whl file containing a.so file and resource folder
actual result is .whl file contain only a.so file.
to also package the resource_folder I used get_package_files_in_directory() function as suggested in this link "( How do you add additional files to a wheel?)" but this also didnot work for me