Question

I have some scripts that I often use in both windows(cygwin) and linux, I'd like to make the scripts executable in both environments. Is there a way to alias the location of my python installation, for example so that

#!/usr/bin/python

will still find my python installation, even though, as far as cygwin is concerned, it is located at /cygdrive/c/Python26/python?

Was it helpful?

Solution

Just install Python via Cygwin's setup.exe, and it will be in /usr/bin.

Or create symbolic links on both systems, for example in /usr/local/bin/python, and use that in the shebang.

Or write an installation script that adjusts the #! line in your Python scripts as it installs them.

Note that if your /cygdrive/c/Python26/python (C:\Python26\python) is a native Windows Python installation, scripts using it won't be able to use Cygwin-style paths.

OTHER TIPS

Put /cygdrive/c/Python26/python in your PATH variable, and replace the shebang line with

#!/usr/bin/env python

assuming that cygwin can run that version of python.

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