Question

This may be a bizarre use case/desire. With setup.py I can use the scripts parameter in the setup call to have it install some scripts, easy peasy. However, I plan on installing my application within a virtualenv, and I want my scripts to use the virtualenv python - not the default system install.

How can I do this?

Was it helpful?

Solution

Turns out setup.py is smarter than I thought - it automagically converts the hash-bang line to point to the python that it was installed with.

All you have to do is:

  • put #!/usr/bin/env python at the beginning of your script
  • make your script executable - $ chmod +x path/to/script
  • put the script in the setup function

setup( #stuff goes here scripts=['path/to/script'], )

  • (myenv) $ python setup.py develop (or install)

And magic happens!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top