Skip to content
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

Don't depend on distutils #1121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wentasah
Copy link

@wentasah wentasah commented Oct 16, 2024

Checklist:

  • Your branch is up-to-date with the master branch and tested with latest changes
  • Extended the README / documentation, if necessary
  • Code compiles correctly and runs
  • Code is formatted and checked with Utilities/code_check_and_formatting.sh
  • Changelog is updated

Description

distutils are no longer available in Python 3.12. Therefore, we copy the strtobool function from distutils to our own module. This is in line with https://peps.python.org/pep-0632/#migration-advice.

Where has this been tested?

  • Platform(s): Linux
  • Python version(s): 3.12
  • Unreal Engine version(s): 4.26
  • CARLA version: 0.9.15

Possible Drawbacks

Hopefully none.


This change is Reviewable

@@ -15,6 +15,7 @@
## Upcoming
* Improvements to the CarlaDataProvider:
- Added `spawn_actor` for a blueprint based actor creation similar to `World.spawn_actor`
* Allow using with Python 3.12
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Allow using with Python 3.12
* Implement `strtobool` formerly included in `distutils`, which is removed in Python 3.12.

I am certain you checked it with 3.12, however I think its not yet 100% 3.12 ready, e.g. the requirements.txt file, and the core team should make this stement.
Therefore, I think we should adjust this statement to be more precise on this PR.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is better. I'm using this with 3.12, but without the requirements.txt file, so its content might need some update.

srunner/util.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a tools and utilities folder. I suggest to move this to a tools/strtobool.py or another fitting file.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense. Moved.

distutils are no longer available in Python 3.12. Therefore, we copy
the strtobool function from distutils to our own module. This is in
line with https://peps.python.org/pep-0632/#migration-advice.
Copy link
Contributor

@Daraan Daraan left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 5 files at r2, all commit messages.
Reviewable status: 4 of 5 files reviewed, 2 unresolved discussions

@ClemensLinnhoff
Copy link

I tried this branch, but I still get an error during installing of the requirements:

ModuleNotFoundError: No module named 'distutils.msvccompiler'

I am under Ubuntu 22.04 and I tried it in a venv with Python 3.

@wentasah
Copy link
Author

Can you send the full backtrace? I don't see any occurrence of msvccompiler in the scenario runner code base, so this is probably from some dependency. I was testing this on NixOS and used different versions of dependencies than those from requirements.txt.

@ClemensLinnhoff
Copy link

Here is the full output:

Collecting py-trees==0.8.3
  Using cached py_trees-0.8.3-py3-none-any.whl (61 kB)
Collecting numpy==1.18.4
  Using cached numpy-1.18.4.zip (5.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      Running from numpy source directory.
      <string>:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      Traceback (most recent call last):
        File "/opt/carla-simulator/scenario_runner/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/carla-simulator/scenario_runner/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/carla-simulator/scenario_runner/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-yvnxgwvm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 377, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-yvnxgwvm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-yvnxgwvm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 488, in <module>
        File "<string>", line 465, in setup_package
        File "/tmp/pip-install-rtdln26_/numpy_7122fe4224844daeb3356d0eb1228b32/numpy/distutils/core.py", line 26, in <module>
          from numpy.distutils.command import config, config_compiler, \
        File "/tmp/pip-install-rtdln26_/numpy_7122fe4224844daeb3356d0eb1228b32/numpy/distutils/command/config.py", line 20, in <module>
          from numpy.distutils.mingw32ccompiler import generate_manifest
        File "/tmp/pip-install-rtdln26_/numpy_7122fe4224844daeb3356d0eb1228b32/numpy/distutils/mingw32ccompiler.py", line 34, in <module>
          from distutils.msvccompiler import get_build_version as get_build_msvc_version
      ModuleNotFoundError: No module named 'distutils.msvccompiler'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

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.

3 participants