-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PEX info to the PEX repl. (#2496)
It should now be clear when you've dropped into a PEX repl (vs. a plain Python repl). This may help stem some of the confusion brough about by running `pex` with no arguments. In addition, you gain some introspection capabilities via the `pex_info` REPL command. Fixes #157
- Loading branch information
Showing
48 changed files
with
1,640 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2024 Pex project contributors. | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import absolute_import | ||
|
||
import os | ||
import sys | ||
|
||
from pex.compatibility import commonpath | ||
from pex.typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import Optional | ||
|
||
|
||
def prog_path(prog=None): | ||
# type: (Optional[str]) -> str | ||
"""Generate the most concise path possible that is still runnable on the command line.""" | ||
|
||
exe_path = os.path.abspath(prog or sys.argv[0]) | ||
cwd = os.path.abspath(os.getcwd()) | ||
if commonpath((exe_path, cwd)) == cwd: | ||
exe_path = os.path.relpath(exe_path, cwd) | ||
# Handle users that do not have . as a PATH entry. | ||
if not os.path.dirname(exe_path) and os.curdir not in os.environ.get("PATH", "").split( | ||
os.pathsep | ||
): | ||
exe_path = os.path.join(os.curdir, exe_path) | ||
else: | ||
for path_entry in os.environ.get("PATH", "").split(os.pathsep): | ||
abs_path_entry = os.path.abspath(path_entry) | ||
if commonpath((exe_path, abs_path_entry)) == abs_path_entry: | ||
return os.path.relpath(exe_path, abs_path_entry) | ||
return exe_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2024 Pex project contributors. | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import absolute_import | ||
|
||
# For re-export | ||
from pex.repl.pex_repl import ( # noqa | ||
create_pex_repl, | ||
create_pex_repl_exe, | ||
export_pex_cli_no_args_use, | ||
) | ||
|
||
__all__ = ("create_pex_repl", "create_pex_repl_exe", "export_pex_cli_no_args_use") |
Oops, something went wrong.