bitter-ability-32190
06/24/2022, 3:00 PMfrom pex.finders import get_entry_point_from_console_script
gets me most of the way there, but I need to also give it the list of distributions.
Pex grabs this with dists = list(self.activate())
on a PEX
object, however mimicking that goes š„
from pex.pex import PEX
dists=PEX().activate()
->
FileNotFoundError: [Errno 2] No such file or directory: '-c/PEX-INFO'
Before I go on, thought I'd ask here to make sure I'm not about to do something stupid šbitter-ability-32190
06/24/2022, 3:02 PMdebugpy
and having it execute a console_script
.
Basically I have pex
-> debugpy.pex
(which acts like the python
interpreter) -> -c "...my code to find and execute the script"
bitter-ability-32190
06/24/2022, 3:02 PMpex
and debugpy
use runpy
, so we're all still in one big happy envbitter-ability-32190
06/24/2022, 3:04 PMpex=os.environ.get("PEX')
gets me somewhere! Although I only see the distribution for debugpy
and not any of the other deps I'm shoehorning in via PEX_PATH
bitter-ability-32190
06/24/2022, 3:09 PMprint(os.environ.get('PEX_PATH', None));
is None
so I guess that checks. I'm guessing PEX is scrubbing itself by the time my code is executingbitter-ability-32190
06/24/2022, 3:11 PM"--no-strip-pex-env"
wins me a cokebitter-ability-32190
06/24/2022, 3:15 PM# NB: Use PEX itself to execute the console_script
(
"import os;"
+ "from pex.pex import PEX;"
+ f"PEX(pex=os.environ['PEX']).execute_script('{value.name}')"
),
bitter-ability-32190
06/24/2022, 5:43 PMbitter-ability-32190
06/25/2022, 8:42 PMenough-analyst-54434
06/26/2022, 4:05 AMbitter-ability-32190
06/26/2022, 10:58 AMbitter-ability-32190
06/26/2022, 11:17 AMenough-analyst-54434
06/26/2022, 1:41 PMenough-analyst-54434
06/26/2022, 1:46 PMenough-analyst-54434
06/26/2022, 1:52 PMbitter-ability-32190
06/26/2022, 1:54 PMbitter-ability-32190
06/26/2022, 1:54 PMbitter-ability-32190
06/26/2022, 1:56 PMenough-analyst-54434
06/26/2022, 2:04 PMbitter-ability-32190
06/26/2022, 2:09 PMbitter-ability-32190
06/26/2022, 2:10 PMenough-analyst-54434
06/26/2022, 2:22 PMjsirois@siroisdesign:~$ pex pex -c pex -o pex.pex
jsirois@siroisdesign:~$ ./pex.pex cowsay -c cowsay -o cowsay.pex
jsirois@siroisdesign:~$ PEX_SCRIPT=pex-tools ./pex.pex cowsay.pex info -i2
{
"bootstrap_hash": "2fe5b6193b3a13f029607461b1403422c82eb36e",
"build_properties": {
"pex_version": "2.1.92"
},
"code_hash": "1c57aa9488b00dac83e854a24dff9d6320daa013",
"distributions": {
"cowsay-5.0-py2.py3-none-any.whl": "9d9be34e631f7691e63cfbeb4b0f9add9b480da561e2b6d7421fc4e192a6d320"
},
"emit_warnings": true,
"entry_point": "cowsay.main:cli",
"ignore_errors": false,
"includes_tools": false,
"inherit_path": "false",
"interpreter_constraints": [],
"pex_hash": "d73b21ed0785f13e73b6b2272b6def7a0163224f",
"pex_path": null,
"requirements": [
"cowsay"
],
"strip_pex_env": true,
"venv": false,
"venv_bin_path": "false",
"venv_copies": false,
"venv_site_packages_copies": false,
"pex_root": "/home/jsirois/.pex"
}
enough-analyst-54434
06/26/2022, 2:23 PM"entry_point"
value to get the module of the console script.enough-analyst-54434
06/26/2022, 2:25 PMbitter-ability-32190
06/26/2022, 3:48 PMbitter-ability-32190
06/26/2022, 5:24 PMentry_point
I need a mapping of console_script name to entry_points š¤enough-analyst-54434
06/26/2022, 5:27 PMenough-analyst-54434
06/26/2022, 5:29 PMbitter-ability-32190
06/26/2022, 5:29 PMsetuptools
and make sure we use hashes and the other stuff to ensure safety for our users
⢠Have to make sure the PEX_PATH
uses the correct ordering
⢠Involves yet another PEXenough-analyst-54434
06/26/2022, 5:30 PMenough-analyst-54434
06/26/2022, 5:30 PMbitter-ability-32190
06/26/2022, 5:39 PMbitter-ability-32190
06/26/2022, 5:40 PMimportlib_metadata
into the debugpy PEX and conventionally add it last.
Pants isnt set up to support this easily though (hashes and whatnot would be handcrafted)enough-analyst-54434
06/26/2022, 5:40 PMbitter-ability-32190
06/26/2022, 5:41 PM