-
-
Save kalbasit/fcba95f1fe574e2633fd03507c461dd7 to your computer and use it in GitHub Desktop.
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
{ lib, pythonPackages }: | |
with lib; | |
let | |
pkgs = { | |
area = { version = "1.1.1"; }; | |
dask = { version = "1.2.2"; }; | |
geojson = { version = "2.4.1"; }; | |
geopy = { version = "1.19.0"; }; | |
h3 = { version = "3.4.2"; }; | |
pandas = { version = "0.24.2"; }; | |
psycopg2 = { version = "2.7.6.1"; }; | |
pyarrow = { version = "0.12.0"; }; | |
pytz = { version = "2018.9"; }; | |
pyyaml = { version = "5.1"; }; | |
s3fs = { version = "0.2.2"; }; | |
scikitlearn = { version = "0.20.3"; }; | |
simple-salesforce = { version = "0.74.2"; }; | |
snowflake-sqlalchemy = { version = "1.1.4"; }; | |
sqlalchemy = { version = "1.3.3"; }; | |
timezonefinder = { version = "4.0.2"; }; | |
}; | |
/* Get the version of a package | |
Example: | |
getPackageVersion python37Packages area | |
=> "1.1.1" | |
*/ | |
getPackageVersion = pythonPackages: pythonPackage: (builtins.parseDrvName pythonPackages."${pythonPackage}".name).version; | |
/* Validate package versions | |
Example: | |
validatePackageVersion python37Packages "area" { version = "1.1.1"; } | |
=> true | |
*/ | |
validatePackageVersion = pythonPackages: pythonPackage: pkgDef: (getPackageVersion pythonPackages pythonPackage) == pkgDef.version; | |
/* Filter the valid packages out of the set | |
Example: | |
filterValidPackages python37Packages { area = { version = "1.1.1"; }; geopy = { version = "1.19.0"; }; } | |
=> { geopy = { version = "1.19.0"; }; } | |
*/ | |
filterValidPackages = pythonPackages: pkgs: filterAttrs (pythonPackage: pkgDef: !validatePackageVersion pythonPackages pythonPackage pkgDef) pkgs; | |
/* Generate error messages for every package in a set, and include the want/got versions | |
Example: | |
getErrorPackageVersions { geopy = { version = "1.19.0"; }; } | |
=> [ "Expected geopy at 1.19.0 got 1.20.0" ] | |
*/ | |
getErrorPackageVersions = invalidPackages: mapAttrsToList (pythonPackage: pkgDef: "Expected ${pythonPackage} at ${pkgDef.version} got ${getPackageVersion pythonPackages pythonPackage}") invalidPackages; | |
invalidPackages = filterValidPackages pythonPackages pkgs; | |
in | |
if invalidPackages == {} then (builtins.attrNames pkgs) | |
else throw (builtins.concatStringsSep "\n" (["Some packages did not match the expect version:"] ++ (getErrorPackageVersions invalidPackages))) |
Author
kalbasit
commented
Jul 21, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment