AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
922 stars 329 forks source link

Error caused by weakly referenced package not specifying version range #1711

Closed loonghao closed 3 months ago

loonghao commented 3 months ago

Environment

To Reproduce

# internal_pkg  package.py
# -*- coding: utf-8 -*-

name = 'internal_pkg'

version = '0.3.0'

description = "XXX"

authors = ['XXX']

tools = []

requires = [
    'python-2.7..4',
    'setuptools-41..100',
    '~numpy',
    '~scipy'
]
variants = []
build_requires = []

private_build_requires = [
    'rez_builder-0',
    'setuptools_scm-1.15'
]

def commands():
    """Set up package."""
    env.PYTHONPATH.prepend("{this.root}/site-packages")  # noqa: F821

tests = {}

dev_requires = []

homepage = 'XXXX'

format_version = 2

Running the following command will result in the error shown below.

rez env internal_pkg scipy-1 -- python
Traceback (most recent call last):
  File "g:\rez\3.1.0\platform-windows\Vendor\Python\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "g:\rez\3.1.0\platform-windows\Vendor\Python\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "g:\rez\3.1.0\platform-windows\Scripts\rez_exe\rez.exe\__main__.py", line 7, in <module>
  File "g:\rez\3.1.0\platform-windows\rez\cli\_entry_points.py", line 69, in run_rez
    return run()
  File "g:\rez\3.1.0\platform-windows\rez\cli\_main.py", line 189, in run
    returncode = run_cmd()
  File "g:\rez\3.1.0\platform-windows\rez\cli\_main.py", line 181, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "g:\rez\3.1.0\platform-windows\rez\cli\env.py", line 205, in command
    context = ResolvedContext(
  File "g:\rez\3.1.0\platform-windows\rez\resolved_context.py", line 316, in __init__
    resolver.solve()
  File "g:\rez\3.1.0\platform-windows\rez\utils\memcached.py", line 262, in wrapper
    return func(*nargs, **kwargs)
  File "g:\rez\3.1.0\platform-windows\rez\resolver.py", line 123, in solve
    solver = self._solve()
  File "g:\rez\3.1.0\platform-windows\rez\resolver.py", line 408, in _solve
    solver.solve()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 2106, in solve
    self.solve_step()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 2186, in solve_step
    new_phase = phase.solve()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 1290, in solve
    scope_, extracted_request = scopes[i].extract()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 1115, in extract
    new_slice, package_request = self.variant_slice.extract()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 736, in extract
    if not self.extractable:
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 612, in extractable
    return not self.extracted_fams.issuperset(self.common_fams)
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 606, in common_fams
    self._update_fam_info()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 875, in _update_fam_info
    self._common_fams = set(self.first_variant.request_fams)
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 617, in first_variant
    entry.sort()
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 457, in sort
    self.variants.sort(key=key, reverse=True)
  File "g:\rez\3.1.0\platform-windows\rez\solver.py", line 432, in key
    range_key = orderer.sort_key(req.name, req.range)
  File "g:\rez\3.1.0\platform-windows\rez\package_order.py", line 143, in sort_key
    raise TypeError(version_like)
TypeError: None

Executed in version 3.1.0 The following command is as expected

rez ~numpy ~scipy scipy-1.6 -- python

In the package.py of internal_pkg, lock the weakly referenced numpy and scipy to specific version ranges. Executing the following command is also in line with expectations.

rez env internal_pkg scipy-1 -- python

Regression This error has appeared since 3.1.0 and is caused by the update of this PR. https://github.com/AcademySoftwareFoundation/rez/pull/1684/files