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

Cannot run CLI aestream after installing aestream via pip to user home #112

Open
holesond opened this issue Jun 19, 2024 · 2 comments
Open

Comments

@holesond
Copy link

OS and Python version: Ubuntu 22.04, Python 3.10.12

Reproduce the issue by running the following without root privileges:

pip install aestream

or

pip install --user aestream

Then running aestream fails with:

user@computer:~$ aestream
Traceback (most recent call last):
  File "/home/user/.local/bin/aestream", line 8, in <module>
    os.execv(
FileNotFoundError: [Errno 2] No such file or directory

Currently, the code of aestream (in /home/user/.local/bin/aestream) is:

#!/usr/bin/python3
import os
import sys
import sysconfig


if __name__ == "__main__":
    os.execv(
        os.path.join(sysconfig.get_path("platlib"), 'aestream.scripts/aestream'),
        sys.argv,
    )

sysconfig.get_path("platlib") returns '/usr/local/lib/python3.10/dist-packages'. However, pip installed the aestream package to '/home/user/.local/lib/python3.10/site-packages'.

I have fixed the issue in my AEStream installation by trying all the possible dist-packages and site-packages paths in the aestream code as follows:

#!/usr/bin/python3
import os
import sys
import site
import sysconfig


if __name__ == "__main__":
    packages_paths = [site.getusersitepackages()]
    packages_paths.append(sysconfig.get_path("platlib"))
    packages_paths.extend(site.getsitepackages())
    aestream_paths = [
        os.path.join(packages, 'aestream.scripts/aestream')
        for packages in packages_paths]
    succeeded = False
    for path in aestream_paths:
        try:
            os.execv(path, sys.argv)
            succeeded = True
            break
        except FileNotFoundError:
            pass
    if not succeeded:
        raise RuntimeError(
            f"I have not found the aestream executable among the paths: "
            f"{aestream_paths}")

These are all the possible paths on my system:

>>> import sysconfig
>>> sysconfig.get_path("platlib")
'/usr/local/lib/python3.10/dist-packages'
>>> import site; site.getsitepackages()
['/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.10/dist-packages']
>>> site.getusersitepackages()
'/home/user/.local/lib/python3.10/site-packages'
@Jegp
Copy link
Contributor

Jegp commented Jun 21, 2024

Thank you so much for your elaborate error report.

I reproduced the behavior in a Docker container, and it's clear that the platlib environmental variable is wrong. The correct fix to this, IMO, would be to update the script to also search in .local, pretty much what you're suggesting.

That script comes from somewhere upstream. AEStream uses scikit-build-core to build the distribution and cibuildwheels to build the wheels, but it's honestly a little unclear to me exactly where in the (huge) build stack the script is being generated. I wrote the pypa community on their discord and will follow up on this. If you have any input/ideas I'm all ears! 👂

@henryiii
Copy link

I linked to the issue in auditwheel. A better variation on this fix would be to check other schemes; this one is sysconfig.get_path("posix_user", "platlib").

The core problem is the executable links to other things in platlib, which is invalid; you should swap it for a console entry point wrapping the executable (which is then placed in platlib so relative paths work), or statically link so that it doesn't depend on platlib. auditwheel is trying to fix this for you, and is applying a fix that ignores user platlib.

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

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy