Skip to content

Commit f1ec891

Browse files
authored
Merge pull request #31 from jreese/enhance
Enhanced package compatibility
2 parents f185897 + aebd317 commit f1ec891

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

dowsing/setuptools/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def mangle(package: str) -> str:
9696
d1.find_packages_include,
9797
):
9898
d1.packages_dict[p] = mangle(p)
99-
elif d1.packages != "??":
100-
assert isinstance(d1.packages, (list, tuple))
99+
elif d1.packages not in ("??", "????"):
100+
assert isinstance(
101+
d1.packages, (list, tuple)
102+
), f"{d1.packages!r} is not a list/tuple"
101103
for p in d1.packages:
102104
if p:
103105
d1.packages_dict[p] = mangle(p)

dowsing/setuptools/setup_py_parsing.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ def visit_Call(self, node: cst.Call) -> Optional[bool]:
141141
# TODO sometimes there is more than one setup call, we might
142142
# prioritize/merge...
143143
if any(
144-
q.name in ("setuptools.setup", "distutils.core.setup", "setup3lib")
144+
q.name
145+
in (
146+
"setuptools.setup",
147+
"distutils.core.setup",
148+
"setup3lib",
149+
"skbuild.setup",
150+
)
145151
for q in names
146152
):
147153
self.found_setup = True
@@ -177,7 +183,8 @@ def evaluate_in_scope(self, item: cst.CSTNode, scope: Any) -> Any:
177183

178184
if isinstance(item, cst.SimpleString):
179185
return item.evaluated_value
180-
# TODO int/float/etc
186+
elif isinstance(item, (cst.Integer, cst.Float)):
187+
return int(item.value)
181188
elif isinstance(item, cst.Name) and item.value in self.BOOL_NAMES:
182189
return self.BOOL_NAMES[item.value]
183190
elif isinstance(item, cst.Name):
@@ -277,7 +284,14 @@ def evaluate_in_scope(self, item: cst.CSTNode, scope: Any) -> Any:
277284
# TODO: Figure out why this is Sequence
278285
if isinstance(item.slice[0].slice, cst.Index):
279286
rhs = self.evaluate_in_scope(item.slice[0].slice.value, scope)
280-
return lhs.get(rhs, "??")
287+
try:
288+
if isinstance(lhs, dict):
289+
return lhs.get(rhs, "??")
290+
else:
291+
return lhs[rhs]
292+
except Exception:
293+
return "??"
294+
281295
else:
282296
# LOG.warning(f"Omit2 {type(item.slice[0].slice)!r}")
283297
return "??"

dowsing/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Distribution(pkginfo.distribution.Distribution): # type: ignore
6363
pbr: Optional[bool] = None
6464
pbr__files__packages_root: Optional[str] = None
6565
pbr__files__packages: Optional[str] = None
66+
provides_extra: Optional[Sequence[str]] = ()
6667

6768
def _getHeaderAttrs(self) -> Sequence[Tuple[str, str, bool]]:
6869
# Until I invent a metadata version to include this, do so

0 commit comments

Comments
 (0)