Sitemap

Strip scripts from pybuild

1 min readJul 9, 2024

--

I need to build a debian package from a python package. The python package is not under my control so i can not easily change the setup.py file.
It is using setuptools and has a very standard setup.py containing scripts. But for my resulting debian package i don’t want any of the scripts included.

setup(
...
scripts=glob.glob(os.path.join('examples', '*.py')),
...
)

I tried to use --install-scripts=/dev/null but since it is in a debian build that means they are still in the package as ./dev/null/script.py.

Get Ted James’s stories in your inbox

Join Medium for free to get updates from this writer.

Is there a way to control the setuptools install to suppress/omit the scripts or do i need to remove them from the setup.py via some sed magic?

Solution

A solution is to set and restore before and after the build

export PYBUILD_BEFORE_BUILD=sed -i '/scripts\s*=/d' setup.py
export PYBUILD_AFTER_INSTALL=git checkout setup.py

Drawbacks are that I actually need to sed things out of the setup.py. Im looking very much for a cleaner solution.

Answered By — Sir l33tname

Answer Checked By — Willingham (FixIt Volunteer)

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

creative-commons-by-21pxcreative-commons-sa-21px

--

--

Ted James
Ted James

Written by Ted James

The world is my office, and every destination is my inspiration