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

Bad virtualenv patch breaking pipenv on Python 3.7.2 #57008

Closed
matthew-piziak opened this issue Mar 7, 2019 · 1 comment
Closed

Bad virtualenv patch breaking pipenv on Python 3.7.2 #57008

matthew-piziak opened this issue Mar 7, 2019 · 1 comment

Comments

@matthew-piziak
Copy link
Contributor

Issue description

Any pipenv command results in this:

Using base prefix '/nix/store/p6x8n1v3axgd48s8il2q97w6408bf67x-python3-3.7.2-env'
Traceback (most recent call last):
  File "/nix/store/clwdqf1zrhv3gcbrrca2cklrs0xkpj26-python3.7-virtualenv-16.4.1/bin/.virtualenv-wrapped", line 11, in <module>
    sys.exit(main())
  File "/nix/store/p6x8n1v3axgd48s8il2q97w6408bf67x-python3-3.7.2-env/lib/python3.7/site-packages/virtualenv.py", line 810, in main
    symlink=options.symlink,
  File "/nix/store/p6x8n1v3axgd48s8il2q97w6408bf67x-python3-3.7.2-env/lib/python3.7/site-packages/virtualenv.py", line 1088, in create_environment
    install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
  File "/nix/store/p6x8n1v3axgd48s8il2q97w6408bf67x-python3-3.7.2-env/lib/python3.7/site-packages/virtualenv.py", line 1385, in install_python
    wrapper_path = join(prefix, "lib", py_version, "site-packages")
NameError: name 'py_version' is not defined

...which, I mean, yeah, it's not available as far as I can tell, but I think it's a bug resulting from an outdated patch here: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch

I hard-coded py_version in that file to the version that I needed, and now I can use pipenv again.

Steps to reproduce

On unstable, install pipenv and try to run pipenv install in an empty directory.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.17.19, NixOS, 18.03.133402.cb0e20d6db9 (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0.4
  • channels(root): "nixpkgs-18.03.133402.cb0e20d6db9, unstable-19.09pre171786.34aa254f9eb"
  • channels(matt): "unstable"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs
@rht
Copy link
Member

rht commented Mar 12, 2019

My current workaround for patching configuration.nix (this is probably more verbose than it should be)

nixpkgs.config.packageOverrides = pkgs : rec {
      python37Packages = pkgs.python37Packages.override (oldAttrs: {
        overrides = self: super: {
          virtualenv = super.virtualenv.overrideAttrs ( z : rec {
            postPatch = ''
              substituteInPlace virtualenv.py --replace "py_version" "PY_VERSION"
            '';
          });
        };
      });

This uncovers more error after creating the virtualenv symlinks: Nvm, it works. I had to do more cleanup in addition to find $VENVPATH -type l delete before refreshing the venv.

Fatal Python error: initfsencoding: Unable to get the locale encoding
LookupError: no codec search functions registered: can't find encoding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants