https://pantsbuild.org/ logo
#development
Title
# development
e

enough-analyst-54434

05/11/2023, 7:16 PM
Perhaps, but from the info you provided this should not work. Did you leave out a PEX_EXTRA_SYS_PATH or similar from the __run.sh contents?
1
b

bitter-ability-32190

05/11/2023, 7:40 PM
Why shouldn't it work? And no, no
PEX_EXTRA_SYS_PATH
e

enough-analyst-54434

05/11/2023, 7:52 PM
Because PEXes are hermetic by default and the entry point you specify is loose outside the PEX.
So the PEX purposefully cannot see
__nbconvert.py
unless you tell it to.
For example:
Copy code
jsirois@Gill-Windows:~/dev/pantsbuild/jsirois-scie-pants (install/specialize-setuptools-version *) $ echo "print(f'Here {__file__}')" > loose.py
jsirois@Gill-Windows:~/dev/pantsbuild/jsirois-scie-pants (install/specialize-setuptools-version *) $ pex -oempty.pex
jsirois@Gill-Windows:~/dev/pantsbuild/jsirois-scie-pants (install/specialize-setuptools-version *) $ PEX_MODULE=loose ./empty.pex
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/__main__.py", line 106, in <module>
    bootstrap_pex(__entry_point__, execute=__execute__, venv_dir=__venv_dir__)
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex_bootstrapper.py", line 618, in bootstrap_pex
    pex.PEX(entry_point).execute()
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 560, in execute
    sys.exit(self._wrap_coverage(self._wrap_profiling, self._execute))
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 467, in _wrap_coverage
    return runner(*args)
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 498, in _wrap_profiling
    return runner(*args)
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 592, in _execute
    return self.execute_entry(
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 800, in execute_entry
    return self.execute_module(entry_point.module)
  File "/home/jsirois/.pex/unzipped_pexes/6d69888624b3304a2671961f15e628c55daf5895/.bootstrap/pex/pex.py", line 808, in execute_module
    runpy.run_module(module_name, run_name="__main__", alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 220, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/usr/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named loose
jsirois@Gill-Windows:~/dev/pantsbuild/jsirois-scie-pants (install/specialize-setuptools-version *) $ PEX_EXTRA_SYS_PATH=. PEX_MODULE=loose ./empty.pex
Here /home/jsirois/dev/pantsbuild/jsirois-scie-pants/./loose.py
This is extremely old PEX behavior.
b

bitter-ability-32190

05/11/2023, 8:06 PM
Huh, well TIL. Thanks
e

enough-analyst-54434

05/11/2023, 8:07 PM
So what changed then?
b

bitter-ability-32190

05/11/2023, 8:09 PM
Something from Pants I presume in how it runs VenvPEXs? The branch's diff is minimal and the version is the only thing that makes sense
b

broad-processor-92400

05/11/2023, 10:03 PM
Might this be https://github.com/pantsbuild/pants/pull/18582 ? Do you only see the behaviour change when you run with
__run.sh
? Potentially it was previously inheriting something from your shell...
that's 2.17 only, nevermind...