Skip to content

Instantly share code, notes, and snippets.

@kiloreux
Created October 17, 2018 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiloreux/c78a5964b32cf3632306e496a551b004 to your computer and use it in GitHub Desktop.
Save kiloreux/c78a5964b32cf3632306e496a551b004 to your computer and use it in GitHub Desktop.
# generated using pypi2nix tool (version: 1.8.1)
# See more at: https://github.com/garbas/pypi2nix
#
# COMMAND:
# pypi2nix -V 2.7 -s numpy -r requirements.txt -E mysql55 -E gfortran -E blas -E pkgconfig -E freetype.dev -E libpng -E agg -E libressl
#
let
overlay = self: super: {
opencv3 = super.opencv3.overrideAttrs (oa: rec {
version = "3.4.3";
name = "opencv-${version}";
src = self.fetchFromGitHub {
owner = "opencv";
repo = "opencv";
rev = version;
sha256 = "138q3wiv4g4xvqzsp93xaqayv7kz7bl2vrgppp8jm8w6m25cd4i2";
};
});
};
in
{ pkgs ? import <nixpkgs> {overlays = [ overlay ];}
}:
let
inherit (pkgs) makeWrapper stdenv glibcLocales;
inherit (pkgs.stdenv.lib) fix' extends inNixShell;
pythonPackages =
import "${toString pkgs.path}/pkgs/top-level/python-packages.nix" {
inherit pkgs;
inherit (pkgs) stdenv;
python = pkgs.python27Full;
# patching pip so it does not try to remove files when running nix-shell
overrides =
self: super: {
bootstrapped-pip = super.bootstrapped-pip.overrideDerivation (old: {
patchPhase = old.patchPhase + ''
if [ -e $out/${pkgs.python27Full.sitePackages}/pip/req/req_install.py ]; then
sed -i \
-e "s|paths_to_remove.remove(auto_confirm)|#paths_to_remove.remove(auto_confirm)|" \
-e "s|self.uninstalled = paths_to_remove|#self.uninstalled = paths_to_remove|" \
$out/${pkgs.python27Full.sitePackages}/pip/req/req_install.py
fi
'';
});
};
};
commonBuildInputs = with pkgs; [ mysql55 gfortran blas pkgconfig freetype.dev libpng agg libressl ];
commonDoCheck = false;
withPackages = pkgs':
let
pkgs = builtins.removeAttrs pkgs' ["__unfix__"];
interpreterWithPackages = selectPkgsFn: pythonPackages.buildPythonPackage {
name = "python27Full-interpreter";
buildInputs = [ makeWrapper ] ++ (selectPkgsFn pkgs);
buildCommand = ''
mkdir -p $out/bin
mkdir -p $out/share
ln -s ${pythonPackages.python.interpreter} \
$out/bin/${pythonPackages.python.executable}
for dep in ${builtins.concatStringsSep " "
(selectPkgsFn pkgs)}; do
if [ -d "$dep/bin" ]; then
for prog in "$dep/bin/"*; do
if [ -x "$prog" ] && [ -f "$prog" ]; then
ln -s $prog $out/bin/`basename $prog`
fi
done
fi
if [ -d "$dep/share" ]; then
for dir in "$dep/share/"*; do
base=$(basename $dir)
if [ -d "$dir" ] && [ $base = "OpenCV" ]; then
ln -s $dir $out/share/`basename $dir`
fi
done
fi
done
for prog in "$out/bin/"*; do
wrapProgram "$prog" --prefix PYTHONPATH : "$PYTHONPATH" --set LC_CTYPE en_US.UTF-8 --set LC_ALL en_US.UTF-8 --set LANG en_US.UTF-8
done
pushd $out/bin
ln -s ${pythonPackages.python.executable} python
ln -s ${pythonPackages.python.executable} \
python2
popd
'';
passthru.interpreter = pythonPackages.python;
};
interpreter = interpreterWithPackages builtins.attrValues;
in {
__old = pythonPackages;
inherit interpreter;
inherit interpreterWithPackages;
mkDerivation = pythonPackages.buildPythonPackage;
packages = pkgs;
overrideDerivation = drv: f:
pythonPackages.buildPythonPackage (
drv.drvAttrs // f drv.drvAttrs // { meta = drv.meta; }
);
withPackages = pkgs'':
withPackages (pkgs // pkgs'');
};
python = withPackages {};
generated = self: {
"LinkChecker" = python.mkDerivation {
name = "LinkChecker-9.2";
src = pkgs.fetchurl { url = "https://files.pythonhosted.org/packages/a9/b3/33de0997bd24c6551a5f13182dbc2b59774cf98c78dcffad37a6f8d57a65/LinkChecker-9.2.tar.gz"; sha256 = "ba556cd1c172c2cbcb92fc3405d48f44fa56c3074ed3b7ead87f635ad54fb907"; };
doCheck = commonDoCheck;
checkPhase = "";
installCheckPhase = "";
buildInputs = commonBuildInputs;
propagatedBuildInputs = [
self."requests"
];
meta = with pkgs.stdenv.lib; {
homepage = "http://wummel.github.io/linkchecker/";
license = licenses.gpl1;
description = "check links in web documents or full websites";
};
};
"PyYAML" = python.mkDerivation {
name = "PyYAML-3.12";
src = pkgs.fetchurl { url = "https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz"; sha256 = "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab"; };
doCheck = commonDoCheck;
checkPhase = "";
installCheckPhase = "";
buildInputs = commonBuildInputs;
propagatedBuildInputs = [ ];
meta = with pkgs.stdenv.lib; {
homepage = "http://pyyaml.org/wiki/PyYAML";
license = licenses.mit;
description = "YAML parser and emitter for Python";
};
};
};
localOverridesFile = ./requirements_override.nix;
overrides = import localOverridesFile { inherit pkgs python; };
commonOverrides = [
];
allOverrides =
(if (builtins.pathExists localOverridesFile)
then [overrides] else [] ) ++ commonOverrides;
in python.withPackages
(fix' (pkgs.lib.fold
extends
generated
allOverrides
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment