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

Using custom Python from nixpkgs-python results in an interpreter unable to find glibc (I think) #909

Closed
mcdonc opened this issue Dec 23, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@mcdonc
Copy link
Contributor

mcdonc commented Dec 23, 2023

  languages.python = {
    enable = true;
    version = "3.11.6";
    venv = {
      enable = true;
    };
  };
inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixos-23.11
  nixpkgs-python:
    url: github:cachix/nixpkgs-python
  devenv:
    url: github:mcdonc/devenv/python-rewrite

allowUnfree: true

(this only works if you use the nixpkgs-python cachix cache or turn off sandboxing, see #901)

devenv shell
Building shell ...
trace: warning: For cachix.push and cachix.pull attributes to have an effect,
upgrade to devenv 1.0 or later.

Entering shell ...

Python interpreter changed, rebuilding Python venv...
/nix/store/m29jrr9cy9wg9kgy7k1dyr0gc44a5r43-python3-3.11.6-env/bin/python3.11 -m venv --upgrade-deps /home/chrism/projects/apex/eao_dash/.devenv/state/venv
/nix/store/3w7xj32jhxqhkvn66x67vql9lzmbffyw-python3-3.11.6/bin/python3.11: error while loading shared libraries: __vdso_gettimeofday: invalid mode for dlopen(): Invalid argument
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/.devenv_interpreter: No such file or directory
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/bin/activate: No such file or directory
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/bin/pip: No such file or directory
✨ devenv 0.6.3 is out of date. Please update to 1.0: https://devenv.sh/getting-started/#installation
(devenv) 
[chrism@thinknix512:~/projects/apex/eao_dash]$ /nix/store/m29jrr9cy9wg9kgy7k1dyr0gc44a5r43-python3-3.11.6-env/bin/python3.11
/nix/store/3w7xj32jhxqhkvn66x67vql9lzmbffyw-python3-3.11.6/bin/python3.11: error while loading shared libraries: __vdso_gettimeofday: invalid mode for dlopen(): Invalid argument
(devenv) 
@mcdonc mcdonc added the bug Something isn't working label Dec 23, 2023
@mcdonc
Copy link
Contributor Author

mcdonc commented Dec 31, 2023

Note that working with nixpkgs-python directly works fine:

❯ nix build '.#"3.11.6"'
❯ ./result/bin/python -c "pass"

So it likely has something to do with LD_LIBRARY_PATH or possibly the Python binary wrappers.

@mcdonc
Copy link
Contributor Author

mcdonc commented Dec 31, 2023

It's the Python binary wrappers:

❯ devenv shell
Building shell ...
trace: warning: For cachix.push and cachix.pull attributes to have an effect,
upgrade to devenv 1.0 or later.

Entering shell ...

Python interpreter changed, rebuilding Python venv...
/nix/store/m29jrr9cy9wg9kgy7k1dyr0gc44a5r43-python3-3.11.6-env/bin/python3.11 -m venv --upgrade-deps /home/chrism/projects/apex/eao_dash/.devenv/state/venv
/nix/store/3w7xj32jhxqhkvn66x67vql9lzmbffyw-python3-3.11.6/bin/python3.11: error while loading shared libraries: __vdso_gettimeofday: invalid mode for dlopen(): Invalid argument
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/.devenv_interpreter: No such file or directory
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/bin/activate: No such file or directory
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/.devenv_requirements: No such file or directory
Requirements changed, running pip install -r /nix/store/2cjacq6j9ms8f588fy4395h3d246gadk-requirements.txt...
bash: /home/chrism/projects/apex/eao_dash/.devenv/state/venv/bin/pip: No such file or directory
✨ devenv 0.6.3 is out of date. Please update to 1.0: https://devenv.sh/getting-started/#installation
(devenv) 
[chrism@thinknix512:~/projects/apex/eao_dash]$ /nix/store/m29jrr9cy9wg9kgy7k1dyr0gc44a5r43-python3-3.11.6-env/bin/python3.11
/nix/store/3w7xj32jhxqhkvn66x67vql9lzmbffyw-python3-3.11.6/bin/python3.11: error while loading shared libraries: __vdso_gettimeofday: invalid mode for dlopen(): Invalid argument
(devenv) 
[chrism@thinknix512:~/projects/apex/eao_dash]$ 
(devenv) 
[chrism@thinknix512:~/projects/apex/eao_dash]$ /nix/store/3w7xj32jhxqhkvn66x67vql9lzmbffyw-python3-3.11.6/bin/python3.11
Python 3.11.6 (main, Oct  2 2023, 13:45:54) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
(devenv) 
[chrism@thinknix512:~/projects/apex/eao_dash]$ 

@mcdonc
Copy link
Contributor Author

mcdonc commented Jan 2, 2024

Disabling the inclusion of pkgs.pythonManylinuxPackages.manylinux2014Package in the definition of libraries allows the wrapper to work.

I suspect that putting manylinux on the LD_LIBRARY_PATH is the major rationale for the wrapper because libraries just kinda work anyway, but I'm not sure how it would work? nixpkgs-python is going to produce things that link to some glibc, and the manylinux wrapper is going to put another glibc on the LD_LIBRARY_PATH that will be found first.

I'm going to try to hit up @domenkozar in the devenv element room sometime this week so I can understand how this might be meant to work.

@mcdonc
Copy link
Contributor Author

mcdonc commented Jan 4, 2024

Until this is fixed, adding this to your devenv.nix:

languages.python.manylinux.enable = false;

Will work around it.

@mcdonc
Copy link
Contributor Author

mcdonc commented Jan 5, 2024

Irritating. Although numpy installs as a "manylinux" wheel, it actually has a dependency on a non-manylinux library (zlib):

[chrism@optinix:~/projects/devenv/tmp/.devenv/state/venv/lib/python3.11/site-packages/numpy]$ find . -name "*.so"|xargs ldd|grep "not found"
	libz.so.1 => not found
	libz.so.1 => not found
	libz.so.1 => not found

@mcdonc
Copy link
Contributor Author

mcdonc commented Jan 5, 2024

Note that doing some shenanigans to synchronize nixpkg-python's nixpkgs input to the nixpkgs input produces a working wrapper (it can create the venv):

inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixos-23.11
  nixpkgs-python:
    url: github:cachix/nixpkgs-python
    inputs:
      nixpkgs:
        follows: nixpkgs

However, this causes at least one bizarre behavior when trying to use various Python 3.11 packages. In one case, trying to use the nixpkgs version of concurrent.futures tells me I have a Python compiled without semaphore support when I try to use version: 3.11.6 in the devenv config.

@mcdonc
Copy link
Contributor Author

mcdonc commented Jan 10, 2024

#920 will fix this issue.

@domenkozar
Copy link
Member

#920 is merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants