Skip to content

rez-pip can't handle python_version requirements in packages #96

@BryceGattis

Description

@BryceGattis

elastictransport 8.12.0 has the following requirements:

'urllib3 <3,>=1.26.2',
'certifi',
'dataclasses ; python_version < "3.7"',
'importlib-metadata ; python_version < "3.8"'
...
...

When running rez-pip2 elastictransport==8.12.0, I end up getting a ResourceError like this:

Traceback (most recent call last):
  File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Rez\Scripts\rez-pip2.exe\__main__.py", line 7, in <module>
  File "c:\program files\rez\lib\site-packages\rez_pip\cli.py", line 324, in run
    _run(args, pipArgs, pipWorkArea)
  File "c:\program files\rez\lib\site-packages\rez_pip\cli.py", line 225, in _run
    release=args.release,
  File "c:\program files\rez\lib\site-packages\rez_pip\rez.py", line 126, in createPackage
    pkg.pip["metadata"] = remainingMetadata
  File "C:\Python37\lib\contextlib.py", line 119, in __exit__
    next(self.gen)
  File "c:\program files\rez\lib\site-packages\rez\package_maker.py", line 209, in make_package
    variant_ = variant.install(path, dry_run=True)
  File "c:\program files\rez\lib\site-packages\rez\packages.py", line 457, in install
    overrides=overrides)
  File "c:\program files\rez\lib\site-packages\rezplugins\package_repository\filesystem.py", line 951, in install_variant

    variant = _create_variant()
  File "c:\program files\rez\lib\site-packages\rezplugins\package_repository\filesystem.py", line 947, in _create_variant

    overrides=overrides
  File "c:\program files\rez\lib\site-packages\rezplugins\package_repository\filesystem.py", line 1246, in _create_variant
    % (variant, package))
rez.exceptions.ResourceError: Attempting to install a package without variants (MemoryVariantResource({'location': 'memory{0x1ea5f20c0e8}', 'name': 'elastic_transport', 'version': '8.12.0', 'index': None, 'repository_type': 'memory'})) into an existing package with variants (FileSystemPackageResource({'location': '\\\\vm-fs-003\\prod\\sww\\rez\\packages', 'name': 'elastic_transport', 'version': '8.12.0', 'repository_type': 'filesystem'}))

It seems like the python version dependent dependency was put in the variant list in the output package.py file:

variants = [['importlib_metadata']]

I am doing the rez-pip install with both Python 3.7.9 and Python 3.9.10 at the same time (by not specifying --python-version).

The issue seems to be that the Python 3.7 variant requires importlib-metadata but the 3.9 variant does not, and so the above crash happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions