Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with shebang of Python scripts being too long #104

Closed
karenyyng opened this issue Sep 4, 2015 · 2 comments
Closed

problem with shebang of Python scripts being too long #104

karenyyng opened this issue Sep 4, 2015 · 2 comments
Labels
bug Something isn't working duplicate

Comments

@karenyyng
Copy link
Member

Some Python packages install python scripts to be executed via bash.
If we use the Python installed with spack, the path of the python is something like:
#!/<SOME_DIR>/spack_git_repo/opt/spack/chaos_5_x86_64_ib/gcc-4.4.7/python-2.7.10- yqkr6m74axh3nafjscgtjb3zj3htx3fe/bin/python

Somehow the bash interpreter will cut it off when the shebang is longer than a certain number of characters as documented here

For me it cut off so the she-bang looked like:
``#!/<SOME_DIR>/spack_git_repo/opt/spack/chaos_5_x86_64_ib/gcc-4.4.7/python-2.7.10- yqkr6m74axh3nafjscgtjb3zj3htx3fe/bin/p`

A simple fix is to change the line of shebang to:
#!/bin/env python

Is there a better solution than manually changing all the shebangs for the python scripts?
In any case, I thought it may be nice to document this behavior somewhere in the spack documentation for Python use.
Thanks.

@mathstuf
Copy link
Contributor

Yes, there is a character limit, defined here. It also only supports one argument (see this LWN article).

As for a solution, it might be best if the scripts just used the environment to get the right Python from spack (requiring that spack be loaded to run the script).

@tgamblin tgamblin added bug Something isn't working duplicate labels Dec 20, 2015
@tgamblin
Copy link
Member

Duplicates #54

tgamblin added a commit that referenced this issue Mar 5, 2016
This does several things:

- Add `sbang`: a script to run scripts with long shebang lines.
  - Documentation for `sbang` is in `bin/sbang`.

- Add an `sbang` hook that filters the `bin` directory after install
  and modifies any scripts wtih shebangs that are too long to use
  `sbang` instead.

- `sbang` is at the top level, so it should be runnable (not much we
  can do if spack itself is too deep for shebang)
  - `sbang`, when used as the interpreter, runs the *second* shebang
    line it finds in a script.
  - shoud fix issues with too long shebang paths.
matz-e added a commit to matz-e/spack that referenced this issue Oct 16, 2018
* mvdtool: new package @ 1.4
* py-jprops: new package @ 2.0.2
* py-pyarrow: new package
* py-h5py: add ~mpi to dependencies.
* py-py4j: add version 0.10.6
* py-hdfs: new package
* py-progress: new package.
* py-pyspark: new package
* py-sparkmanager: new package
* py-bb5: new package
* spykfunc: new package
* py-py4j: change to sha256.
* arrow: add missing dependency for python build
* py-bb5: keep .git when creating the cache archive

* feature: add option to retain .vcs
Some packages require version control information to build, e.g., python
packages depending on `setuptools-scm`.  Spack will remove any VCS
directory when caching hashable stages like tags, this patch will
provide a parameter `clean=False` to the `version` function that will
retain `.git` etc.

* fixup! py-jprops: new package @ 1.0.2
* spark: only java 8 is officially supported recently
* py-py4j: add version 0.10.7 for Spark 2.3.2
* {,py-py}spark: add BBP-specific binaries.
matz-e added a commit to matz-e/spack that referenced this issue Jan 28, 2019
* mvdtool: new package @ 1.4
* py-jprops: new package @ 2.0.2
* py-pyarrow: new package
* py-h5py: add ~mpi to dependencies.
* py-py4j: add version 0.10.6
* py-hdfs: new package
* py-progress: new package.
* py-pyspark: new package
* py-sparkmanager: new package
* py-bb5: new package
* spykfunc: new package
* py-py4j: change to sha256.
* arrow: add missing dependency for python build
* py-bb5: keep .git when creating the cache archive

* feature: add option to retain .vcs
Some packages require version control information to build, e.g., python
packages depending on `setuptools-scm`.  Spack will remove any VCS
directory when caching hashable stages like tags, this patch will
provide a parameter `clean=False` to the `version` function that will
retain `.git` etc.

* fixup! py-jprops: new package @ 1.0.2
* spark: only java 8 is officially supported recently
* py-py4j: add version 0.10.7 for Spark 2.3.2
* {,py-py}spark: add BBP-specific binaries.
climbfuji added a commit to climbfuji/spack that referenced this issue Jul 13, 2022
greenc-FNAL pushed a commit to greenc-FNAL/spack that referenced this issue Apr 6, 2023
Activate CI for FNAL-specific branches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate
Projects
None yet
Development

No branches or pull requests

3 participants