I have a small helper function test
containing sensitive code. To mask this code, I have written the function in hello.pyx
and using it in my package mypackage
.
I am able to build and use it by modifying the setup.py
for the package to something like below:
import os
from setuptools import setup, find_packages
from Cython.Build import cythonize
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup(
name='mypackage',
ext_modules = cythonize('mypackage/hello.pyx'),
packages=find_packages(),
include_package_data=True,
)
However, when i build/install it via python setup.py
or pip install
, the cython generated hello.c
as well as hello.so
are getting placed in the install directory (in my case ~/.local/python2.7/site-packages/mypackage/
)
I can manually remove the hello.c
from the install directory (leaving just the hello.so
file) and the package runs fine.
Is there a way I can automate this process so that i don't need to manually remove the compiled c
file ?
I looked at this stackoverflow question. However, I am getting an error during cythonize operation when i am trying to build the wheel using pip wheel .
. Also, in my case I am fine with installing using tar.gz as long as the installed code doesn't contain plain text files for hello.c
[Edit]
I was able to stop placing a .c
file in the install directory by using include_package_data=False
in my setup.py
.. However, am not exactly sure whether this option means for non python files in the project
MANIFEST.in
in your project directory? If yes, what does it contain? – SaporMANIFEST.in
.. btw just updated the question – Recidivate