Skip to content

Replace distutils.version with looseversion since the former was deprecated in python 3.10 and removed in 3.12. #99549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

dyung
Copy link
Collaborator

@dyung dyung commented Jul 18, 2024

Python deprecated the distutils package in 3.10, and removed it in 3.12 causing problems when trying to run the lit tests with 3.12.

https://docs.python.org/3.10/library/distutils.html

Replace usage with the looseversion package which should be a drop-in replacement for the original usage.

@dyung dyung requested a review from tlively July 18, 2024 19:04
@tlively
Copy link
Collaborator

tlively commented Jul 18, 2024

Change LGTM, but I'm not sure whether LLVM has policies around introducing new developer dependencies like this package. Do you know?

@dyung
Copy link
Collaborator Author

dyung commented Jul 18, 2024

Change LGTM, but I'm not sure whether LLVM has policies around introducing new developer dependencies like this package. Do you know?

I'm not sure to be honest. Any ideas who to ask?

Copy link
Collaborator

@tlively tlively left a comment

Choose a reason for hiding this comment

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

I asked around on an internal LLVM chat and consensus was that this is probably fine to commit, but it would also be ideal to reimplement the logic to avoid the dependency. There was one idea to limit the scope of the import, e.g.

if dwarf_version_string and gdb_version_string:
    if int(dwarf_version_string) >= 5:
        try:
          from looseversion import LooseVersion
        except:
          raise Error("running gdb tests requires the looseversion package")
        if LooseVersion(gdb_version_string) < LooseVersion("10.1"):

But I don't want to block this :)

@dyung
Copy link
Collaborator Author

dyung commented Jul 18, 2024

I asked around on an internal LLVM chat and consensus was that this is probably fine to commit, but it would also be ideal to reimplement the logic to avoid the dependency. There was one idea to limit the scope of the import, e.g.

if dwarf_version_string and gdb_version_string:
    if int(dwarf_version_string) >= 5:
        try:
          from looseversion import LooseVersion
        except:
          raise Error("running gdb tests requires the looseversion package")
        if LooseVersion(gdb_version_string) < LooseVersion("10.1"):

But I don't want to block this :)

Thanks! I'll look into rewriting it into something similar, I just wanted to make sure this got in before the release branching next week since it is causing us a lot of headaches internally.

@ilovepi
Copy link
Contributor

ilovepi commented Jul 18, 2024

@mysterymath you may want to take a look at this before it hits Fuchsia CI.

@mysterymath
Copy link
Contributor

We've a workable solution for this in Fuchsia now, so I think this is good to proceed.

@dyung dyung merged commit 1492e5f into llvm:main Jul 20, 2024
6 checks passed
@dyung dyung deleted the dyung/main/remove-distutils branch July 20, 2024 19:08
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 20, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building cross-project-tests at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/2785

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using split-file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/split-file
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using yaml2obj: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/yaml2obj
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using llvm-objcopy: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/llvm-objcopy
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/utils/lit/lit/TestingConfig.py:152: fatal: unable to parse config file '/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/cross-project-tests/lit.cfg.py', traceback: Traceback (most recent call last):
  File "/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 140, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/cross-project-tests/lit.cfg.py", line 7, in <module>
    from looseversion import LooseVersion
ModuleNotFoundError: No module named 'looseversion'

FAILED: CMakeFiles/check-all /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/CMakeFiles/check-all 
cd /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build && /usr/bin/python3.10 /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/./bin/llvm-lit --verbose -j100 --param USE_Z3_SOLVER=0 /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/utils/mlgo-utils /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/projects/cross-project-tests /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/lld/test /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/include-cleaner/test /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/pseudo/test /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/test /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/utils/lit /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/test
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 20, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-gcc-ubuntu running on sie-linux-worker3 while building cross-project-tests at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/174/builds/2014

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using split-file: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/split-file
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using yaml2obj: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/yaml2obj
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using llvm-objcopy: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llvm-objcopy
llvm-lit: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/utils/lit/lit/TestingConfig.py:152: fatal: unable to parse config file '/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/cross-project-tests/lit.cfg.py', traceback: Traceback (most recent call last):
  File "/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 140, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/cross-project-tests/lit.cfg.py", line 7, in <module>
    from looseversion import LooseVersion
ModuleNotFoundError: No module named 'looseversion'

FAILED: CMakeFiles/check-all /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/CMakeFiles/check-all 
cd /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build && /usr/bin/python3.8 /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-lit --verbose --param USE_Z3_SOLVER=0 /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/utils/mlgo-utils /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/cross-project-tests /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/lld/test /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/tools/extra/include-cleaner/test /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/tools/extra/pseudo/test /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/tools/extra/test /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/test @/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/lit.tests /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/utils/lit /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/test
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 20, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building cross-project-tests at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/2264

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
llvm-lit: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using split-file: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/split-file
llvm-lit: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using yaml2obj: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/yaml2obj
llvm-lit: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using llvm-objcopy: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/llvm-objcopy
llvm-lit: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit/TestingConfig.py:152: fatal: unable to parse config file '/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/cross-project-tests/lit.cfg.py', traceback: Traceback (most recent call last):
  File "/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 140, in load_from_path
    exec(compile(data, path, "exec"), cfg_globals, None)
  File "/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/cross-project-tests/lit.cfg.py", line 7, in <module>
    from looseversion import LooseVersion
