Skip to content

Commit 6720b7e

Browse files
authored
fix: add platform/arch to variant for rez-pip packages with entry point scripts (#1287)
* fix: add platform/arch to variant for rez-pip packages with entry point scripts Signed-off-by: Brendan Abel <[email protected]>
1 parent d40536e commit 6720b7e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/rez/tests/test_pip_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ def test_is_pure_python_package(self):
149149

150150
self.assertTrue(rez.utils.pip.is_pure_python_package(dist))
151151

152+
def test_is_entry_points_scripts_package(self):
153+
"""
154+
"""
155+
dpath = rez.vendor.distlib.database.DistributionPath([self.dist_path])
156+
dist = list(dpath.get_distributions())[0]
157+
self.assertFalse(rez.utils.pip.is_entry_points_scripts_package(dist))
158+
152159
def test_convert_distlib_to_setuptools_wrong(self):
153160
"""
154161
"""

src/rez/utils/pip.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,22 @@ def is_pure_python_package(installed_dist):
332332
return (is_purelib == "true")
333333

334334

335+
def is_entry_points_scripts_package(installed_dist):
336+
"""Determine if a dist has generated entry point scripts.
337+
338+
Args:
339+
installed_dist (`distlib.database.InstalledDistribution`): Distribution
340+
to test.
341+
342+
Returns:
343+
bool: True if dist has generated entry point scripts
344+
"""
345+
setuptools_dist = convert_distlib_to_setuptools(installed_dist)
346+
347+
entry_map = setuptools_dist.get_entry_map()
348+
return bool(entry_map.get("console_scripts") or entry_map.get("gui_scripts"))
349+
350+
335351
def get_rez_requirements(installed_dist, python_version, name_casings=None):
336352
"""Get requirements of the given dist, in rez-compatible format.
337353
@@ -383,7 +399,10 @@ def get_rez_requirements(installed_dist, python_version, name_casings=None):
383399

384400
# assume package is platform- and arch- specific if it isn't pure python
385401
is_pure_python = is_pure_python_package(installed_dist)
386-
if not is_pure_python:
402+
# entry_points scripts are platform and arch specific executables generated by
403+
# python build frontends during install
404+
has_entry_points_scripts = is_entry_points_scripts_package(installed_dist)
405+
if not is_pure_python or has_entry_points_scripts:
387406
sys_requires.update(["platform", "arch"])
388407

389408
# evaluate wrt python version, which may not be the current interpreter version

0 commit comments

Comments
 (0)