Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/rez/vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ tested.
<tr><td>
argcomplete
</td><td>
6f943d76400d6755c2152deff4f2c5c5fa4d9e7c (Jul 20, 2014)
3.1.2 (Sep 16, 2023)
</td><td>
Apache 2.0
</td><td>
https://github.com/kislyuk/argcomplete<br>
Our version is patched.
Updated (Sept 2025)
</td></tr>

<!-- ######################################################### -->
Expand Down Expand Up @@ -180,18 +180,12 @@ Updated (April 2025) to help address py3.12 update.
<tr><td>
pydot
</td><td>
1.4.2.dev0 (Oct 28, 2020)
2.0.0 (Dec 30, 2023)
</td><td>
MIT
</td><td>
https://github.com/pydot/pydot<br>

* Updated (July 2019) in order to update pyparsing lib which in turn is
required by the packaging library. Updated (Aug 2019) for py3.
* Updated (Nov 2020) for finding right dot executable on Windows + Anaconda,
see [pydot/pydot#205](https://github.com/pydot/pydot/issues/205) for detail.
Also, pydot has not bumping version for a long time, log down commit change
here: a10ced4 -> 03533f3
Updated (Sept 2025)
</td></tr>

<!-- ######################################################### -->
Expand All @@ -210,12 +204,12 @@ No longer maintained, moved to https://github.com/Shoobx/python-graph
<tr><td>
pyparsing
</td><td>
2.4.0 (Apr 8, 2019)
3.1.4 (Aug 25, 2024)
</td><td>
MIT
</td><td>
https://github.com/pyparsing/pyparsing<br>
Updated (July 2019) along with pydot to allow for packaging lib to be used.
Updated (Sept 2025)
</td></tr>

<!-- ######################################################### -->
Expand Down
452 changes: 8 additions & 444 deletions src/rez/vendor/argcomplete/__init__.py

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions src/rez/vendor/argcomplete/_check_console_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
Utility for locating the module (or package's __init__.py)
associated with a given console_script name
and verifying it contains the PYTHON_ARGCOMPLETE_OK marker.

Such scripts are automatically generated and cannot contain
the marker themselves, so we defer to the containing module or package.

For more information on setuptools console_scripts, see
https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation

Intended to be invoked by argcomplete's global completion function.
"""
import os
import sys

try:
from importlib.metadata import entry_points as importlib_entry_points
from importlib.metadata import EntryPoint
use_entry_points_backport = False
except ImportError:
from importlib_metadata import entry_points as importlib_entry_points # type:ignore
from importlib_metadata import EntryPoint # type:ignore
use_entry_points_backport = True

from ._check_module import ArgcompleteMarkerNotFound, find
from typing import Iterable


def main():
# Argument is the full path to the console script.
script_path = sys.argv[1]

# Find the module and function names that correspond to this
# assuming it is actually a console script.
name = os.path.basename(script_path)

entry_points : Iterable[EntryPoint] = importlib_entry_points() # type:ignore

# The importlib_metadata backport returns a tuple of entry point objects
# whereas the official library returns a SelectableGroups object
# Python 3.12+ behaves like the importlib_metadata backport
if not use_entry_points_backport and sys.version_info < (3, 12):
entry_points = entry_points["console_scripts"] # type:ignore

entry_points = [ep for ep in entry_points \
if ep.name == name and ep.group == "console_scripts" ] # type:ignore

if not entry_points:
raise ArgcompleteMarkerNotFound("no entry point found matching script")
entry_point = entry_points[0]
module_name, function_name = entry_point.value.split(":", 1)

# Check this looks like the script we really expected.
with open(script_path) as f:
script = f.read()
if "from {} import {}".format(module_name, function_name) not in script:
raise ArgcompleteMarkerNotFound("does not appear to be a console script")
if "sys.exit({}())".format(function_name) not in script:
raise ArgcompleteMarkerNotFound("does not appear to be a console script")

# Look for the argcomplete marker in the script it imports.
with open(find(module_name, return_package=True)) as f:
head = f.read(1024)
if "PYTHON_ARGCOMPLETE_OK" not in head:
raise ArgcompleteMarkerNotFound("marker not found")


if __name__ == "__main__":
try:
main()
except ArgcompleteMarkerNotFound as e:
sys.exit(str(e))
89 changes: 89 additions & 0 deletions src/rez/vendor/argcomplete/_check_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""
Utility for locating a module (or package's __main__.py) with a given name
and verifying it contains the PYTHON_ARGCOMPLETE_OK marker.

The module name should be specified in a form usable with `python -m`.

Intended to be invoked by argcomplete's global completion function.
"""
import os
import sys
import tokenize

try:
from importlib.util import find_spec # type:ignore
except ImportError:
import typing as t
from collections import namedtuple
from imp import find_module

ModuleSpec = namedtuple("ModuleSpec", ["origin", "has_location", "submodule_search_locations"])

def find_spec( # type:ignore
name: str,
package: t.Optional[str] = None,
) -> t.Optional[ModuleSpec]:
"""Minimal implementation as required by `find`."""
try:
f, path, _ = find_module(name)
except ImportError:
return None
has_location = path is not None
if f is None:
return ModuleSpec(None, has_location, [path])
f.close()
return ModuleSpec(path, has_location, None)


class ArgcompleteMarkerNotFound(RuntimeError):
pass


def find(name, return_package=False):
names = name.split(".")
spec = find_spec(names[0])
if spec is None:
raise ArgcompleteMarkerNotFound('no module named "{}"'.format(names[0]))
if not spec.has_location:
raise ArgcompleteMarkerNotFound("cannot locate file")
if spec.submodule_search_locations is None:
if len(names) != 1:
raise ArgcompleteMarkerNotFound("{} is not a package".format(names[0]))
return spec.origin
if len(spec.submodule_search_locations) != 1:
raise ArgcompleteMarkerNotFound("expecting one search location")
path = os.path.join(spec.submodule_search_locations[0], *names[1:])
if os.path.isdir(path):
filename = "__main__.py"
if return_package:
filename = "__init__.py"
return os.path.join(path, filename)
else:
return path + ".py"


def main():
try:
name = sys.argv[1]
except IndexError:
raise ArgcompleteMarkerNotFound("missing argument on the command line")

filename = find(name)

try:
fp = tokenize.open(filename)
except OSError:
raise ArgcompleteMarkerNotFound("cannot open file")

with fp:
head = fp.read(1024)

if "PYTHON_ARGCOMPLETE_OK" not in head:
raise ArgcompleteMarkerNotFound("marker not found")


if __name__ == "__main__":
try:
main()
except ArgcompleteMarkerNotFound as e:
sys.exit(str(e))
Loading
Loading