@ -31,10 +31,9 @@ let
callPackage = pkgs . newScope self ;
bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { } ;
namePrefix = python . libPrefix + " - " ;
mkPythonDerivation = makeOverridable ( callPackage ../development/interpreters/python/mk-python-derivation.nix {
} ) ;
bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { } ;
# Derivations built with `buildPythonPackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overridePythonAttrs` and it overrides the call to `buildPythonPackage`.
@ -52,13 +51,20 @@ let
}
else ff ;
buildPythonPackage = makeOverridablePythonPackage ( callPackage ../development/interpreters/python/build-python-package.nix {
inherit mkPythonDerivation ;
buildPythonPackage = makeOverridablePythonPackage ( makeOverridable ( callPackage ../development/interpreters/python/build-python-package.nix {
inherit bootstrapped-pip ;
flit = self . flit ;
} ) ;
# We want Python libraries to be named like e.g. "python3.6-${name}"
inherit namePrefix ;
pythonModule = python ;
} ) ) ;
buildPythonApplication = args : buildPythonPackage ( { namePrefix = " " ; } // args ) ;
buildPythonApplication = makeOverridablePythonPackage ( makeOverridable ( callPackage ../development/interpreters/python/build-python-package.nix {
inherit bootstrapped-pip ;
flit = self . flit ;
namePrefix = " " ;
pythonModule = false ;
} ) ) ;
graphiteVersion = " 1 . 0 . 2 " ;
@ -80,10 +86,40 @@ let
else throw " U n s u p p o r t e d k i n d ${ kind } " ) ;
in fetcher ( builtins . removeAttrs attrs [ " f o r m a t " ] ) ) ;
# Check whether a derivation provides a Python module.
hasPythonModule = drv : ( hasAttr " p y t h o n M o d u l e " drv ) && ( ( getAttr " p y t h o n M o d u l e " drv ) == python ) ;
# Get list of required Python modules given a list of derivations.
requiredPythonModules = drvs : let
filterNull = list : filter ( x : ! isNull x ) list ;
conditionalGetRecurse = attr : condition : drv : let f = conditionalGetRecurse attr condition ; in
( if ( condition drv ) then unique [ drv ] ++ ( concatMap f ( filterNull ( getAttr attr drv ) ) ) else [ ] ) ;
_required = drv : conditionalGetRecurse " p r o p a g a t e d B u i l d I n p u t s " hasPythonModule drv ;
in [ python ] ++ ( unique ( concatMap _required ( filterNull drvs ) ) ) ;
# Create a PYTHONPATH from a list of derivations. This function recurses into the items to find derivations
# providing Python modules.
makePythonPath = drvs : stdenv . lib . makeSearchPath python . sitePackages ( requiredPythonModules drvs ) ;
# Convert derivation to a Python module.
toPythonModule = drv :
drv . overrideAttrs ( oldAttrs : {
# Use passthru in order to prevent rebuilds when possible.
passthru = ( oldAttrs . passthru or { } ) // {
name = namePrefix + oldAttrs . name ;
pythonModule = python ;
pythonPath = [ ] ; # Deprecated, for compatibility.
} ;
} ) ;
disabledIf = x : drv :
if x then throw " ${ removePrefix namePrefix ( drv . pname or drv . name ) } n o t s u p p o r t e d f o r i n t e r p r e t e r ${ python . executable } " else drv ;
in {
inherit python bootstrapped-pip pythonAtLeast pythonOlder isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k mkPythonDerivation buildPythonPackage buildPythonApplication ;
inherit python bootstrapped-pip pythonAtLeast pythonOlder isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k buildPythonPackage buildPythonApplication ;
inherit fetchPypi callPackage ;
inherit hasPythonModule requiredPythonModules makePythonPath disabledIf ;
# helpers