Changing console_script entry point interpreter for packaging

て烟熏妆下的殇ゞ 提交于 2019-11-28 07:43:19

You can customize the console_scripts' shebang line by setting 'sys.executable' (learned this from a debian bug report). That is to say...

sys.executable = '/bin/custom_python'

setup(
  entry_points={
    'console_scripts': [
       ... etc...
    ]
  }
)

Better though would be to include the 'execute' argument when building...

setup(
  entry_points={
    'console_scripts': [
       ... etc...
    ]
  },
  options={
      'build_scripts': {
          'executable': '/bin/custom_python',
      },
  }
)

Simply change the shebang of your setup.py to match the python you want your entry points to use:

#!/bin/custom_python

(I tried @damian answer but not working for me, maybe the setuptools version on Debian Jessie is too old)

For future reference for someone who wants to do this at runtime without modifying the setup.py, it's possible to pass the interpreter path to setup.py build via pip with:

$ ./venv/bin/pip install --global-option=build \
--global-option='--executable=/bin/custom_python' .
...
$ head -1 ./venv/bin/some-entry-point
#!/bin/custom_python
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!