skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

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

    export PYBUILD_BEFORE_BUILD=sed -i '/scriptss*=/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.


  2. export _SETUPTOOLS_INCLUDE_SCRIPTS=NO
    
    import os
    
    if os.environ.get('_SETUPTOOLS_INCLUDE_SCRIPTS') == 'NO':
       scripts = []
    else:
       scripts = glob.glob(os.path.join('examples', '*.py'))
    
    setup(
        ...
        scripts=scripts,
        ...
    )
    
    unset _SETUPTOOLS_INCLUDE_SCRIPTS
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search