poetry2nix: 1.31.0 -> 1.33.0

This commit is contained in:
adisbladis 2022-10-07 18:12:48 +13:00
parent 867d3dd394
commit aa463a0d1d
16 changed files with 18018 additions and 1228 deletions

View file

@ -5,9 +5,9 @@
}:
let
# Poetry2nix version
version = "1.31.0";
version = "1.33.0";
inherit (poetryLib) isCompatible readTOML moduleName;
inherit (poetryLib) isCompatible readTOML normalizePackageName normalizePackageSet;
# Map SPDX identifiers to license names
spdxLicenses = lib.listToAttrs (lib.filter (pair: pair.name != null) (builtins.map (v: { name = if lib.hasAttr "spdxId" v then v.spdxId else null; value = v; }) (lib.attrValues lib.licenses)));
@ -17,29 +17,33 @@ let
# Experimental withPlugins functionality
toPluginAble = (import ./plugins.nix { inherit pkgs lib; }).toPluginAble;
# List of known build systems that are passed through from nixpkgs unmodified
knownBuildSystems = builtins.fromJSON (builtins.readFile ./known-build-systems.json);
nixpkgsBuildSystems = lib.subtractLists [ "poetry" "poetry-core" ] knownBuildSystems;
mkInputAttrs =
{ py
, pyProject
, attrs
, includeBuildSystem ? true
, groups ? [ ]
}:
let
getInputs = attr: attrs.${attr} or [ ];
# Get dependencies and filter out depending on interpreter version
getDeps = depAttr:
getDeps = depSet:
let
compat = isCompatible (poetryLib.getPythonVersion py);
deps = pyProject.tool.poetry.${depAttr} or { };
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames depSet);
in
(
builtins.map
(
dep:
let
pkg = py.pkgs."${moduleName dep}";
constraints = deps.${dep}.python or "";
pkg = py.pkgs."${normalizePackageName dep}";
constraints = depSet.${dep}.python or "";
isCompat = compat constraints;
in
if isCompat then pkg else null
@ -57,9 +61,20 @@ let
in
{
buildInputs = mkInput "buildInputs" (if includeBuildSystem then buildSystemPkgs else [ ]);
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
propagatedBuildInputs = mkInput "propagatedBuildInputs" (
(getDeps pyProject.tool.poetry."dependencies" or { })
++ (
# >=poetry-1.2.0 dependency groups
if pyProject.tool.poetry.group or { } != { }
then lib.flatten (map (g: getDeps pyProject.tool.poetry.group.${g}.dependencies) groups)
else [ ]
)
);
nativeBuildInputs = mkInput "nativeBuildInputs" [ ];
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
checkInputs = mkInput "checkInputs" (
getDeps (pyProject.tool.poetry."dev-dependencies" or { }) # <poetry-1.2.0
++ getDeps (pyProject.tool.poetry.group."dev".dependencies or { }) # >=poetry-1.2.0
);
};
@ -115,7 +130,8 @@ lib.makeScope pkgs.newScope (self: {
# Example: { my-app = ./src; }
, editablePackageSources ? { }
, pyProject ? readTOML pyproject
}@attrs:
, groups ? [ ]
}:
let
/* The default list of poetry2nix override overlays */
mkEvalPep508 = import ./pep508.nix {
@ -144,15 +160,7 @@ lib.makeScope pkgs.newScope (self: {
let
lockfiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
in
lib.listToAttrs (lib.mapAttrsToList (n: v: { name = moduleName n; value = v; }) lockfiles);
specialAttrs = [
"overrides"
"poetrylock"
"projectDir"
"pwd"
"preferWheels"
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;
lib.listToAttrs (lib.mapAttrsToList (n: v: { name = normalizePackageName n; value = v; }) lockfiles);
evalPep508 = mkEvalPep508 python;
# Filter packages by their PEP508 markers & pyproject interpreter version
@ -170,19 +178,32 @@ lib.makeScope pkgs.newScope (self: {
# closure as python can only ever have one version of a dependency
baseOverlay = self: super:
let
getDep = depName: self.${depName};
lockPkgs = builtins.listToAttrs (
builtins.map
(
pkgMeta: rec {
name = moduleName pkgMeta.name;
pkgMeta:
if builtins.elem pkgMeta.name nixpkgsBuildSystems then {
name = pkgMeta.name;
value = super."${pkgMeta.name}";
} else rec {
name = normalizePackageName pkgMeta.name;
value = self.mkPoetryDep (
pkgMeta // {
inherit pwd preferWheels;
source = pkgMeta.source or null;
files = lockFiles.${name};
pythonPackages = self;
sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name} or { };
sourceSpec =
let
normalizedName = normalizePackageName pkgMeta.name;
in
(
(normalizePackageSet pyProject.tool.poetry.dependencies or { }).${normalizedName}
or (normalizePackageSet pyProject.tool.poetry.dev-dependencies or { }).${normalizedName}
or (normalizePackageSet pyProject.tool.poetry.group.dev.dependencies { }).${normalizedName} # Poetry 1.2.0+
or { }
);
}
);
}
@ -231,7 +252,7 @@ lib.makeScope pkgs.newScope (self: {
super)
# Null out any filtered packages, we don't want python.pkgs from nixpkgs
(self: super: builtins.listToAttrs (builtins.map (x: { name = moduleName x.name; value = null; }) incompatible))
(self: super: builtins.listToAttrs (builtins.map (x: { name = normalizePackageName x.name; value = null; }) incompatible))
# Create poetry2nix layer
baseOverlay
@ -241,7 +262,7 @@ lib.makeScope pkgs.newScope (self: {
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) overlays;
py = python.override { inherit packageOverrides; self = py; };
inputAttrs = mkInputAttrs { inherit py pyProject; attrs = { }; includeBuildSystem = false; };
inputAttrs = mkInputAttrs { inherit py pyProject groups; attrs = { }; includeBuildSystem = false; };
requiredPythonModules = python.pkgs.requiredPythonModules;
/* Include all the nested dependencies which are required for each package.
@ -276,9 +297,10 @@ lib.makeScope pkgs.newScope (self: {
, preferWheels ? false
, editablePackageSources ? { }
, extraPackages ? ps: [ ]
, groups ? [ "dev" ]
}:
let
inherit (lib) elem hasAttr;
inherit (lib) hasAttr;
pyProject = readTOML pyproject;
@ -294,6 +316,12 @@ lib.makeScope pkgs.newScope (self: {
allEditablePackageSources = (
(getEditableDeps (pyProject.tool.poetry."dependencies" or { }))
// (getEditableDeps (pyProject.tool.poetry."dev-dependencies" or { }))
// (
# Poetry>=1.2.0
if pyProject.tool.poetry.group or { } != { } then
builtins.foldl' (acc: g: acc // getEditableDeps pyProject.tool.poetry.group.${g}.dependencies) { } groups
else { }
)
// editablePackageSources
);
@ -302,7 +330,7 @@ lib.makeScope pkgs.newScope (self: {
excludedEditablePackageNames;
poetryPython = self.mkPoetryPackages {
inherit pyproject poetrylock overrides python pwd preferWheels pyProject;
inherit pyproject poetrylock overrides python pwd preferWheels pyProject groups;
editablePackageSources = editablePackageSources';
};
@ -335,11 +363,12 @@ lib.makeScope pkgs.newScope (self: {
, python ? pkgs.python3
, pwd ? projectDir
, preferWheels ? false
, groups ? [ ]
, ...
}@attrs:
let
poetryPython = self.mkPoetryPackages {
inherit pyproject poetrylock overrides python pwd preferWheels;
inherit pyproject poetrylock overrides python pwd preferWheels groups;
};
py = poetryPython.python;
@ -354,7 +383,7 @@ lib.makeScope pkgs.newScope (self: {
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;
inputAttrs = mkInputAttrs { inherit py pyProject attrs; };
inputAttrs = mkInputAttrs { inherit py pyProject attrs groups; };
app = py.pkgs.buildPythonPackage (
passedAttrs // inputAttrs // {
@ -363,7 +392,7 @@ lib.makeScope pkgs.newScope (self: {
py.pkgs.removeGitDependenciesHook
];
} // {
pname = moduleName pyProject.tool.poetry.name;
pname = normalizePackageName pyProject.tool.poetry.name;
version = pyProject.tool.poetry.version;
inherit src;
@ -445,7 +474,7 @@ lib.makeScope pkgs.newScope (self: {
Can be overriden by calling defaultPoetryOverrides.overrideOverlay which takes an overlay function
*/
defaultPoetryOverrides = self.mkDefaultPoetryOverrides (import ./overrides { inherit pkgs lib; });
defaultPoetryOverrides = self.mkDefaultPoetryOverrides (import ./overrides { inherit pkgs lib poetryLib; });
/*
Convenience functions for specifying overlays with or without the poerty2nix default overrides

View file

@ -6,7 +6,7 @@
, editablePackageSources
}:
let
name = poetryLib.moduleName pyProject.tool.poetry.name;
name = poetryLib.normalizePackageName pyProject.tool.poetry.name;
# Just enough standard PKG-INFO fields for an editable installation
pkgInfoFields = {

View file

@ -80,14 +80,23 @@ if package_filename not in parser.sources:
exit(1)
package_file = open(package_filename, "wb")
# Sometimes the href is a relative path
if urlparse(parser.sources[package_filename]).netloc == "":
# Sometimes the href is a relative or absolute path within the index's domain.
indicated_url = urlparse(parser.sources[package_filename])
if indicated_url.netloc == "":
parsed_url = urlparse(index_url)
if indicated_url.path.startswith("/"):
# An absolute path within the index's domain.
path = parser.sources[package_filename]
else:
# A relative path.
path = parsed_url.path + "/" + parser.sources[package_filename]
package_url = urlunparse(
(
parsed_url.scheme,
parsed_url.netloc,
parsed_url.path + "/" + parser.sources[package_filename],
path,
None,
None,
None,

View file

@ -70,6 +70,7 @@ in
filenames = builtins.concatStringsSep " " [
"pyproject.toml"
"README.md"
"LICENSE"
];
};
} ./fixup-hook.sh

View file

@ -22,6 +22,7 @@ def main(input, output, fields_to_remove):
any_removed |= dep.pop(field, None) is not None
if any_removed:
dep["version"] = "*"
dep.pop("develop", None)
output.write(tomlkit.dumps(data))

View file

@ -0,0 +1,12 @@
[
"poetry",
"poetry-core",
"flit",
"flit-core",
"pbr",
"flitBuildHook",
"cython",
"hatchling",
"setuptools",
"setuptools-scm"
]

View file

@ -8,8 +8,16 @@ let
genList (i: if i == idx then value else (builtins.elemAt list i)) (length list)
);
# Do some canonicalisation of module names
moduleName = name: lib.toLower (lib.replaceStrings [ "_" "." ] [ "-" "-" ] name);
# Normalize package names as per PEP 503
normalizePackageName = name:
let
parts = builtins.split "[-_.]+" name;
partsWithoutSeparator = builtins.filter (x: builtins.typeOf x == "string") parts;
in
lib.strings.toLower (lib.strings.concatStringsSep "-" partsWithoutSeparator);
# Normalize an entire attrset of packages
normalizePackageSet = lib.attrsets.mapAttrs' (name: value: lib.attrsets.nameValuePair (normalizePackageName name) value);
# Get a full semver pythonVersion from a python derivation
getPythonVersion = python:
@ -233,7 +241,8 @@ in
getBuildSystemPkgs
satisfiesSemver
cleanPythonSources
moduleName
normalizePackageName
normalizePackageSet
getPythonVersion
getTargetMachine
;

View file

@ -26,7 +26,7 @@ pythonPackages.callPackage
}@args:
let
inherit (python) stdenv;
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromLegacy fetchFromPypi moduleName;
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromLegacy fetchFromPypi normalizePackageName;
inherit (import ./pep425.nix {
inherit lib poetryLib python stdenv;
@ -88,26 +88,14 @@ pythonPackages.callPackage
else (builtins.elemAt (lib.strings.splitString "-" name) 2);
};
# Prevent infinite recursion
skipSetupToolsSCM = [
"setuptools_scm"
"setuptools-scm"
"toml" # Toml is an extra for setuptools-scm
"tomli" # tomli is an extra for later versions of setuptools-scm
"flit-core"
"packaging"
"six"
"pyparsing"
"typing-extensions"
];
baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm;
format = if isDirectory || isGit || isUrl then "pyproject" else fileInfo.format;
in
buildPythonPackage {
pname = moduleName name;
pname = normalizePackageName name;
version = version;
inherit format;
# Circumvent output separation (https://github.com/NixOS/nixpkgs/pull/190487)
format = if format == "pyproject" then "poetry2nix" else format;
doCheck = false; # We never get development deps
@ -118,16 +106,21 @@ pythonPackages.callPackage
pythonPackages.poetry2nixFixupHook
]
++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook
++ lib.optionals (format == "wheel") [
pythonPackages.wheelUnpackHook
pythonPackages.pipInstallHook
pythonPackages.setuptools
]
++ lib.optionals (format == "pyproject") [
pythonPackages.removePathDependenciesHook
pythonPackages.removeGitDependenciesHook
pythonPackages.pipBuildHook
];
buildInputs = (
baseBuildInputs
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) pythonPackages.setuptools
++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
++ lib.optional isDirectory buildSystemPkgs
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) pythonPackages.setuptools
);
propagatedBuildInputs =
@ -149,7 +142,7 @@ pythonPackages.callPackage
);
depAttrs = lib.attrNames deps;
in
builtins.map (n: pythonPackages.${moduleName n}) depAttrs;
builtins.map (n: pythonPackages.${normalizePackageName n}) depAttrs;
meta = {
broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions;
@ -172,10 +165,7 @@ pythonPackages.callPackage
rev = source.resolved_reference or source.reference;
ref = sourceSpec.branch or (if sourceSpec ? tag then "refs/tags/${sourceSpec.tag}" else "HEAD");
} // (
let
nixVersion = builtins.substring 0 3 builtins.nixVersion;
in
lib.optionalAttrs ((sourceSpec ? rev) && (lib.versionAtLeast nixVersion "2.4")) {
lib.optionalAttrs ((sourceSpec ? rev) && (lib.versionAtLeast builtins.nixVersion "2.4")) {
allRefs = true;
}
))

View file

@ -1,6 +1,7 @@
{ pkgs ? import <nixpkgs> { }
, lib ? pkgs.lib
, stdenv ? pkgs.stdenv
, poetryLib
}:
let
@ -37,6 +38,8 @@ let
(
# Flit only works on Python3
if (attr == "flit-core" || attr == "flit" || attr == "hatchling") && !self.isPy3k then drv
else if drv == null then null
else if drv ? overridePythonAttrs == false then drv
else
drv.overridePythonAttrs (
old:
@ -56,6 +59,8 @@ let
in
lib.composeManyExtensions [
# normalize all the names
(self: super: poetryLib.normalizePackageSet super)
# NixOps
(self: super:
@ -80,22 +85,11 @@ lib.composeManyExtensions [
systems)
buildSystems)
# Build systems with conditionals
(self: super: {
platformdirs =
if lib.versionAtLeast super.platformdirs.version "2.5.2"
then addBuildSystem { inherit self; drv = super.platformdirs; attr = "hatchling"; extraAttrs = [ "hatch-vcs" ]; }
else super.platformdirs;
})
# Build fixes
(self: super:
let
inherit (self.python) stdenv;
inherit (pkgs.buildPackages) pkg-config;
inherit (pkgs) buildPackages;
pyBuildPackages = self.python.pythonForBuild.pkgs;
selectQt5 = version:
@ -108,7 +102,7 @@ lib.composeManyExtensions [
{
automat = super.automat.overridePythonAttrs (
old: rec {
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.m2r ];
}
);
@ -152,7 +146,7 @@ lib.composeManyExtensions [
);
argcomplete = super.argcomplete.overridePythonAttrs (
old: rec {
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.importlib-metadata ];
}
);
@ -164,7 +158,7 @@ lib.composeManyExtensions [
);
astroid = super.astroid.overridePythonAttrs (
old: rec {
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
@ -193,13 +187,37 @@ lib.composeManyExtensions [
dontUseCmakeConfigure = true;
}
);
bcrypt = super.bcrypt.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libffi ];
}
);
bcrypt =
let
getCargoHash = version: {
"4.0.0" = "sha256-HvfRLyUhlXVuvxWrtSDKx3rMKJbjvuiMcDY6g+pYFS0=";
}.${version} or (
lib.warn "Unknown bcrypt version: '${version}'. Please update getCargoHash." lib.fakeHash
);
sha256 = getCargoHash super.bcrypt.version;
in
super.bcrypt.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ])
++ [ pkgs.libffi ]
++ lib.optionals (lib.versionAtLeast old.version "4" && stdenv.isDarwin)
[ pkgs.darwin.apple_sdk.frameworks.Security pkgs.libiconv ];
nativeBuildInputs = with pkgs;
(old.nativeBuildInputs or [ ])
++ lib.optionals (lib.versionAtLeast old.version "4")
(with pkgs.rustPlatform; [ rust.rustc rust.cargo cargoSetupHook self.setuptools-rust ]);
} // lib.optionalAttrs (lib.versionAtLeast old.version "4") rec {
cargoDeps =
pkgs.rustPlatform.fetchCargoTarball
{
src = old.src;
sourceRoot = "${old.pname}-${old.version}/src/_bcrypt";
name = "${old.pname}-${old.version}";
sha256 = getCargoHash old.version;
};
cargoRoot = "src/_bcrypt";
}
);
bjoern = super.bjoern.overridePythonAttrs (
old: {
buildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.libev ];
@ -276,6 +294,12 @@ lib.composeManyExtensions [
)
);
contourpy = super.contourpy.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pybind11 ];
}
);
cloudflare = super.cloudflare.overridePythonAttrs (
old: {
postPatch = ''
@ -326,6 +350,7 @@ lib.composeManyExtensions [
"36.0.2" = "1a0ni1a3dbv2dvh6gx2i54z8v5j9m6asqg97kkv7gqb1ivihsbp8";
"37.0.2" = "sha256-qvrxvneoBXjP96AnUPyrtfmCnZo+IriHR5HbtWQ5Gk8=";
"37.0.4" = "sha256-f8r6QclTwkgK20CNe9i65ZOqvSUeDc4Emv6BFBhh1hI";
"38.0.1" = "sha256-o8l13fnfEUvUdDasq3LxSPArozRHKVsZfQg9DNR6M6Q=";
}.${version} or (
lib.warn "Unknown cryptography version: '${version}'. Please update getCargoHash." lib.fakeHash
);
@ -344,7 +369,8 @@ lib.composeManyExtensions [
++ lib.optional (!self.isPyPy) pyBuildPackages.cffi
++ lib.optional (lib.versionAtLeast old.version "3.5")
(with pkgs.rustPlatform; [ cargoSetupHook rust.cargo rust.rustc ]);
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.openssl ]
buildInputs = (old.buildInputs or [ ])
++ [ (if lib.versionAtLeast old.version "37" then pkgs.openssl_3 else pkgs.openssl_1_1) ]
++ lib.optionals stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security pkgs.libiconv ];
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ self.cffi ];
} // lib.optionalAttrs (lib.versionAtLeast old.version "3.4" && lib.versionOlder old.version "3.5") {
@ -624,6 +650,11 @@ lib.composeManyExtensions [
outputs = [ "out" "dev" ];
});
gunicorn = super.gunicorn.overridePythonAttrs (old: {
# actually needs setuptools as a runtime dependency
propagatedBuildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools ];
});
h3 = super.h3.overridePythonAttrs (
old: {
preBuild = (old.preBuild or "") + ''
@ -834,8 +865,17 @@ lib.composeManyExtensions [
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.yajl ];
});
jsonschema =
if lib.versionAtLeast super.jsonschema.version "4.0.0"
then
super.jsonschema.overridePythonAttrs
(old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.importlib-resources ];
})
else super.jsonschema;
jupyter = super.jupyter.overridePythonAttrs (
old: rec {
old: {
# jupyter is a meta-package. Everything relevant comes from the
# dependencies. It does however have a jupyter.py file that conflicts
# with jupyter-core so this meta solves this conflict.
@ -848,7 +888,7 @@ lib.composeManyExtensions [
});
jupyterlab-widgets = super.jupyterlab-widgets.overridePythonAttrs (
old: rec {
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.jupyter-packaging ];
}
);
@ -1089,11 +1129,11 @@ lib.composeManyExtensions [
excludes = [ "pyproject.toml" ];
})
];
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools-scm-git-archive ];
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools self.setuptools-scm self.setuptools-scm-git-archive ];
}
)) else
super.molecule.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools-scm-git-archive ];
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools self.setuptools-scm self.setuptools-scm-git-archive ];
});
mpi4py = super.mpi4py.overridePythonAttrs (
@ -1153,7 +1193,7 @@ lib.composeManyExtensions [
url = "https://github.com/python/mypy/commit/e7869f05751561958b946b562093397027f6d5fa.patch";
sha256 = "sha256-waIZ+m3tfvYE4HJ8kL6rN/C4fMjvLEe9UoPbt9mHWIM=";
})
] ++ lib.optionals (lib.strings.versionAtLeast old.version "0.960") [
] ++ lib.optionals ((lib.strings.versionAtLeast old.version "0.960") && (lib.strings.versionOlder old.version "0.971")) [
(pkgs.fetchpatch {
url = "https://github.com/python/mypy/commit/2004ae023b9d3628d9f09886cbbc20868aee8554.patch";
sha256 = "sha256-y+tXvgyiECO5+66YLvaje8Bz5iPvfWNIBJcsnZ2nOdI=";
@ -1224,6 +1264,12 @@ lib.composeManyExtensions [
}
);
omegaconf = super.omegaconf.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.jdk ];
}
);
open3d = super.open3d.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (with pkgs; [
udev
@ -1232,13 +1278,16 @@ lib.composeManyExtensions [
autoPatchelfIgnoreMissingDeps = true;
});
opencv-python = super.opencv-python.overridePythonAttrs (
_opencv-python-override =
old: {
nativeBuildInputs = [ pkgs.cmake ] ++ old.nativeBuildInputs;
buildInputs = [ self.scikit-build ] ++ (old.buildInputs or [ ]);
dontUseCmakeConfigure = true;
}
);
};
opencv-python = super.opencv-python.overridePythonAttrs self._opencv-python-override;
opencv-python-headless = super.opencv-python.overridePythonAttrs self._opencv-python-override;
opencv-contrib-python = super.opencv-contrib-python.overridePythonAttrs (
old: {
@ -1249,19 +1298,35 @@ lib.composeManyExtensions [
);
openexr = super.openexr.overridePythonAttrs (
old: rec {
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.openexr pkgs.ilmbase ];
NIX_CFLAGS_COMPILE = [ "-I${pkgs.openexr.dev}/include/OpenEXR" "-I${pkgs.ilmbase.dev}/include/OpenEXR" ];
}
);
openvino = super.openvino.overridePythonAttrs (
old: {
buildInputs = [
pkgs.ocl-icd
pkgs.hwloc
pkgs.tbb
pkgs.numactl
pkgs.libxml2
] ++ (old.buildInputs or [ ]);
}
);
orjson =
let
getCargoHash = version: {
"3.6.7" = "sha256-sz2k9podPB6QSptkyOu7+BoVTrKhefizRtYU+MICPt4=";
"3.6.8" = "sha256-vpfceVtYkU09xszNIihY1xbqGWieqDquxwsAmDH8jd4=";
"3.7.2" = "sha256-2U37IhftNYjH7sV7Nh51YpR/WjmPmmzX/aGuHsFgwf4=";
}.${version} or null;
"3.7.9" = "sha256-QHzAhjHgm4XLxY2zUdnIsd/WWMI7dJLQQAvTXC+2asQ=";
"3.8.0" = "sha256-8k0DetamwLqkdcg8V/D2J5ja6IJSLi50CE+ZjFa7Hdc=";
}.${version} or (
lib.warn "Unknown orjson version: '${version}'. Please update getCargoHash." lib.fakeHash
);
in
super.orjson.overridePythonAttrs (old: {
cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
@ -1318,7 +1383,7 @@ lib.composeManyExtensions [
});
parsel = super.parsel.overridePythonAttrs (
old: rec {
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
@ -1351,30 +1416,52 @@ lib.composeManyExtensions [
);
pillow = super.pillow.overridePythonAttrs (
old: {
old:
let
preConfigure = (old.preConfigure or "") + pkgs.python3.pkgs.pillow.preConfigure;
in
{
nativeBuildInputs = (old.nativeBuildInputs or [ ])
++ [ pkg-config self.pytest-runner ];
buildInputs = with pkgs; (old.buildInputs or [ ])
++ [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ]
++ lib.optionals (lib.versionAtLeast old.version "7.1.0") [ xorg.libxcb ]
++ lib.optionals (self.isPyPy) [ tk xorg.libX11 ];
preConfigure = lib.optional (old.format != "wheel") preConfigure;
}
);
poetry-core = super.poetry-core.overridePythonAttrs (old: {
# "Vendor" dependencies (for build-system support)
postPatch = ''
echo "import sys" >> poetry/__init__.py
for path in $propagatedBuildInputs; do
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
done
'';
poetry-core = super.poetry-core.overridePythonAttrs (old:
let
initFile =
if lib.versionOlder super.poetry-core.version "1.1"
then "poetry/__init__.py"
else "./src/poetry/core/__init__.py";
in
{
# "Vendor" dependencies (for build-system support)
postPatch = ''
find .
# Propagating dependencies leads to issues downstream
# We've already patched poetry to prefer "vendored" dependencies
postFixup = ''
rm $out/nix-support/propagated-build-inputs
'';
echo "import sys" >> ${initFile}
for path in $propagatedBuildInputs; do
echo "sys.path.insert(0, \"$path\")" >> ${initFile}
done
'';
# Propagating dependencies leads to issues downstream
# We've already patched poetry to prefer "vendored" dependencies
postFixup = ''
rm $out/nix-support/propagated-build-inputs
'';
});
# Requires poetry which isn't available during bootstrap
poetry-plugin-export = super.poetry-plugin-export.overridePythonAttrs (old: {
dontUsePythonImportsCheck = true;
pipInstallFlags = [
"--no-deps"
];
});
portend = super.portend.overridePythonAttrs (
@ -1666,6 +1753,11 @@ lib.composeManyExtensions [
in
super.pyqt5.overridePythonAttrs (
old: {
postPatch = ''
# Confirm license
sed -i s/"if tool == 'pep517':"/"if True:"/ project.py
'';
dontConfigure = true;
dontWrapQtApps = true;
nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
@ -1840,7 +1932,7 @@ lib.composeManyExtensions [
);
rockset = super.rockset.overridePythonAttrs (
old: rec {
old: {
postPatch = ''
cp ./setup_rockset.py ./setup.py
'';
@ -1994,6 +2086,12 @@ lib.composeManyExtensions [
'';
});
suds = super.suds.overridePythonAttrs (old: {
# Fix naming convention shenanigans.
# https://github.com/suds-community/suds/blob/a616d96b070ca119a532ff395d4a2a2ba42b257c/setup.py#L648
SUDS_PACKAGE = "suds";
});
systemd-python = super.systemd-python.overridePythonAttrs (old: {
buildInputs = old.buildInputs ++ [ pkgs.systemd ];
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkg-config ];
@ -2287,7 +2385,7 @@ lib.composeManyExtensions [
# For some reason the toml dependency of tqdm declared here:
# https://github.com/tqdm/tqdm/blob/67130a23646ae672836b971e1086b6ae4c77d930/pyproject.toml#L2
# is not translated correctly to a nix dependency.
tqdm = super.tqdm.overrideAttrs (
tqdm = super.tqdm.overridePythonAttrs (
old: {
buildInputs = [ super.toml ] ++ (old.buildInputs or [ ]);
}

View file

@ -99,7 +99,7 @@ let
filtered = builtins.filter filterWheel filesWithoutSources;
choose = files:
let
osxMatches = [ "12_0" "11_0" "10_12" "10_11" "10_10" "10_9" "10_8" "10_7" "any" ];
osxMatches = [ "12_0" "11_0" "10_15" "10_12" "10_11" "10_10" "10_9" "10_8" "10_7" "any" ];
linuxMatches = [ "manylinux1_" "manylinux2010_" "manylinux2014_" "manylinux_" "any" ];
chooseLinux = x: lib.take 1 (findBestMatches linuxMatches x);
chooseOSX = x: lib.take 1 (findBestMatches osxMatches x);

View file

@ -18,17 +18,19 @@ poetry2nix.mkPoetryApplication {
# "Vendor" dependencies (for build-system support)
postPatch = ''
echo "import sys" >> poetry/__init__.py
# Figure out the location of poetry.core
# As poetry.core is using the same root import name as the poetry package and the python module system wont look for the root
# in the separate second location we need to link poetry.core to poetry
POETRY_CORE=$(python -c 'import poetry.core; import os.path; print(os.path.dirname(poetry.core.__file__))')
echo "import sys" >> src/poetry/__init__.py
for path in $propagatedBuildInputs; do
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
echo "sys.path.insert(0, \"$path\")" >> src/poetry/__init__.py
done
'';
postInstall = ''
# Figure out the location of poetry.core
# As poetry.core is using the same root import name as the poetry package and the python module system wont look for the root
# in the separate second location we need to link poetry.core to poetry
ln -s $(python -c 'import poetry.core; import os.path; print(os.path.dirname(poetry.core.__file__))') $out/${python.sitePackages}/poetry/core
ln -s $POETRY_CORE $out/${python.sitePackages}/poetry/core
mkdir -p "$out/share/bash-completion/completions"
"$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"

File diff suppressed because it is too large Load diff

View file

@ -1,14 +1,31 @@
[tool.poetry]
name = "poetry"
version = "1.1.14"
version = "1.2.1"
description = "Python dependency management and packaging made easy."
authors = [
"Sébastien Eustace <sebastien@eustace.io>"
"Sébastien Eustace <sebastien@eustace.io>",
]
maintainers = [
"Arun Babu Neelicattu <arun.neelicattu@gmail.com>",
"Bjorn Neergaard <bjorn@neersighted.com>",
"Branch Vincent <branchevincent@gmail.com>",
"Bryce Drennan <github@accounts.brycedrennan.com>",
"Daniel Eades <danieleades@hotmail.com>",
"Randy Döring <radoering.poetry@gmail.com>",
"Steph Samson <hello@stephsamson.com>",
"finswimmer <finswimmer77@gmail.com>",
]
license = "MIT"
readme = "README.md"
packages = [
{ include = "poetry", from = "src" }
]
include = [
{ path = "tests", format = "sdist" }
]
homepage = "https://python-poetry.org/"
repository = "https://github.com/python-poetry/poetry"
documentation = "https://python-poetry.org/docs"
@ -20,104 +37,136 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules"
]
[tool.poetry.build]
generate-setup-file = false
# Requirements
[tool.poetry.dependencies]
python = "^3.5"
python = "^3.7"
poetry-core = "~1.0.7"
cleo = "^0.8.1"
clikit = "^0.6.2"
crashtest = { version = "^0.3.0", python = "^3.6" }
requests = "^2.18"
poetry-core = "1.2.0"
poetry-plugin-export = "^1.0.7"
"backports.cached-property" = { version = "^1.0.2", python = "<3.8" }
cachecontrol = { version = "^0.12.9", extras = ["filecache"] }
cachy = "^0.3.0"
requests-toolbelt = "^0.9.1"
cachecontrol = [
{ version = "^0.12.4", extras = ["filecache"], python = "<3.6" },
{ version = "^0.12.9", extras = ["filecache"], python = "^3.6" }
]
pkginfo = "^1.4"
cleo = "^1.0.0a5"
crashtest = "^0.3.0"
html5lib = "^1.0"
shellingham = "^1.1"
tomlkit = ">=0.7.0,<1.0.0"
importlib-metadata = { version = "^4.4", python = "<3.10" }
jsonschema = "^4.10.0"
# keyring uses calver, so version is unclamped
keyring = ">=21.2.0"
# packaging uses calver, so version is unclamped
packaging = ">=20.4"
pexpect = "^4.7.0"
packaging = "^20.4"
virtualenv = { version = "^20.0.26" }
# The typing module is not in the stdlib in Python 2.7
typing = { version = "^3.6", python = "~2.7" }
# Use pathlib2 for Python 2.7
pathlib2 = { version = "^2.3", python = "~2.7" }
# Use futures on Python 2.7
futures = { version = "^3.3.0", python = "~2.7" }
# Use glob2 for Python 2.7 and 3.4
glob2 = { version = "^0.6", python = "~2.7" }
# functools32 is needed for Python 2.7
functools32 = { version = "^3.2.3", python = "~2.7" }
keyring = [
{ version = "^18.0.1", python = "~2.7" },
{ version = "^20.0.1", python = "~3.5" },
{ version = ">=21.2.0", python = "^3.6" }
]
# Use subprocess32 for Python 2.7
subprocess32 = { version = "^3.5", python = "~2.7" }
importlib-metadata = {version = "^1.6.0", python = "<3.8"}
pkginfo = "^1.5"
platformdirs = "^2.5.2"
requests = "^2.18"
requests-toolbelt = "^0.9.1"
shellingham = "^1.5"
# exclude 0.11.2 and 0.11.3 due to https://github.com/sdispater/tomlkit/issues/225
tomlkit = ">=0.11.1,<1.0.0,!=0.11.2,!=0.11.3"
# exclude 20.4.5 - 20.4.6 due to https://github.com/pypa/pip/issues/9953
virtualenv = ">=20.4.3,!=20.4.5,!=20.4.6"
xattr = { version = "^0.9.7", markers = "sys_platform == 'darwin'" }
urllib3 = "^1.26.0"
dulwich = "^0.20.46"
[tool.poetry.dev-dependencies]
pytest = [
{version = "^4.1", python = "<3.5"},
{version = "^5.4.3", python = "~3.5"},
{version = "^6.2.5", python = ">=3.6"}
]
pytest-cov = "^2.5"
pytest-mock = "^1.9"
pre-commit = { version = "^2.6", python = "^3.6.1" }
tox = "^3.0"
pytest-sugar = "^0.9.2"
httpretty = "^1.0.3"
# We need to restrict the version of urllib3 to avoid
# httpretty breaking. This is fixed in httpretty >= 1.0.3
# but it's not compatible with Python 2.7 and 3.5.
urllib3 = "~1.26.9"
tox = "^3.18"
pytest = "^7.1"
pytest-cov = "^3.0"
pytest-mock = "^3.5"
pytest-randomly = "^3.10"
pytest-sugar = "^0.9"
pytest-xdist = { version = "^2.5", extras = ["psutil"] }
pre-commit = "^2.6"
deepdiff = "^5.0"
httpretty = "^1.0"
typing-extensions = { version = "^4.0.0", python = "<3.8" }
zipp = { version = "^3.4", python = "<3.8" }
flatdict = "^4.0.1"
mypy = ">=0.971"
types-html5lib = ">=1.1.9"
types-jsonschema = ">=4.9.0"
types-requests = ">=2.28.8"
[tool.poetry.scripts]
poetry = "poetry.console:main"
poetry = "poetry.console.application:main"
[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=1.1.0"]
build-backend = "poetry.core.masonry.api"
[tool.isort]
py_version = 37
profile = "black"
force_single_line = true
atomic = true
include_trailing_comma = true
lines_after_imports = 2
combine_as_imports = true
lines_between_types = 1
use_parentheses = true
src_paths = ["poetry", "tests"]
skip_glob = ["*/setup.py"]
filter_files = true
known_first_party = "poetry"
lines_after_imports = 2
src_paths = ["src", "tests"]
extend_skip = ["setup.py"]
known_third_party = ["poetry.core"]
[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| tests/.*/setup.py
)/
target-version = ['py37']
preview = true
force-exclude = '''
.*/setup\.py$
'''
[tool.mypy]
files = "src"
mypy_path = "src"
namespace_packages = true
explicit_package_bases = true
show_error_codes = true
strict = true
enable_error_code = [
"ignore-without-code",
"redundant-expr",
"truthy-bool",
]
# use of importlib-metadata backport at python3.7 makes it impossible to
# satisfy mypy without some ignores: but we get a different set of ignores at
# different python versions.
#
# <https://github.com/python/mypy/issues/8823>, meanwhile suppress that
# warning.
[[tool.mypy.overrides]]
module = [
'poetry.console.commands.self.show.plugins',
'poetry.installation.executor',
'poetry.mixology.version_solver',
'poetry.plugins.plugin_manager',
'poetry.repositories.installed_repository',
'poetry.utils.env',
]
warn_unused_ignores = false
[[tool.mypy.overrides]]
module = [
'cachecontrol.*',
'cachy.*',
'cleo.*',
'crashtest.*',
'pexpect.*',
'pkginfo.*',
'requests_toolbelt.*',
'shellingham.*',
'virtualenv.*',
'xattr.*',
]
ignore_missing_imports = true
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:"
]

View file

@ -1,8 +1,8 @@
{
"owner": "python-poetry",
"repo": "poetry",
"rev": "1.1.14",
"sha256": "1yx2a1xzid9zclf88wwczz7wgphsgpp3ksmha2jiacq898wrkwcz",
"rev": "1.2.1",
"sha256": "10y2vs28xbg5msr49wvhm3s780v4hb2jpxn7lzdin4l1qkrchdiq",
"fetchSubmodules": true
}

View file

@ -34,6 +34,8 @@ python.pkgs.buildPythonPackage {
dontConfigure = true;
dontUseSetuptoolsCheck = true;
format = "poetry2nix";
installPhase = ''
mkdir -p $out/bin
${lib.concatStringsSep "\n" (lib.mapAttrsToList mkScript scripts)}