I just build a jupyter-labs pex by making a requir...
# pex
j
I just build a jupyter-labs pex by making a requirements file from
pip freeze
then using that as the input to
pex -r /tmp/jupyterlab-requirements.txt -o jupyter-labs.pex -p /Users/myacct/.pyenv/shims/python
. When I go to run the pex with
jupyter-labs.pex -e jupyterlab.labapp:main
I get the following error:
Copy code
jupyter-labs.pex -e jupyterlab.labapp:main
Traceback (most recent call last):
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_main_module_details(_Error)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 219, in _get_main_module_details
    return _get_module_details(main_name)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 128, in _get_module_details
    spec = importlib.util.find_spec(mod_name)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/importlib/util.py", line 91, in find_spec
    return _find_spec(fullname, None)
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
  File "/Users/myacct/dev/virtualenvs/tmp-bc02eb6e921a2fd/jupyter-labs.pex/__main__.py", line 3
    [ -n "$PYENV_DEBUG" ] && set -x
                      ^
SyntaxError: invalid syntax
Am I missing something? I'm using a virtualenv to build the pex. I am also using
pyenv
for my python interpreter.
When I set
PYENV_DEBUG
to anything, I get debug information that begins with
[pyenv:22]
and
[pyenv-version-file:7]
etc.
I'm manually building this pex file to better understand how to code the
jupyter
plugin I've been discussing in #plugins.
f
the code in question is shell code which Python is rejecting
as for why a
__main__.py
has shell code, that is unexpected
j
This is the
__main__.py
in the built pex.
f
right, but the first part of that script is a bash script, not a Python script. the Python interpreter will not parse bash.
👍🏽 1
j
Looks like it is something with the jupyter-lab setup. I just redid it with a
sphinx
example and the
__main__.py
contains nothing but python in that pex.
Yes. I got that. Why it is putting it in there?
f
interesting, so the interaction of pex and jupyter-lab is doing something weird then
j
I think I may of found the problem.
doing a test...
found it. I had
-p /Users/myacct/.pyenv/shims/python
which is a bash script python shim.
user error
I'll update the question.
f
we potentially could have pex try to detect this case by flagging files passed to
-p
that have a shebang line that is not python
👍🏽 1
j
Is this something
pex
should error out on? If yes, I'll make an issue.
f
it is worth reporting. it may not be perfectly solvable but worth giving some thought to
j
I'll make an issue. At the worse it gets closed and we have a more permanent memory in github than this free slack.
👍 2
e
-p
!=
--python
That's an easy mistake to make, but I don't see a fix there. The
--help
docs are clear.
j
Yup. User error. 👁️ 👁️