Skip to content

Conversation

instinct-vfx
Copy link
Contributor

@instinct-vfx instinct-vfx commented Apr 16, 2025

Fixes #1948. Builds on #1943 as many of the issues are due to outdated vendored dependencies.

@instinct-vfx instinct-vfx requested a review from a team as a code owner April 16, 2025 11:26
@instinct-vfx instinct-vfx force-pushed the feat/add_support_for_python-3.12+_reloaded branch from c455cba to 7edd950 Compare April 16, 2025 11:28
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

❌ Patch coverage is 75.60976% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.81%. Comparing base (8fde5c2) to head (8e04b41).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/rez/utils/pip.py 84.84% 2 Missing and 3 partials ⚠️
src/rez/utils/py_dist.py 0.00% 4 Missing ⚠️
src/rez/bind/rez.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1950      +/-   ##
==========================================
+ Coverage   59.77%   59.81%   +0.04%     
==========================================
  Files         163      163              
  Lines       20005    20031      +26     
  Branches     3494     3503       +9     
==========================================
+ Hits        11958    11982      +24     
- Misses       7231     7233       +2     
  Partials      816      816              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@instinct-vfx instinct-vfx force-pushed the feat/add_support_for_python-3.12+_reloaded branch from f443e2b to 1e3e1ec Compare April 16, 2025 11:52
Copy link
Member

@JeanChristopheMorinPerso JeanChristopheMorinPerso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @instinct-vfx, I left some comments.

@maxnbk maxnbk added this to the Next milestone May 15, 2025
@maxnbk maxnbk force-pushed the feat/add_support_for_python-3.12+_reloaded branch from 1e3e1ec to 5bf9772 Compare May 15, 2025 16:16
maxnbk and others added 4 commits May 20, 2025 10:26
…es to importlib.metadata

Signed-off-by: Stephen Mackenzie <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
Signed-off-by: Jean-Christophe Morin <[email protected]>
@JeanChristopheMorinPerso
Copy link
Member

Tests are now passing. We should still try to install stuff with rez-pip, just in case. Our test suite doesn't have any tests for that.

@JeanChristopheMorinPerso
Copy link
Member

JeanChristopheMorinPerso commented Jun 21, 2025

Also, this PR technically drops support for Python 3.7 since we use importlib.metadata.

@JeanChristopheMorinPerso JeanChristopheMorinPerso changed the title Feat/add support for python 3.12+ reloaded Add support for python 3.12+ and drop support for 3.7 Jun 21, 2025
@JeanChristopheMorinPerso
Copy link
Member

JeanChristopheMorinPerso commented Sep 25, 2025

@instinct-vfx @maxnbk @bpabel do you have anything against merging this PR? If not, can you all give your approval please?

@Aphosis
Copy link

Aphosis commented Oct 3, 2025

Hi everyone,

Just a heads up, I stumbled upon this PR while debugging an issue with rez pip, and while it solves some issues it looks like it also introduces new ones.

For some context, I tried to install keyring with the following command (using the latest rez tag at first):

rez pip --install --python-version=3.10  keyring==25.2.1

It failed with the following traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\rez-install\Scripts\rez\rez.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\projects\rez\src\rez\cli\_entry_points.py", line 69, in run_rez
    return run()
           ^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\_main.py", line 189, in run
    returncode = run_cmd()
                 ^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\_main.py", line 181, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\pip.py", line 52, in command
    pip_install_package(
  File "C:\Users\user\projects\rez\src\rez\pip.py", line 344, in pip_install_package
    rez_requires = get_rez_requirements(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\utils\pip.py", line 405, in get_rez_requirements
    is_pure_python = is_pure_python_package(installed_dist)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\utils\pip.py", line 329, in is_pure_python_package
    wheel_data = setuptools_dist.get_metadata('WHEEL')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_metadata'

After some debugging it looked like it came from pkg_resources and distlib assigning slightly different names to the discovered distributions.

In particular, it was failing on jaraco.functools, since pkg_resources discovered it as jaraco_functools.

I manually tested discovering installed distributions with importlib.metadata and found out that it correctly gave jaraco.functools, so before writing a patch I checked to see if someone already opened an issue on GitHub and that's when I found your PR.

I went ahead and tested it with the same command, and it gave me another error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\user\rez-install\Scripts\rez\rez.exe\__main__.py", line 7, in <module>
  File "C:\Users\user\projects\rez\src\rez\cli\_entry_points.py", line 69, in run_rez
    return run()
           ^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\_main.py", line 189, in run
    returncode = run_cmd()
                 ^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\_main.py", line 181, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\cli\pip.py", line 52, in command
    pip_install_package(
  File "C:\Users\user\projects\rez\src\rez\pip.py", line 344, in pip_install_package
    rez_requires = get_rez_requirements(
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\utils\pip.py", line 420, in get_rez_requirements
    is_pure_python = is_pure_python_package(installed_dist)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\projects\rez\src\rez\utils\pip.py", line 332, in is_pure_python_package
    for f in setuptools_dist.files:
             ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'files'

After debugging it, it turns out this time it was failing on importlib_metadata: both importlib and distlib correctly gave the name importlib_metadata, but since the distlib name is further normalized by rez using (the now localized in rez) pkg_resources.safe_name function, it actual comparison in rez.utils.pip.convert_distlib_to_setuptools becomes "importlib_metadata" == "importlib-metadata", thus failing to map the distribution from importlib to distlib.

I also tried it with flask, sphinx, and requests just to see if that was not an isolated case, and only requests (and its dependencies) was installed successfully.

I can open a separate issue if needed, but since that looked like a regression I opted to comment here first.

If you need anything else I'll be happy to answer with more information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for python 3.12 and python 3.13
5 participants