summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-04-30 11:24:18 -0400
committerCharles Harris <charlesr.harris@gmail.com>2015-04-30 11:24:18 -0400
commit38cb7aa3815748c1d719e918718b7726a18ed1fc (patch)
tree8a49ad8401148b682d4e3474b8cb35b5ebbd2ff5
parentbd821f56ce4864ab3e327378de518ba45df208fa (diff)
parent19220c47cf6138b4f42f67b9b4d80f2575e22145 (diff)
downloadnumpy-38cb7aa3815748c1d719e918718b7726a18ed1fc.tar.gz
Merge pull request #5815 from matthew-brett/f2py-shebang-fix
BUG: fix f2py shebang line for bdist wheel, egg
-rw-r--r--numpy/f2py/setup.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/numpy/f2py/setup.py b/numpy/f2py/setup.py
index 3e2cf6867..9f6e47c1c 100644
--- a/numpy/f2py/setup.py
+++ b/numpy/f2py/setup.py
@@ -29,6 +29,20 @@ from numpy.distutils.misc_util import Configuration
from __version__ import version
+
+def _get_f2py_shebang():
+ """ Return shebang line for f2py script
+
+ If we are building a binary distribution format, then the shebang line
+ should be ``#!python`` rather than ``#!`` followed by the contents of
+ ``sys.executable``.
+ """
+ if set(('bdist_wheel', 'bdist_egg', 'bdist_mpkg', 'bdist_wininst',
+ 'bdist_rpm')).intersection(sys.argv):
+ return '#!python'
+ return '#!' + sys.executable
+
+
def configuration(parent_package='',top_path=None):
config = Configuration('f2py', parent_package, top_path)
@@ -50,7 +64,7 @@ def configuration(parent_package='',top_path=None):
if newer(__file__, target):
log.info('Creating %s', target)
f = open(target, 'w')
- f.write('#!%s\n' % (sys.executable))
+ f.write(_get_f2py_shebang() + '\n')
mainloc = os.path.join(os.path.dirname(__file__), "__main__.py")
with open(mainloc) as mf:
f.write(mf.read())