Comments (9)
I am having a similar issue with incorrect shebang:
gory details (click to expand)
/tmp > virtualenv --system-site-packages --python=python3 venvs/dev3
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/venvs/dev3/bin/python3
Also creating executable in /tmp/venvs/dev3/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
/tmp > source venvs/dev3/bin/activate
(dev3)
/tmp > pip install shiv
Collecting shiv
Using cached https://files.pythonhosted.org/packages/66/cc/67b69bffa38e620cea0d211d74f19b30304c21e584dcd407da007b30c007/shiv-0.0.48-py3-none-any.whl
Requirement already satisfied: pip>=9.0.3 in ./venvs/dev3/lib/python3.7/site-packages (from shiv) (19.2.3)
Requirement already satisfied: setuptools in ./venvs/dev3/lib/python3.7/site-packages (from shiv) (41.2.0)
Collecting click!=7.0,>=6.7 (from shiv)
Using cached https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl
Installing collected packages: click, shiv
Found existing installation: Click 7.0
Not uninstalling click at /usr/lib/python3/dist-packages, outside environment /tmp/venvs/dev3
Can't uninstall 'Click'. No files were found to uninstall.
Successfully installed click-6.7 shiv-0.0.48
(dev3)
/tmp > shiv requests -o requests.pyz --quiet
(dev3)
/tmp > ./requests.pyz
zsh: permission denied: ./requests.pyz
(dev3)
/tmp > head -n1 ./requests.pyz
#!/usr/lib/python3
(dev3)
/tmp > ls -l /usr/lib/python3 -d
drwxr-xr-x 3 root root 4096 Oct 19 2014 /usr/lib/python3/
(dev3)
/tmp > shiv --version
shiv, version 0.0.48
Specifying `-p '/usr/bin/env python3'` mitigates it
/tmp > shiv requests -o requests.pyz -p '/usr/bin/env python3' --quiet
(dev3)
/tmp > ./requests.pyz
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
from shiv.
hi @ibeex
Unfortunately this is not enough information to troubleshoot, what are the permissions on that file? also, can you share the version of shiv you are using and show me head -n1 my_command.pyz
?
thanks
from shiv.
here it is
[I] ➜ ll my_command.pyz
-rwxr-xr-x 1 myuser users 642K Nov 10 16:21 my_command.pyz
[I] ➜ head -n1 my_command.pyz
#!/usr/share/bash-completion/completions/python3
[I] ➜ type python
python is /home/myuser/.pyenv/shims/python
[I] ➜ type shiv
shiv is /home/myuser/.local/bin/shiv
shiv is installed with pipsi, I user pyenv to manage python versions, and virtualenvs
Edit:
it works using -p
shiv -e cpe_middleware.cpe_middleware:cli -p '/usr/bin/env python3' -o my_command.pyz .
is it bug or intended behaviour?
from shiv.
if I had to venture a guess I'd say the issue is the shebang there - is that a valid interpreter?
does the pyz execute if you invoke it with your pyenv interpreter path? e.g.
/home/myuser/.pyenv/shims/python ./my_command.pyz
I'm not super familiar with pipsi, but nothing jumps out at me as incompatible with how shiv works.
from shiv.
/home/myuser/.pyenv/shims/python ./my_command.pyz
works, why is default python detected #!/usr/share/bash-completion/completions/python3
?
from shiv.
That is an excellent question - I have no idea why that would be the case.
If, when building a pyz
with shiv, you do not specify an interpreter or shebang (using the -p
option), then shiv defaults to sys.executable
but attempts first to suss out whether it's being invoked from a virtualenv or not, and if so, what is the actual location of that interpreter (rather than the interpreter that's been copied into the virtualenv).
This is done via the _interpreter_path
function (found here)
How did you make your pyz
? Were you in an activated virtualenv? Did you specify a shebang using -p
? In order to help I need to know more about your environment, and if possible, steps to be able to reproduce. Thanks :)
from shiv.
Hi @lorencarvalho my python setup involves pyenv pyenv manages python versions and virtualenviroments. My local pyton tools like black and shiv are installed in separate virtualenviroments with pipsi this configuration ensure that nothing is installed to system python and every project can haw separate python version and virtualenv.
So shiv is in separate virtualenv and it was invoked in virtualenviroment for my project
shiv -e cpe_m.cpe_mi:cli -o my_command.pyz .
.
One more thing as I understand shiv should make pyz
on your local machine and simplify deployment on remote machine. So isn't better that default shebang should be /usr/bin/env python3
or /usr/bin/env python2
depending on python version. And _interpreter_path
can return one or another depending is it py2 or py3.
from shiv.
@ibeex shiv only supports Python 3 (specifically 3.6, as f-strings are used) currently. It is theoretically possible that we could build Python 2 zipapps, but given EOL for Py2 is inching closer and closer every day (2020!) we've opted not to.
I'm unfamiliar with the implementation of pipsi and pyenv, so I'm not in the best position to debug those issues, but yes, if you intend to ship your pyz to another machine, then passing --python "/usr/bin/env python3"
when creating your pyz is generally the best practice.
from shiv.
$ python3 -m this | grep guess
In the face of ambiguity, refuse the temptation to guess.
If you ask me, -p
should be a mandatory option. ;)
Possibly allowing things like {pymajor}
based on the running interpreter.
from shiv.
Related Issues (20)
- use the python interpreter (to set the shebang line) when running pip HOT 2
- Accept pipenv's Pipfile.lock in place of pip's requirements.txt HOT 3
- Repetition of `site-packages\build\lib\build\lib\...` HOT 1
- support for packages with a .pth file HOT 3
- Run fails if the built app contains more than 65535 files or is over 2GB HOT 1
- ConfigParser issue with duplicate option entries HOT 2
- Shiv ignores files defined in .gitignore without an option to override and add anyway HOT 2
- Error while finding module specification for '__main__' HOT 2
- How to use single shiv zipapp/pyz for multiple python scripts HOT 1
- Error if output path doesn't exist HOT 1
- The shiv of release page should probably be generated on Windows HOT 1
- Any way to use shiv on read-only filesystem? HOT 2
- Is asyncio supported? HOT 1
- Environments created with symlinked folders (by PDM with cache=True) are not correctly packed
- shiv version 1.0.4 reports the incorrect version of 1.0.3
- Shiv with console script prints the __main__ module dictionary to stderr HOT 1
- Windows: Bug in Interpreter Path Handling
- Is there a way to show a message to the user during the environment bootstrapping phase? HOT 3
- Incorrect bootstrap filename HOT 3
- DuplicateOptionError when there is { in entry_points.txt file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shiv.