Search code examples
pythondebiansetuptoolspackaging

Strip scripts from pybuild


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.

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.