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

Installing Pyasyncore with Python 3.12 doesn't install Python files on Raspbian 12 #2

Closed
erikmouw opened this issue Feb 21, 2024 · 4 comments

Comments

@erikmouw
Copy link

Installing pyasyncore with Python3.12 doesn't install any files on Raspbian 12.

OS release:

pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

How to reproduce:

pi@raspberrypi:~ $ cd /scratch/tmp/
pi@raspberrypi:/scratch/tmp $ python3.12 -m venv venv
pi@raspberrypi:/scratch/tmp $ source venv/bin/activate
(venv) pi@raspberrypi:/scratch/tmp $ pip install pyasyncore
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyasyncore
  Using cached https://www.piwheels.org/simple/pyasyncore/pyasyncore-1.0.3-py3-none-any.whl (3.8 kB)
Installing collected packages: pyasyncore
Successfully installed pyasyncore-1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ pip list
Package    Version
---------- -------
pip        24.0
pyasyncore 1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ python
Python 3.12.2 (main, Feb 17 2024, 13:29:44) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'asyncore'
>>>

A workaround is to tell pip to install no binaries:

(venv) pi@raspberrypi:/scratch/tmp $ pip uninstall pyasyncore
Found existing installation: pyasyncore 1.0.3
Uninstalling pyasyncore-1.0.3:
  Would remove:
    /scratch/tmp/venv/lib/python3.12/site-packages/pyasyncore-1.0.3.dist-info/*
Proceed (Y/n)? y
  Successfully uninstalled pyasyncore-1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ pip cache purge
(venv) pi@raspberrypi:/scratch/tmp $ pip install --no-binary :all: pyasyncore
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyasyncore
  Using cached pyasyncore-1.0.3.tar.gz (9.9 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyasyncore
  Building wheel for pyasyncore (pyproject.toml) ... done
  Created wheel for pyasyncore: filename=pyasyncore-1.0.3-py3-none-any.whl size=10120 sha256=60b1894391a6ea2d4a6caa625ad2d5280a64dc4ba1d38ef004f1414208814536
  Stored in directory: /home/pi/.cache/pip/wheels/9c/fb/ac/1b44d6b1b833c08f1a502d805221c25b327b0d4ce3f40b59c5
Successfully built pyasyncore
Installing collected packages: pyasyncore
Successfully installed pyasyncore-1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ python
Python 3.12.2 (main, Feb 17 2024, 13:29:44) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore
>>>

The workaround makes sure that pip doesn't try to download binary wheels but builds a wheel locally. It looks like there is no binary wheel for Raspbian 12 uploaded to Pypi (Iooking at the locally generated wheels it should be a cp312-cp312-linux_armv7l type wheel).

@erikmouw
Copy link
Author

FYI: I was hoping I could recreate this issue on MacOS (Intel based MacBook with Python 3.12 from brew), but there pip install pyasyncore just works as expected. Unfortunately I don't have an ARM based Mac to test.

@simonrob
Copy link
Owner

Thannks for the report. This is strange – there's no native code involved, so the platform shouldn't matter. Regardless, I tried on an ARM based macOS laptop just now and it works fine:

~ › python -m venv .venv
~source .venv/bin/activate
(.venv) ~ › python --version
Python 3.12.2
(.venv) ~ › python -m pip install pyasyncore
Collecting pyasyncore
  Downloading pyasyncore-1.0.3-py3-none-any.whl.metadata (3.4 kB)
Downloading pyasyncore-1.0.3-py3-none-any.whl (10 kB)
Installing collected packages: pyasyncore
Successfully installed pyasyncore-1.0.3
(.venv) ~ › python
Python 3.12.2 (main, Feb 21 2024, 20:16:56) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore
>>> asyncore.
asyncore.EAGAIN                 asyncore.EPIPE                  asyncore.errorcode              asyncore.readwrite(
[...]

The only difference I can see is the file sizes involved. Your failing one is 3.8kB:

Using cached https://www.piwheels.org/simple/pyasyncore/pyasyncore-1.0.3-py3-none-any.whl (3.8 kB)

Your successful one is 10120B (~10kB):

Created wheel for pyasyncore: filename=pyasyncore-1.0.3-py3-none-any.whl size=10120

And I get the same result:

Downloading pyasyncore-1.0.3-py3-none-any.whl (10 kB)

I've not seen piwheels.org as a source before, but it looks like they are rebuilding the wheel files themselves, even when the original is architecture-independent. My guess is that they are doing this on Python < 3.12, which means the asyncore package is not actually included (see the check in setup.py). When you build from source on Python >= 3.12, this check passes, so you get the intended result.

This check was to make absolutely sure there is no possiblity of affecting the system asyncore when building from source on versions of Python that already bundle it. But as the note in the file explains, it probably isn't required. It is also confusing in that it only affects building the package, not its actual usage.

Removing this would I suspect fix your issue. I'll think about whether there are any possible side-effects, but otherwise I think it's probably fine to do this. In the meantime, building from source is one option; another is to remove piwheels – the PyPI version should with without issue.

@erikmouw
Copy link
Author

I think we're on the right track here. There is a file /etc/pip.conf on my Pi which is owned by the python-pip-whl package. However, that package has long been removed, but its configuration file /etc/pip.conf was still there.

root@raspberrypi:~# dpkg -l python-pip-whl
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version          Architecture Description
+++-==============-================-============-=====================================
rc  python-pip-whl 20.3.4-4+deb11u1 all          Python package installer (pip wheels)
root@raspberrypi:~# dpkg --purge python-pip-whl
(Reading database ... 90152 files and directories currently installed.)
Purging configuration files for python-pip-whl (20.3.4-4+deb11u1) ...
root@raspberrypi:~# ls -l /etc/pip.conf
ls: cannot access '/etc/pip.conf': No such file or directory

Now it works like expected:

(venv) pi@raspberrypi:/scratch/tmp $ pip uninstall pyasyncore
Found existing installation: pyasyncore 1.0.3
Uninstalling pyasyncore-1.0.3:
  Would remove:
    /scratch/tmp/venv/lib/python3.12/site-packages/asyncore/*
    /scratch/tmp/venv/lib/python3.12/site-packages/pyasyncore-1.0.3.dist-info/*
Proceed (Y/n)? y
  Successfully uninstalled pyasyncore-1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ pip install pyasyncore
Collecting pyasyncore
  Downloading pyasyncore-1.0.3-py3-none-any.whl.metadata (3.4 kB)
Downloading pyasyncore-1.0.3-py3-none-any.whl (10 kB)
Installing collected packages: pyasyncore
Successfully installed pyasyncore-1.0.3
(venv) pi@raspberrypi:/scratch/tmp $ python
Python 3.12.2 (main, Feb 17 2024, 13:29:44) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncore
>>> asyncore.
asyncore.EAGAIN                 asyncore.EPIPE                  asyncore.errorcode              asyncore.readwrite(
etc.

This particular Pi has been through at least two Raspbian dist upgrades, the /etc/pip.conf configuration file was a remnant of an earlier OS version. Once the package was purged everything works as expected.

Thanks for your help!

@simonrob
Copy link
Owner

I've just released version 1.0.4, which includes this change. Thanks for the help!

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