ModuleNotFoundError: No module named 'looseversion'

FAILED: CMakeFiles/check-all /Users/buildbot/buildbot-root/aarch64-darwin/build/CMakeFiles/check-all 
cd /Users/buildbot/buildbot-root/aarch64-darwin/build && /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 /Users/buildbot/buildbot-root/aarch64-darwin/build/./bin/llvm-lit --verbose --param USE_Z3_SOLVER=0 /Users/buildbot/buildbot-root/aarch64-darwin/build/utils/mlgo-utils /Users/buildbot/buildbot-root/aarch64-darwin/build/projects/cross-project-tests /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/lld/test /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/include-cleaner/test /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/pseudo/test /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/clangd/test/../unittests /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/clangd/test /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test /Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/test /Users/buildbot/buildbot-root/aarch64-darwin/build/utils/lit /Users/buildbot/buildbot-root/aarch64-darwin/build/test
ninja: build stopped: subcommand failed.

JDevlieghere added a commit that referenced this pull request Jul 20, 2024
…was deprecated in python 3.10 and removed in 3.12." (#99786)

Reverts #99549 because it breaks a bunch of build bots.
@JDevlieghere
Copy link
Member

Reverted this as this breaks a bunch of build bots. This definitely deserves more discussion. For example, we took an alternative approach in LLDB (see #93712) which may be applicable here too?

@dyung
Copy link
Collaborator Author

dyung commented Jul 20, 2024

Reverted this as this breaks a bunch of build bots. This definitely deserves more discussion. For example, we took an alternative approach in LLDB (see #93712) which may be applicable here too?

@JDevlieghere did this break any of your bots other than the ones reported here? All of the ones listed here are my bots and I'm in the process of updating them.

@dyung
Copy link
Collaborator Author

dyung commented Jul 20, 2024

For example, we took an alternative approach in LLDB (see #93712) which may be applicable here too?

The LLDB approach also seems to require an extra package to be installed that is not part of the default python distribution, is that really that different from the approach here?

@JDevlieghere
Copy link
Member

JDevlieghere commented Jul 20, 2024

Reverted this as this breaks a bunch of build bots. This definitely deserves more discussion. For example, we took an alternative approach in LLDB (see #93712) which may be applicable here too?

@JDevlieghere did this break any of your bots other than the ones reported here? All of the ones listed here are my bots and I'm in the process of updating them.

Yes, it also broke the GreenDragon bots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/ which you wouldn't be able to update yourself.

The LLDB approach also seems to require an extra package to be installed that is not part of the default python distribution, is that really that different from the approach here?

It's not, except that maybe one could argue that packaging is maintained by a Python workgroup and has millions of users compared to this package, which seems to be maintained by a single person and has a few thousand users. More importantly though, we should have the same solution across subprojects to avoid bots and developers having to install an increasing number of arbitrary packages.

@dyung
Copy link
Collaborator Author

dyung commented Jul 20, 2024

Reverted this as this breaks a bunch of build bots. This definitely deserves more discussion. For example, we took an alternative approach in LLDB (see #93712) which may be applicable here too?

@JDevlieghere did this break any of your bots other than the ones reported here? All of the ones listed here are my bots and I'm in the process of updating them.

Yes, it also broke the GreenDragon bots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/ which you wouldn't be able to update yourself.

Ah, sorry about that.

The LLDB approach also seems to require an extra package to be installed that is not part of the default python distribution, is that really that different from the approach here?

It's not, except that maybe one could argue that packaging is maintained by a Python workgroup and has millions of users compared to this package, which seems to be maintained by a single person and has a few thousand users. More importantly though, we should have the same solution across subprojects to avoid bots and developers having to install an increasing number of arbitrary packages.

I did try to look at using the packaging package instead, but it seemed to require more work to make sure everything worked while using looseversion was a drop-in replacement that should just work with minimal changes required. I wasn't aware of the work done in GDB to try and solve a similar problem, but will look into it, thanks for pointing it out (we don't run LLDB internally). If we did want to borrow the same or a similar approach, it would make more sense if both could share the same code, so bug fixes in one would be fixed in both. Is there a way to do that in the current system?

dyung added a commit that referenced this pull request Jul 22, 2024
… deprecated in python 3.10 and removed in 3.12. (#99852)

Attempt to reland #99549, but using packaging.version instead of
looseversion, based on the usage used for LLDB in #93712.
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
…ecated in python 3.10 and removed in 3.12. (#99549)

Summary:
Python deprecated the distutils package in 3.10, and removed it in 3.12
causing problems when trying to run the lit tests with 3.12.

https://docs.python.org/3.10/library/distutils.html

Replace usage with the looseversion package which should be a drop-in
replacement for the original usage.

If your testing fails after this commit, you need to install the looseversion package.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251589
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
…was deprecated in python 3.10 and removed in 3.12." (#99786)

Summary: Reverts #99549 because it breaks a bunch of build bots.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251297
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
… deprecated in python 3.10 and removed in 3.12. (#99852)

Attempt to reland #99549, but using packaging.version instead of
looseversion, based on the usage used for LLDB in #93712.
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.

6 participants