manual: specify interpreter in virtualenv shell

Without this virtualenv might try to setup an environment for a
different version of python then the one specified in the expression.
This commit is contained in:
Daiderd Jordan 2019-12-17 15:26:06 +01:00
parent a5e98ed7cf
commit 0159151705
No known key found for this signature in database
GPG Key ID: D02435D05B810C96

View File

@ -1034,7 +1034,10 @@ Create this `default.nix` file, together with a `requirements.txt` and simply ex
```nix ```nix
with import <nixpkgs> {}; with import <nixpkgs> {};
with python27Packages;
let
pythonPackages = python27Packages;
in
stdenv.mkDerivation { stdenv.mkDerivation {
name = "impurePythonEnv"; name = "impurePythonEnv";
@ -1044,9 +1047,8 @@ stdenv.mkDerivation {
buildInputs = [ buildInputs = [
# these packages are required for virtualenv and pip to work: # these packages are required for virtualenv and pip to work:
# #
python27Full pythonPackages.virtualenv
python27Packages.virtualenv pythonPackages.pip
python27Packages.pip
# the following packages are related to the dependencies of your python # the following packages are related to the dependencies of your python
# project. # project.
# In this particular example the python modules listed in the # In this particular example the python modules listed in the
@ -1059,14 +1061,13 @@ stdenv.mkDerivation {
libxml2 libxml2
libxslt libxslt
libzip libzip
stdenv
zlib zlib
]; ];
shellHook = '' shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels # set SOURCE_DATE_EPOCH so that we can use python wheels
SOURCE_DATE_EPOCH=$(date +%s) SOURCE_DATE_EPOCH=$(date +%s)
virtualenv --no-setuptools venv virtualenv --python=${pythonPackages.python.interpreter} --no-setuptools venv
export PATH=$PWD/venv/bin:$PATH export PATH=$PWD/venv/bin:$PATH
pip install -r requirements.txt pip install -r requirements.txt
''; '';