Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to exclude source code from bdist_wheel python

Tags:

python

We want to exclude the Python source code from the package we create. But after configuring setup.py, I failed excluding the py files. I have been using python setup.py bdist_wheel as command. Is there any way to exclude to source code from Python package? Basically we do not want to expose the source codes.

like image 944
Gloria Avatar asked Nov 08 '17 08:11

Gloria


3 Answers

The wheel plugin for setuptools that handles bdist_wheel does not have the --exclude_source_files which is only supported by bdist_egg. The egg packages are however deprecated and not supported by pip for example. What you can do however:

pip3 install wheel
python3 setup.py bdist_egg --exclude-source-files
wheel convert dist/mypackage-1.0-py3.6.egg

The wheel utility takes a source-stripped egg and converts it into whl package.

like image 145
kravietz Avatar answered Nov 04 '22 17:11

kravietz


This came up for us putting Python libs on an embedded system with very minimal available memory.

It can be achieved with:

./setup.py bdist_egg --exclude_source_files

Works for both distutils and setuptools.

like image 30
gbtimmon Avatar answered Nov 04 '22 18:11

gbtimmon


Well, we also encountered this issue (around 2 years ago) and didn't find a sensible automation process for it. So I wrote my own.

You're welcomed to it: setup.py template

like image 1
Opher Avatar answered Nov 04 '22 16:11

Opher