Skip to content

rez-pkg-cache fails on Windows for packages with upper-case characters #2101

@nikshankarnoble

Description

@nikshankarnoble

On Windows, the rez.packages.get_package_from_uri() function returns None for any packages that have one or more uppercase characters in either their package or version name (when using the FilesystemPackageRepository. This also affects the get_variant_from_uri() method from the same module that calls it as well.

From what I can tell, the culprit is here where the URI path is lower-cased before all the subsequent comparison checks, but the subsequent checks for package and version through .get_package() are checking against the non-normalised versions, so they don't match:

uri = os.path.normcase(uri)

This was introduced a few years in the following PR, which was also to address issues around finding variants on Windows so I'm not sure what reverting this change could break:
#1011

This leads to any variants on these packages not being able to be added to the package cache manually using rez-pkg-cache, as it will give the following error:

$ rez-pkg-cache -a "\\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py[0]"
No such variant: \\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py[0]

This seems to still work for the normal rez-env case as you already have the Variant objects from the resolve - the issue here is getting from the URI input to the actual Variant API object.

Environment

  • OS: Windows 11 25H2
  • Rez version: 3.1.1
  • Rez python version: 3.10.10

To Reproduce

API

  1. On Windows, find a package that has at least one uppercase character in either the package name of version, e.g (Pyside6 or arch-AMD64) and get the full URI for it:
> rez-view arch-AMD64
URI:
\\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py
...
  1. Open up a Rez Python shell and run the following snippet, which will show that the API is not able to identify that package by it's URI:
>>> import rez.packages
>>> uri = r"\\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py"
>>> print(rez.packages.get_package_from_uri(uri))

If you repeat the test with a package version that has no uppercase characters in either package name or version, a Variant object should be returned.

CLI

  1. On Windows, find a variant that has at least one uppercase character in either the package name of version, e.g (Pyside6 or arch-AMD64) and get the full URI for it:
> rez-search arch-AMD64 -t variant -f "{uri}"
\\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py[]
  1. Try to add that URI to the package cache:
> rez-pkg-cache -a "\\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py[]"
16:49:43 INFO     Adding variant '\\\\storage\\pipeline\\rez\\packages\\prod\\ext\\arch\\AMD64\\package.py' to package cache at C:\...\rez\cache\:
No such variant: \\storage\pipeline\rez\packages\prod\ext\arch\AMD64\package.py

Expected behavior

The rez-pkg-cache command would finish successfully and the rez.packages.get_variant_from_uri() method would return a Variant object.

Actual behavior
Adding the package with an uppercase character to the package cache fails and does not return via the rez.packages.get_variant_from_uri() method.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions