Skip to content

Commit

Permalink
fix: add platform/arch to variant for rez-pip packages with entry poi…
Browse files Browse the repository at this point in the history
…nt scripts (#1287)

* fix: add platform/arch to variant for rez-pip packages with entry point scripts

Signed-off-by: Brendan Abel <[email protected]>
  • Loading branch information
bpabel authored Nov 15, 2022
1 parent d40536e commit 6720b7e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/rez/tests/test_pip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ def test_is_pure_python_package(self):

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

def test_is_entry_points_scripts_package(self):
"""
"""
dpath = rez.vendor.distlib.database.DistributionPath([self.dist_path])
dist = list(dpath.get_distributions())[0]
self.assertFalse(rez.utils.pip.is_entry_points_scripts_package(dist))

def test_convert_distlib_to_setuptools_wrong(self):
"""
"""
Expand Down
21 changes: 20 additions & 1 deletion src/rez/utils/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@ def is_pure_python_package(installed_dist):
return (is_purelib == "true")


def is_entry_points_scripts_package(installed_dist):
"""Determine if a dist has generated entry point scripts.
Args:
installed_dist (`distlib.database.InstalledDistribution`): Distribution
to test.
Returns:
bool: True if dist has generated entry point scripts
"""
setuptools_dist = convert_distlib_to_setuptools(installed_dist)

entry_map = setuptools_dist.get_entry_map()
return bool(entry_map.get("console_scripts") or entry_map.get("gui_scripts"))


def get_rez_requirements(installed_dist, python_version, name_casings=None):
"""Get requirements of the given dist, in rez-compatible format.
Expand Down Expand Up @@ -383,7 +399,10 @@ def get_rez_requirements(installed_dist, python_version, name_casings=None):

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

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

0 comments on commit 6720b7e

Please sign in to comment.