Search code examples
pythonsetuptools

python setuptools removed shebang from my script


I have a script as such

from setuptools import setup

setup(
    name='my package',
    version='1.0',
    description='Bla',
    author='Me',
    url='http://www.google.com',
    packages=find_packages(),
    scripts=['bin/python_script_1', 'bin/python_script2'],
)

However the python script python_script_1 and python_script_2 both end up missing the shebang and become broken

source:

#!/bin/env python

"""
This script does things
"""

output:

#!

"""
This script does things
"""

I read the documentations (https://docs.python.org/3/distutils/setupscript.html#installing-scripts) that

The only clever feature is that if the first line of the script starts with #! and contains the word “python”, the Distutils will adjust the first line to refer to the current interpreter location.

This is really confusing, why is my interpreter empty? How do I fix it? Is there some properties or environment variable I can set to fix this behavior?


Solution

  • we found a code defect on our script elsewhere and that was causing the problem. Our setup.cfg was corrupted and provided empty build.executable