pep508
lib.pep508.parseMarkers
Type: parseMarkers :: string -> AttrSet
Parse PEP 508 markers into an AST.
::: {.example #function-library-example-lib.pep508.parseMarkers}
lib.pep508.parseMarkers
usage example
# parseMarkers "(os_name=='a' or os_name=='b') and os_name=='c'"
{
lhs = {
lhs = {
lhs = {
type = "variable";
value = "os_name";
};
op = "==";
rhs = {
type = "string";
value = "a";
};
type = "compare";
};
op = "or";
rhs = {
lhs = {
type = "variable";
value = "os_name";
};
op = "==";
rhs = {
type = "string";
value = "b";
};
type = "compare";
};
type = "boolOp";
};
op = "and";
rhs = {
lhs = {
type = "variable";
value = "os_name";
};
op = "==";
rhs = {
type = "string";
value = "c";
};
type = "compare";
};
type = "boolOp";
}
:::
lib.pep508.parseString
Type: parseString :: string -> AttrSet
Parse a PEP-508 dependency string.
input
: Function argument
::: {.example #function-library-example-lib.pep508.parseString}
lib.pep508.parseString
usage example
# parseString "cachecontrol[filecache]>=0.13.0"
{
conditions = [
{
op = ">=";
version = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ 0 13 0 ];
};
}
];
markers = null;
name = "cachecontrol";
extras = [ "filecache" ];
url = null;
}
:::
lib.pep508.mkEnviron
Type: mkEnviron :: derivation -> AttrSet
Create an attrset of platform variables. As described in https://peps.python.org/pep-0508/#environment-markers.
python
: Function argument
::: {.example #function-library-example-lib.pep508.mkEnviron}
lib.pep508.mkEnviron
usage example
# mkEnviron pkgs.python3
{
implementation_name = {
type = "string";
value = "cpython";
};
implementation_version = {
type = "version";
value = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ 3 10 12 ];
};
};
os_name = {
type = "string";
value = "posix";
};
platform_machine = {
type = "string";
value = "x86_64";
};
platform_python_implementation = {
type = "string";
value = "CPython";
};
# platform_release maps to platform.release() which returns
# the running kernel version on Linux.
# Because this field is not reproducible it's left empty.
platform_release = {
type = "string";
value = "";
};
platform_system = {
type = "string";
value = "Linux";
};
# platform_version maps to platform.version() which also returns
# the running kernel version on Linux.
# Because this field is not reproducible it's left empty.
platform_version = {
type = "version";
value = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ ];
};
};
python_full_version = {
type = "version";
value = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ 3 10 12 ];
};
};
python_version = {
type = "version";
value = {
dev = null;
epoch = 0;
local = null;
post = null;
pre = null;
release = [ 3 10 ];
};
};
sys_platform = {
type = "string";
value = "linux";
};
}
:::
lib.pep508.setEnviron
Update one or more keys in an environment created by mkEnviron.
environ
: Function argument
updates
: Function argument
::: {.example #function-library-example-lib.pep508.setEnviron}
lib.pep508.setEnviron
usage example
# setEnviron (mkEnviron pkgs.python3) { platform_release = "5.10.65"; }
:::
lib.pep508.evalMarkers
Type: evalMarkers :: AttrSet -> AttrSet -> bool
Evaluate an environment as returned by mkEnviron
against markers as returend by parseMarkers
.
environ
: Function argument
value
: Function argument
::: {.example #function-library-example-lib.pep508.evalMarkers}
lib.pep508.evalMarkers
usage example
# evalMarkers (mkEnviron pkgs.python3) (parseMarkers "python_version < \"3.11\"")
true
:::