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

python doc: update virtualenv section #55265

Closed
wants to merge 1 commit into from

Conversation

danbst
Copy link
Contributor

@danbst danbst commented Feb 5, 2019

  • make it easy to switch python 2/3
  • add glibcLocales dep (not sure it is still required after glibc: C.UTF-8 locales #54485
    but manual is also used by users of Nixpkgs versions <19.03)
  • use mkShell
  • use libffi, as it is required for Python3 cryptography (in my setup it worked with Python2 without this dep)
  • set PYTHONPATH. Either this or source venv/bin/activate was missing.

Closes #46909

cc @FRidh @MelleB

- make it easy to switch python 2/3
- add glibcLocales dep (not sure it is still required after NixOS#54485
  but manual is also used by users of Nixpkgs versions <19.03)
- use `mkShell`
- use `libffi`, as it is required for Python3 `cryptography` (in my setup it worked with Python2 without this dep)
- set PYTHONPATH. Either this or `source venv/bin/activate` was missing.

Closes NixOS#46909
@FRidh
Copy link
Member

FRidh commented Feb 5, 2019

Considering this example is not a supported workflow it should never have been part of the manual.

@danbst
Copy link
Contributor Author

danbst commented Feb 5, 2019

@FRidh mmm, what are the problems here? I do advocate exactly this (wiki section https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix-shell), and do use exactly this at company (I'm forced to, because I use NixOS).

But in case this isn't supported by you, then it's fine. I'll merge it before branchoff if there are no other objections.

@danbst
Copy link
Contributor Author

danbst commented Feb 10, 2019

@FRidh I've found your concerns at #21837 (review)

Now I understand that even if this example can work for some (me included), it is not easy to make it work in general case.

@Mic92
Copy link
Member

Mic92 commented Feb 10, 2019

It wouldn't be necessary after #54485 however for nixpkgs itself we also need support on macOS, which is also possible to add, but I currently have not the OS to implement it and test it. If you are only up to support linux, then you can already use it.

@Mic92
Copy link
Member

Mic92 commented Feb 10, 2019

I think it is OK to have it in the manual, if we mention the limitations of it,
i.e. mention the problems with GC. It is also possible to use some packages from the nix store (numpy, pyqt) if one using --system-site-packages. The GC problem can be also worked around by using a persistent GC root https://github.com/direnv/direnv/wiki/Nix#persistent-shell

I even think we still need this option because using nixpkgs python package sets limits one to the versions given by nixpkgs. These are likely to be not compatible with whatever a different project is working on. Also we https://github.com/garbas/pypi2nix it forces one to create your own list of overrides for every package
that needs manual intervention, which can become painful for more complex projects (also it would try to rebuild it everytime from the start after an error).
Also the nix workflow does not allow you to have editable dependencies, which are sometimes necessary if you want to fix stuff in other packages or just add a breakpoint to the source code.

@danbst
Copy link
Contributor Author

danbst commented Aug 18, 2019

Closing this, as virtualenv isn't officially supported for Nixpkgs. But still referenced this PR from https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix-shell

@danbst danbst closed this Aug 18, 2019
@pmyjavec
Copy link

@danbst ,

Sorry to resurrect an old PR, but I love this! Thank you.

@Pablo1107
Copy link
Contributor

Another sorry for resurrecting this PR, but the example giving in the wiki is (maybe?) wrong?

Shouldn't in pkgs.stdenv.mkShell { be in pkgs.mkShell {?

@Mic92
Copy link
Member

Mic92 commented May 27, 2020

Another sorry for resurrecting this PR, but the example giving in the wiki is (maybe?) wrong?

Shouldn't in pkgs.stdenv.mkShell { be in pkgs.mkShell {?

yes. The wiki allows logins via github, if you want to fix it.

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

Successfully merging this pull request may close these issues.

None yet

6 participants