Skip to content

Commit 71d2eb1

Browse files
authored
update vendored modules argcomplete, pydot, pyparsing (part 2) (#2022)
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
1 parent 668dc7f commit 71d2eb1

38 files changed

Lines changed: 13602 additions & 8139 deletions

src/rez/vendor/README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ tested.
2727
<tr><td>
2828
argcomplete
2929
</td><td>
30-
6f943d76400d6755c2152deff4f2c5c5fa4d9e7c (Jul 20, 2014)
30+
3.1.2 (Sep 16, 2023)
3131
</td><td>
3232
Apache 2.0
3333
</td><td>
3434
https://github.com/kislyuk/argcomplete<br>
35-
Our version is patched.
35+
Updated (Sept 2025)
3636
</td></tr>
3737

3838
<!-- ######################################################### -->
@@ -180,18 +180,12 @@ Updated (April 2025) to help address py3.12 update.
180180
<tr><td>
181181
pydot
182182
</td><td>
183-
1.4.2.dev0 (Oct 28, 2020)
183+
2.0.0 (Dec 30, 2023)
184184
</td><td>
185185
MIT
186186
</td><td>
187187
https://github.com/pydot/pydot<br>
188-
189-
* Updated (July 2019) in order to update pyparsing lib which in turn is
190-
required by the packaging library. Updated (Aug 2019) for py3.
191-
* Updated (Nov 2020) for finding right dot executable on Windows + Anaconda,
192-
see [pydot/pydot#205](https://github.com/pydot/pydot/issues/205) for detail.
193-
Also, pydot has not bumping version for a long time, log down commit change
194-
here: a10ced4 -> 03533f3
188+
Updated (Sept 2025)
195189
</td></tr>
196190

197191
<!-- ######################################################### -->
@@ -210,12 +204,12 @@ No longer maintained, moved to https://github.com/Shoobx/python-graph
210204
<tr><td>
211205
pyparsing
212206
</td><td>
213-
2.4.0 (Apr 8, 2019)
207+
3.1.4 (Aug 25, 2024)
214208
</td><td>
215209
MIT
216210
</td><td>
217211
https://github.com/pyparsing/pyparsing<br>
218-
Updated (July 2019) along with pydot to allow for packaging lib to be used.
212+
Updated (Sept 2025)
219213
</td></tr>
220214

221215
<!-- ######################################################### -->

src/rez/vendor/argcomplete/__init__.py

Lines changed: 8 additions & 444 deletions
Large diffs are not rendered by default.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
Utility for locating the module (or package's __init__.py)
3+
associated with a given console_script name
4+
and verifying it contains the PYTHON_ARGCOMPLETE_OK marker.
5+
6+
Such scripts are automatically generated and cannot contain
7+
the marker themselves, so we defer to the containing module or package.
8+
9+
For more information on setuptools console_scripts, see
10+
https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation
11+
12+
Intended to be invoked by argcomplete's global completion function.
13+
"""
14+
import os
15+
import sys
16+
17+
try:
18+
from importlib.metadata import entry_points as importlib_entry_points
19+
from importlib.metadata import EntryPoint
20+
use_entry_points_backport = False
21+
except ImportError:
22+
from importlib_metadata import entry_points as importlib_entry_points # type:ignore
23+
from importlib_metadata import EntryPoint # type:ignore
24+
use_entry_points_backport = True
25+
26+
from ._check_module import ArgcompleteMarkerNotFound, find
27+
from typing import Iterable
28+
29+
30+
def main():
31+
# Argument is the full path to the console script.
32+
script_path = sys.argv[1]
33+
34+
# Find the module and function names that correspond to this
35+
# assuming it is actually a console script.
36+
name = os.path.basename(script_path)
37+
38+
entry_points : Iterable[EntryPoint] = importlib_entry_points() # type:ignore
39+
40+
# The importlib_metadata backport returns a tuple of entry point objects
41+
# whereas the official library returns a SelectableGroups object
42+
# Python 3.12+ behaves like the importlib_metadata backport
43+
if not use_entry_points_backport and sys.version_info < (3, 12):
44+
entry_points = entry_points["console_scripts"] # type:ignore
45+
46+
entry_points = [ep for ep in entry_points \
47+
if ep.name == name and ep.group == "console_scripts" ] # type:ignore
48+
49+
if not entry_points:
50+
raise ArgcompleteMarkerNotFound("no entry point found matching script")
51+
entry_point = entry_points[0]
52+
module_name, function_name = entry_point.value.split(":", 1)
53+
54+
# Check this looks like the script we really expected.
55+
with open(script_path) as f:
56+
script = f.read()
57+
if "from {} import {}".format(module_name, function_name) not in script:
58+
raise ArgcompleteMarkerNotFound("does not appear to be a console script")
59+
if "sys.exit({}())".format(function_name) not in script:
60+
raise ArgcompleteMarkerNotFound("does not appear to be a console script")
61+
62+
# Look for the argcomplete marker in the script it imports.
63+
with open(find(module_name, return_package=True)) as f:
64+
head = f.read(1024)
65+
if "PYTHON_ARGCOMPLETE_OK" not in head:
66+
raise ArgcompleteMarkerNotFound("marker not found")
67+
68+
69+
if __name__ == "__main__":
70+
try:
71+
main()
72+
except ArgcompleteMarkerNotFound as e:
73+
sys.exit(str(e))
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"""
2+
Utility for locating a module (or package's __main__.py) with a given name
3+
and verifying it contains the PYTHON_ARGCOMPLETE_OK marker.
4+
5+
The module name should be specified in a form usable with `python -m`.
6+
7+
Intended to be invoked by argcomplete's global completion function.
8+
"""
9+
import os
10+
import sys
11+
import tokenize
12+
13+
try:
14+
from importlib.util import find_spec # type:ignore
15+
except ImportError:
16+
import typing as t
17+
from collections import namedtuple
18+
from imp import find_module
19+
20+
ModuleSpec = namedtuple("ModuleSpec", ["origin", "has_location", "submodule_search_locations"])
21+
22+
def find_spec( # type:ignore
23+
name: str,
24+
package: t.Optional[str] = None,
25+
) -> t.Optional[ModuleSpec]:
26+
"""Minimal implementation as required by `find`."""
27+
try:
28+
f, path, _ = find_module(name)
29+
except ImportError:
30+
return None
31+
has_location = path is not None
32+
if f is None:
33+
return ModuleSpec(None, has_location, [path])
34+
f.close()
35+
return ModuleSpec(path, has_location, None)
36+
37+
38+
class ArgcompleteMarkerNotFound(RuntimeError):
39+
pass
40+
41+
42+
def find(name, return_package=False):
43+
names = name.split(".")
44+
spec = find_spec(names[0])
45+
if spec is None:
46+
raise ArgcompleteMarkerNotFound('no module named "{}"'.format(names[0]))
47+
if not spec.has_location:
48+
raise ArgcompleteMarkerNotFound("cannot locate file")
49+
if spec.submodule_search_locations is None:
50+
if len(names) != 1:
51+
raise ArgcompleteMarkerNotFound("{} is not a package".format(names[0]))
52+
return spec.origin
53+
if len(spec.submodule_search_locations) != 1:
54+
raise ArgcompleteMarkerNotFound("expecting one search location")
55+
path = os.path.join(spec.submodule_search_locations[0], *names[1:])
56+
if os.path.isdir(path):
57+
filename = "__main__.py"
58+
if return_package:
59+
filename = "__init__.py"
60+
return os.path.join(path, filename)
61+
else:
62+
return path + ".py"
63+
64+
65+
def main():
66+
try:
67+
name = sys.argv[1]
68+
except IndexError:
69+
raise ArgcompleteMarkerNotFound("missing argument on the command line")
70+
71+
filename = find(name)
72+
73+
try:
74+
fp = tokenize.open(filename)
75+
except OSError:
76+
raise ArgcompleteMarkerNotFound("cannot open file")
77+
78+
with fp:
79+
head = fp.read(1024)
80+
81+
if "PYTHON_ARGCOMPLETE_OK" not in head:
82+
raise ArgcompleteMarkerNotFound("marker not found")
83+
84+
85+
if __name__ == "__main__":
86+
try:
87+
main()
88+
except ArgcompleteMarkerNotFound as e:
89+
sys.exit(str(e))

0 commit comments

Comments
 (0)