mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
python docs: update block according to code review
This commit is contained in:
parent
aa9a9dd1b4
commit
58613a7eed
|
@ -812,36 +812,48 @@ and install python modules through `pip` the traditional way.
|
||||||
Create this `default.nix` file, together with a `requirements.txt` and simply execute `nix-shell`.
|
Create this `default.nix` file, together with a `requirements.txt` and simply execute `nix-shell`.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
with import <nixpkgs> {};
|
||||||
th import <nixpkgs> {};
|
|
||||||
with pkgs.python27Packages;
|
with pkgs.python27Packages;
|
||||||
|
|
||||||
buildPythonPackage {
|
stdenv.mkDerivation {
|
||||||
name = "impurePythonEnv";
|
name = "impurePythonEnv";
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
# these packages are required for virtualenv and pip to work:
|
||||||
|
#
|
||||||
|
python27Full
|
||||||
|
python27Packages.virtualenv
|
||||||
|
python27Packages.pip
|
||||||
|
# the following packages are related to the dependencies of your python
|
||||||
|
# project.
|
||||||
|
# In this particular example the python modules listed in the
|
||||||
|
# requirements.tx require the following packages to be installed locally
|
||||||
|
# in order to compile any binary extensions they may require.
|
||||||
|
#
|
||||||
taglib
|
taglib
|
||||||
openssl
|
openssl
|
||||||
git
|
git
|
||||||
libxml2
|
libxml2
|
||||||
libxslt
|
libxslt
|
||||||
libzip
|
libzip
|
||||||
python27Full
|
|
||||||
python27Packages.virtualenv
|
|
||||||
python27Packages.pip
|
|
||||||
stdenv
|
stdenv
|
||||||
zlib ];
|
zlib ];
|
||||||
src = null;
|
src = null;
|
||||||
# When used as `nix-shell --pure`
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
unset http_proxy
|
# set SOURCE_DATE_EPOCH so that we can use python wheels
|
||||||
export GIT_SSL_CAINFO=/etc/ssl/certs/ca-bundle.crt
|
SOURCE_DATE_EPOCH=$(date +%s)
|
||||||
virtualenv --no-wheel --no-setuptools venv
|
virtualenv --no-setuptools venv
|
||||||
export PATH=$PWD/venv/bin:$PATH
|
export PATH=$PWD/venv/bin:$PATH
|
||||||
pip install -r requirements.txt --no-use-wheel
|
pip install -r requirements.txt
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that the `pip install` is an imperative action. So every time `nix-shell`
|
||||||
|
is executed it will attempt to download the python modules listed in
|
||||||
|
requirements.txt. However these will be cached locally within the `virtualenv`
|
||||||
|
folder and not downloaded again.
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
### Contributing guidelines
|
### Contributing guidelines
|
||||||
|
|
Loading…
Reference in a new issue