-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using nix to create the venv and make hermetic dependencies
- Loading branch information
Showing
2 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
let | ||
nixpkgs-src = builtins.fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/tarball/nixos-22.11"; | ||
}; | ||
|
||
pkgs = import nixpkgs-src { | ||
config = { | ||
allowUnfree = true; | ||
}; | ||
}; | ||
|
||
# This is the Python version that will be used. | ||
myPython = pkgs.python310; | ||
|
||
pythonWithPkgs = myPython.withPackages (pythonPkgs: with pythonPkgs; [ | ||
pip | ||
setuptools | ||
wheel | ||
]); | ||
|
||
lib-path = with pkgs; lib.makeLibraryPath [ | ||
libffi | ||
openssl | ||
]; | ||
|
||
shell = pkgs.mkShell { | ||
buildInputs = [ | ||
# my python and packages | ||
pythonWithPkgs | ||
pkgs.memcached | ||
|
||
# other packages needed for compiling python libs | ||
pkgs.readline | ||
pkgs.libffi | ||
pkgs.openssl | ||
]; | ||
|
||
shellHook = '' | ||
# Allow the use of wheels. | ||
SOURCE_DATE_EPOCH=$(date +%s) | ||
# Augment the dynamic linker path | ||
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}" | ||
# Setup the virtual environment if it doesn't already exist. | ||
if test ! -d .venv; then | ||
python -m venv .venv | ||
fi | ||
.venv/bin/pip install -U -r requirements.txt | ||
source .venv/bin/activate | ||
export PYTHONPATH=`pwd`.venv/${myPython.sitePackages}/:$PYTHONPATH | ||
''; | ||
}; | ||
in | ||
|
||
shell |