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

sys.prefix should not be used to discover non-dev data directories? #1320

Closed
3 tasks done
nazarewk opened this issue Nov 20, 2023 · 4 comments
Closed
3 tasks done

sys.prefix should not be used to discover non-dev data directories? #1320

nazarewk opened this issue Nov 20, 2023 · 4 comments
Labels

Comments

@nazarewk
Copy link
Contributor

Environment

NixOS

Bug description

When packaging ulauncher for Nix (#1307) I noticed it tried to read web app files from within Python installation's directory so I patched it {sys.prefix} -> $out.

Today I started digging into issue and seems like this is a proper behavior according to Python docs:

A string giving the site-specific directory prefix where the platform independent Python files are installed; on Unix, the default is /usr/local. This can be set at build time with the --prefix argument to the configure script. See Installation paths for derived paths.

Note: If a virtual environment is in effect, this value will be changed in site.py to point to the virtual environment. The value for the Python installation will still be available, via base_prefix.

This means sys.prefix does what you want it to do only inside the virtualenv itself (in a development environment?) while:

  • ULAUNCHER_DATA_DIR is set up only for development (where it seems not to be needed)
  • yesterday's patch does it as a fallback when ULAUNCHER_DATA_DIR is missing, which has no chance of working

Log output

No response

Communication guidelines

  • I have read and agree with Ulauncher's communication guidelines and checked the troubleshooting page for self-help.

Not an extension issue

  • This issue applies to the Ulauncher application, not a specific extension.

Ulauncher v6

  • I have made sure the bug isn't already fixed in v6.
@nazarewk nazarewk added the bug label Nov 20, 2023
@friday
Copy link
Member

friday commented Nov 20, 2023

This means sys.prefix does what you want it to do only inside the virtualenv itself (in a development environment?)

No. This works perfectly (I'm running it right now and I wouldn't have pushed it if it didn't work). Tested both running from source and installed, Arch and Ubuntu.

How could this only work in a virtual environment when Ulauncher doesn't run in a virtual environment? The documentation says the Unix default is /usr/local for non-virtual environments, but for Arch and Ubuntu it's just /usr

image

It may be wrong to use sys.prefix here for Nix and/or other OSes though. Both me or the original maintainer have been learning how to handle these things as needed and by trial and error.

@nazarewk
Copy link
Contributor Author

nazarewk commented Nov 20, 2023

Makes sense. It assumes ulauncher is installed into that prefix which in itself also makes sense.

The more I think about it the more it seems to be something Nix-specific due to separation of the Python interpreter and per-application packages.

@nazarewk
Copy link
Contributor Author

Those 2 code pieces seem to be responsible:

@friday
Copy link
Member

friday commented Nov 20, 2023

Yeah, I think the assumptions we have works for traditional package managers where you can only have one version installed of each package. But seemingly not for Nix, and likely not for flatpak (which we should try to support at some point in time).

Maybe you can set the ULAUNCHER_DATA_DIR variable exteranally as a workaround? Or if you need something else, let me know.

nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 20, 2023
nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 21, 2023
nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 21, 2023
- adds explicit ULAUNCHER_DATA_DIR to solve Ulauncher#1320
- fix No module named 'gi' in extensions, related to Ulauncher#1306
nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 21, 2023
- adds explicit ULAUNCHER_DATA_DIR to solve Ulauncher#1320
- fix No module named 'gi' in extensions, related to Ulauncher#1306
nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 21, 2023
- adds explicit ULAUNCHER_DATA_DIR to solve Ulauncher#1320
- fix No module named 'gi' in extensions, related to Ulauncher#1306
nazarewk added a commit to nazarewk/Ulauncher that referenced this issue Nov 21, 2023
- adds explicit ULAUNCHER_DATA_DIR to solve Ulauncher#1320
- fix No module named 'gi' in extensions, related to Ulauncher#1306
friday pushed a commit that referenced this issue Nov 21, 2023
- adds explicit ULAUNCHER_DATA_DIR to solve #1320
- fix No module named 'gi' in extensions, related to #1306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants