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

[CI] Python 3.12 compatibility #818

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Conversation

kurtamohler
Copy link
Collaborator

@kurtamohler kurtamohler commented Jun 17, 2024

Description

Adds support for Python 3.12

Motivation and Context

fixes #766

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • New feature (non-breaking change which adds core functionality)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 17, 2024
@kurtamohler
Copy link
Collaborator Author

Unfortunately, pre-commit doesn't seem to work correctly for me with Python 3.12:

$ pre-commit run --all-files
...
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

Traceback (most recent call last):
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/bin/flake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/main/application.py", line 375, in run
    self._run(argv)
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/main/application.py", line 363, in _run
    self.initialize(argv)
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/main/application.py", line 343, in initialize
    self.find_plugins(config_finder)
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/main/application.py", line 157, in find_plugins
    self.check_plugins = plugin_manager.Checkers(local_plugins.extension)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/plugins/manager.py", line 363, in __init__
    self.manager = PluginManager(
                   ^^^^^^^^^^^^^^
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/plugins/manager.py", line 243, in __init__
    self._load_entrypoint_plugins()
  File "/home/endoplasm/.cache/pre-commit/reporpfvou3s/py_env-python3.12/lib/python3.12/site-packages/flake8/plugins/manager.py", line 261, in _load_entrypoint_plugins
    eps = importlib_metadata.entry_points().get(self.namespace, ())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EntryPoints' object has no attribute 'get'

But if I try running it in an environment that has Python 3.11, it passes.

To reproduce the failure:

conda create -n tmp
conda activate tmp
conda install python==3.12
pip install pre-commit
pre-commit run --all-files

@kurtamohler
Copy link
Collaborator Author

I was able to fix that error by updating the rev field for flake8 in .pre-commit-config.yaml, so I'll add that to this PR

@@ -71,7 +83,7 @@ jobs:
- name: Build wheel
shell: bash
run: |
python3 -mpip install wheel
python3 -mpip install wheel setuptools
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this to fix this failure: https://github.com/pytorch/tensordict/actions/runs/9555748210/job/26354755267?pr=818

In Python 3.12, setuptools is required to be able to import distutils

Not sure if this is really the best place to add this dependency

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok, long term we should use smth like what torchtune has (ie no setup.py at all)
https://github.com/pytorch/torchtune/blob/main/pyproject.toml

Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

LGTM thanks for this!

@vmoens vmoens merged commit d7ba913 into pytorch:main Jun 19, 2024
39 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. versioning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Out of date pip install for python 3.12 / Ubuntu 24.04 LTS
3 participants