3

When installing a script using Python, the shebang gets replaced as discussed in this post.

The problem is that in my case it gets replaced by

#!/ssoft/spack/paien/v2/opt/spack/linux-rhel7-x86_E5v2_IntelIB/gcc-7.3.0/python-3.6.5-5yxsy6j5miw26wxpzrtync5gnhtsv5pt/bin/python3

which appears too long for the OS to handle:

bad interpreter: /ssoft/spack/paien/v2/opt/spack/linux-rhel7-x86_E5v2_IntelIB/g: no such file or directory

How can I work around this problem?

(Except for overriding setuptools' default script copy routine.)

Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
  • 2
    Related issue https://github.com/pypa/virtualenv/issues/596 . – Giacomo Alzetta Sep 20 '18 at 14:29
  • 1
    [Here](https://stackoverflow.com/questions/10813538/shebang-line-limit-in-bash-and-linux-kernel) is a SO question that asks about the size limit, but I don't think it answers your question. – syntonym Sep 20 '18 at 14:29
  • @GiacomoAlzetta Thanks, the issue is indeed related, though I don't think it has been fixed. There is some [workaround suggested](https://github.com/pypa/virtualenv/issues/596#issuecomment-411485104) which does not seems to work for me. Or am I missing something? – Tom de Geus Sep 20 '18 at 14:32
  • So... you didn't get the *whole shebang*? – Will Vousden Sep 20 '18 at 17:39
  • @WillVousden The *shebang* written to the script was the whole path, but it is too long for the OS to read. Except for this, the path written is extremely dependent on the loaded environment (using `spack`), i.e. not very robust. – Tom de Geus Sep 21 '18 at 08:31

1 Answers1

1

It's the OS' limit so you don't have any other options but to limit the shebang length.

Install into a directory with shorter path. Or create a symlink with shorter path and use the symlink in the shebang.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks a lot for the answer. However, I don't think either of the suggestions gives a solution here. (1) The installation is decided by `spack`, I have not control here. (2) The symlinks are not respected by `setuptools`, i.e. the path of the Python executable is put, no matter what. – Tom de Geus Sep 21 '18 at 08:23
  • Finally, it seems that [this issue has been around for a while](https://github.com/pypa/setuptools/issues/494), however I cannot find any workaround... – Tom de Geus Sep 21 '18 at 08:24