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

Python 3.12 does not provide setuptools, and circup needs it #213

Open
dhalbert opened this issue May 1, 2024 · 3 comments
Open

Python 3.12 does not provide setuptools, and circup needs it #213

dhalbert opened this issue May 1, 2024 · 3 comments

Comments

@dhalbert
Copy link
Contributor

dhalbert commented May 1, 2024

I installed circup 1.8.0 in a venv with Python 3.12.3 on Ubuntu 24.04. A Two problem arose:

  1. circup expects setuptools to be installed because it uses pkg_resources. pkg_resources is deprecated. From https://setuptools.pypa.io/en/latest/pkg_resources.html:

Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Some useful APIs are also provided by packaging (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.

2. After installing setuptools to work around problem 1, I got this when trying a simple install:
[deleted; my PATH was wrong]

@dhalbert dhalbert changed the title Python 3.12 problems Python 3.12 does not provide setuptools, and circup needs it May 1, 2024
@sjev
Copy link
Contributor

sjev commented May 5, 2024

I've picked up #189 . This one is related. However, I did not encounter issuse in a devcontainer running Python 3.12.3.

pip install . worked without issues. Please provide info on how to reproduce.

@dhalbert
Copy link
Contributor Author

dhalbert commented May 5, 2024

@sjev
Here is a reproduction on Ubuntu 24.04, running in a venv named .py. setuptools is installed in the venv, and then I uninstall it:

(.py) halbert@cod:~$ circup list
Found device at /media/halbert/CIRCUITPY, running CircuitPython 9.1.0-beta.1-16-g8734076e04-dirty.
All modules found on the device are up to date.
(.py) halbert@cod:~$ pip list |grep setuptools
setuptools                               69.5.1
(.py) halbert@cod:~$ pip3 uninstall setuptools
Found existing installation: setuptools 69.5.1
Uninstalling setuptools-69.5.1:
  Would remove:
    /home/halbert/.py/lib/python3.12/site-packages/_distutils_hack/*
    /home/halbert/.py/lib/python3.12/site-packages/distutils-precedence.pth
    /home/halbert/.py/lib/python3.12/site-packages/pkg_resources/*
    /home/halbert/.py/lib/python3.12/site-packages/setuptools-69.5.1.dist-info/*
    /home/halbert/.py/lib/python3.12/site-packages/setuptools/*
Proceed (Y/n)? y
  Successfully uninstalled setuptools-69.5.1
(.py) halbert@cod:~$ circup list
Traceback (most recent call last):
  File "/home/halbert/.py/bin/circup", line 5, in <module>
    from circup import main
  File "/home/halbert/.py/lib/python3.12/site-packages/circup/__init__.py", line 9, in <module>
    from circup.shared import DATA_DIR, BAD_FILE_FORMAT, extract_metadata, _get_modules_file
  File "/home/halbert/.py/lib/python3.12/site-packages/circup/shared.py", line 14, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

If you can't reproduce this make sure setuptools has not been installed via apt. E.g. try import setuptools in Python.

@sjev
Copy link
Contributor

sjev commented May 6, 2024

@dhalbert Thank you, this is clear. Now I see that I misunderstood the original issue.

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

No branches or pull requests

2 participants