summary refs log tree commit diff
path: root/doc/languages-frameworks/python.md
diff options
context:
space:
mode:
authorAzul <mail@azulinho.com>2017-01-12 16:00:50 +0000
committerAzul <mail@azulinho.com>2017-01-12 16:00:50 +0000
commitaa9a9dd1b42f8e17f625a3d6c5466753b19a4428 (patch)
tree99df07b92fbcaacec1fbf38c856f832dacae678c /doc/languages-frameworks/python.md
parent45a677b978bd9b1d648a9b455b482dff514f24fb (diff)
downloadnixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar.gz
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar.bz2
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar.lz
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar.xz
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.tar.zst
nixpkgs-aa9a9dd1b42f8e17f625a3d6c5466753b19a4428.zip
python docs: add an example for a virtualenv and pip through nix-shell
Diffstat (limited to 'doc/languages-frameworks/python.md')
-rw-r--r--doc/languages-frameworks/python.md37
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/languages-frameworks/python.md b/doc/languages-frameworks/python.md
index 82aeb112c93..7fd26c88e38 100644
--- a/doc/languages-frameworks/python.md
+++ b/doc/languages-frameworks/python.md
@@ -804,6 +804,43 @@ If you want to create a Python environment for development, then the recommended
 method is to use `nix-shell`, either with or without the `python.buildEnv`
 function.
 
+### How to consume python modules using pip in a virtualenv like I am used to on other Operating Systems ?
+
+This is an example of a `default.nix` for a `nix-shell`, which allows to consume a `virtualenv` environment,
+and install python modules through `pip` the traditional way.
+
+Create this `default.nix` file, together with a `requirements.txt` and simply execute `nix-shell`.
+
+```
+
+th import <nixpkgs> {};
+with pkgs.python27Packages;
+
+buildPythonPackage { 
+  name = "impurePythonEnv";
+  buildInputs = [
+    taglib
+    openssl
+    git
+    libxml2
+    libxslt
+    libzip
+    python27Full
+    python27Packages.virtualenv
+    python27Packages.pip
+    stdenv
+    zlib ];
+  src = null;
+  # When used as `nix-shell --pure`
+  shellHook = ''
+  unset http_proxy
+  export GIT_SSL_CAINFO=/etc/ssl/certs/ca-bundle.crt
+  virtualenv --no-wheel --no-setuptools venv 
+  export PATH=$PWD/venv/bin:$PATH
+  pip install -r requirements.txt --no-use-wheel
+  '';
+}
+```
 
 ## Contributing