mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-28 01:43:15 +00:00
poetry2nix: 1.11.0 -> 1.12.0
This commit is contained in:
parent
5f464fcd1f
commit
e3f6f9be0f
@ -24,7 +24,7 @@ in
|
||||
lib.makeScope pkgs.newScope (self: {
|
||||
|
||||
# Poetry2nix version
|
||||
version = "1.11.0";
|
||||
version = "1.12.0";
|
||||
|
||||
/*
|
||||
Returns an attrset { python, poetryPackages, pyProject, poetryLock } for the given pyproject/lockfile.
|
||||
@ -114,7 +114,7 @@ lib.makeScope pkgs.newScope (self: {
|
||||
|
||||
__toPluginAble = toPluginAble self;
|
||||
|
||||
inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook;
|
||||
inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook wheelUnpackHook;
|
||||
}
|
||||
)
|
||||
# Null out any filtered packages, we don't want python.pkgs from nixpkgs
|
||||
@ -159,13 +159,28 @@ lib.makeScope pkgs.newScope (self: {
|
||||
}
|
||||
);
|
||||
|
||||
inherit (py) pyProject;
|
||||
|
||||
# Add executables from tool.poetry.scripts
|
||||
scripts = pyProject.tool.poetry.scripts or { };
|
||||
hasScripts = scripts != { };
|
||||
scriptsPackage = import ./shell-scripts.nix {
|
||||
inherit scripts lib;
|
||||
inherit (py) python;
|
||||
};
|
||||
|
||||
hasEditable = editablePackageSources != { };
|
||||
editablePackage = import ./editable.nix {
|
||||
inherit pkgs lib poetryLib editablePackageSources;
|
||||
inherit (py) pyProject python;
|
||||
};
|
||||
|
||||
in
|
||||
py.python.withPackages (_: py.poetryPackages ++ lib.optional (editablePackageSources != { }) editablePackage);
|
||||
py.python.withPackages (
|
||||
_: py.poetryPackages
|
||||
++ lib.optional hasEditable editablePackage
|
||||
++ lib.optional hasScripts scriptsPackage
|
||||
);
|
||||
|
||||
/* Creates a Python application from pyproject.toml and poetry.lock
|
||||
|
||||
|
@ -49,4 +49,16 @@ in
|
||||
} ./fixup-hook.sh
|
||||
) { };
|
||||
|
||||
# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
|
||||
# It doesn't _really_ depend on wheel though, it just copies the wheel.
|
||||
wheelUnpackHook = callPackage
|
||||
({}:
|
||||
makeSetupHook
|
||||
{
|
||||
name = "wheel-unpack-hook.sh";
|
||||
deps = [ ];
|
||||
} ./wheel-unpack-hook.sh
|
||||
) { };
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
# Setup hook to use in case a wheel is fetched
|
||||
echo "Sourcing wheel setup hook"
|
||||
|
||||
wheelUnpackPhase(){
|
||||
echo "Executing wheelUnpackPhase"
|
||||
runHook preUnpack
|
||||
|
||||
mkdir -p dist
|
||||
cp "$src" "dist/$(stripHash "$src")"
|
||||
|
||||
# runHook postUnpack # Calls find...?
|
||||
echo "Finished executing wheelUnpackPhase"
|
||||
}
|
||||
|
||||
if [ -z "${dontUseWheelUnpack-}" ] && [ -z "${unpackPhase-}" ]; then
|
||||
echo "Using wheelUnpackPhase"
|
||||
unpackPhase=wheelUnpackPhase
|
||||
fi
|
@ -47,10 +47,16 @@ pythonPackages.callPackage
|
||||
isGit = isSource && source.type == "git";
|
||||
isLocal = isSource && source.type == "directory";
|
||||
localDepPath = toPath source.url;
|
||||
pyProject = poetryLib.readTOML (localDepPath + "/pyproject.toml");
|
||||
buildSystemPkgs = poetryLib.getBuildSystemPkgs {
|
||||
inherit pythonPackages pyProject;
|
||||
};
|
||||
|
||||
buildSystemPkgs =
|
||||
let
|
||||
pyProjectPath = localDepPath + "/pyproject.toml";
|
||||
pyProject = poetryLib.readTOML pyProjectPath;
|
||||
in
|
||||
if builtins.pathExists pyProjectPath then poetryLib.getBuildSystemPkgs {
|
||||
inherit pythonPackages pyProject;
|
||||
} else [ ];
|
||||
|
||||
fileInfo =
|
||||
let
|
||||
isBdist = f: lib.strings.hasSuffix "whl" f.file;
|
||||
|
@ -12,6 +12,40 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
ansible = super.ansible.overridePythonAttrs (
|
||||
old: {
|
||||
|
||||
prePatch = pkgs.python.pkgs.ansible.prePatch or "";
|
||||
|
||||
postInstall = pkgs.python.pkgs.ansible.postInstall or "";
|
||||
|
||||
# Inputs copied from nixpkgs as ansible doesn't specify it's dependencies
|
||||
# in a correct manner.
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
self.pycrypto
|
||||
self.paramiko
|
||||
self.jinja2
|
||||
self.pyyaml
|
||||
self.httplib2
|
||||
self.six
|
||||
self.netaddr
|
||||
self.dnspython
|
||||
self.jmespath
|
||||
self.dopy
|
||||
self.ncclient
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
ansible-lint = super.ansible-lint.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
|
||||
preBuild = ''
|
||||
export HOME=$(mktemp -d)
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
astroid = super.astroid.overridePythonAttrs (
|
||||
old: rec {
|
||||
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
|
||||
@ -135,6 +169,15 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
h3 = super.h3.overridePythonAttrs (
|
||||
old: {
|
||||
preBuild = (old.preBuild or "") + ''
|
||||
substituteInPlace h3/h3.py \
|
||||
--replace "'{}/{}'.format(_dirname, libh3_path)" '"${pkgs.h3}/lib/libh3${pkgs.stdenv.hostPlatform.extensions.sharedLibrary}"'
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
h5py = super.h5py.overridePythonAttrs (
|
||||
old:
|
||||
if old.format != "wheel" then rec {
|
||||
@ -324,6 +367,13 @@ self: super:
|
||||
pkgs.pkgconfig
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
cat > setup.cfg <<EOF
|
||||
[libs]
|
||||
system_freetype = True
|
||||
EOF
|
||||
'';
|
||||
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
pkgs.libpng
|
||||
pkgs.freetype
|
||||
@ -357,6 +407,23 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
molecule =
|
||||
if lib.versionOlder super.molecule.version "3.0.0" then (super.molecule.overridePythonAttrs (
|
||||
old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
# Fix build with more recent setuptools versions
|
||||
(pkgs.fetchpatch {
|
||||
url = "https://github.com/ansible-community/molecule/commit/c9fee498646a702c77b5aecf6497cff324acd056.patch";
|
||||
sha256 = "1g1n45izdz0a3c9akgxx14zhdw6c3dkb48j8pq64n82fa6ndl1b7";
|
||||
excludes = [ "pyproject.toml" ];
|
||||
})
|
||||
];
|
||||
buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
|
||||
}
|
||||
)) else super.molecule.overridePythonAttrs (old: {
|
||||
buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
|
||||
});
|
||||
|
||||
netcdf4 = super.netcdf4.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
@ -451,12 +518,16 @@ self: super:
|
||||
|
||||
psycopg2 = super.psycopg2.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs
|
||||
++ lib.optional stdenv.isDarwin pkgs.openssl;
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
|
||||
}
|
||||
);
|
||||
|
||||
psycopg2-binary = super.psycopg2-binary.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs
|
||||
++ lib.optional stdenv.isDarwin pkgs.openssl;
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
|
||||
}
|
||||
);
|
||||
@ -753,6 +824,12 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
ffmpeg-python = super.ffmpeg-python.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
|
||||
}
|
||||
);
|
||||
|
||||
python-prctl = super.python-prctl.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [
|
||||
@ -882,6 +959,9 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
# nix uses a dash, poetry uses an underscore
|
||||
typing_extensions = super.typing_extensions or self.typing-extensions;
|
||||
|
||||
urwidtrees = super.urwidtrees.overridePythonAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [
|
||||
@ -898,6 +978,16 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
vispy = super.vispy.overrideAttrs (
|
||||
old: {
|
||||
inherit (pkgs.python3.pkgs.vispy) patches;
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||
self.cython
|
||||
self.setuptools-scm-git-archive
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
uvloop = super.uvloop.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [
|
||||
@ -907,17 +997,34 @@ self: super:
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
# Stop infinite recursion by using bootstrapped pkg from nixpkgs
|
||||
wheel = (
|
||||
pkgs.python3.pkgs.override {
|
||||
bootstrapped-pip = super.bootstrapped-pip.override {
|
||||
wheel = (pkgs.python3.pkgs.override {
|
||||
python = self.python;
|
||||
}
|
||||
).wheel.overridePythonAttrs (
|
||||
old:
|
||||
if old.format == "other" then old else {
|
||||
inherit (super.wheel) pname name version src;
|
||||
}
|
||||
);
|
||||
}).wheel;
|
||||
};
|
||||
wheel =
|
||||
let
|
||||
isWheel = super.wheel.src.isWheel or false;
|
||||
# If "wheel" is a pre-built binary wheel
|
||||
wheelPackage = super.buildPythonPackage {
|
||||
inherit (super.wheel) pname name version src;
|
||||
inherit (pkgs.python3.pkgs.wheel) meta;
|
||||
format = "wheel";
|
||||
};
|
||||
# If "wheel" is built from source
|
||||
sourcePackage = (
|
||||
pkgs.python3.pkgs.override {
|
||||
python = self.python;
|
||||
}
|
||||
).wheel.overridePythonAttrs (
|
||||
old: {
|
||||
inherit (super.wheel) pname name version src;
|
||||
}
|
||||
);
|
||||
in
|
||||
if isWheel then wheelPackage else sourcePackage;
|
||||
|
||||
zipp =
|
||||
(
|
||||
|
@ -62,7 +62,7 @@ let
|
||||
selectWheel = files:
|
||||
let
|
||||
filesWithoutSources = (builtins.filter (x: hasSuffix ".whl" x.file) files);
|
||||
isPyAbiCompatible = pyabi: x: x == "none" || lib.hasPrefix pyabi x || (
|
||||
isPyAbiCompatible = pyabi: x: x == "none" || lib.hasPrefix pyabi x || lib.hasPrefix x pyabi || (
|
||||
# The CPython stable ABI is abi3 as in the shared library suffix.
|
||||
python.passthru.implementation == "cpython" &&
|
||||
builtins.elemAt (lib.splitString "." python.version) 0 == "3" &&
|
||||
|
@ -0,0 +1,41 @@
|
||||
{ lib
|
||||
, scripts
|
||||
, python
|
||||
}:
|
||||
let
|
||||
mkScript = bin: entrypoint:
|
||||
let
|
||||
elem = builtins.elemAt (builtins.split ":" entrypoint);
|
||||
module = elem 0;
|
||||
fn = elem 2;
|
||||
in
|
||||
''
|
||||
cat << EOF >> $out/bin/${bin}
|
||||
#!${python.interpreter}
|
||||
import sys
|
||||
import re
|
||||
|
||||
# Insert "" to add CWD to import path
|
||||
sys.path.insert(0, "")
|
||||
|
||||
from ${module} import ${fn}
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', "", sys.argv[0])
|
||||
sys.exit(${fn}())
|
||||
EOF
|
||||
chmod +x $out/bin/${bin}
|
||||
'';
|
||||
in
|
||||
python.pkgs.buildPythonPackage {
|
||||
name = "poetry2nix-env-scripts";
|
||||
dontUnpack = true;
|
||||
dontUseSetuptoolsBuild = true;
|
||||
dontConfigure = true;
|
||||
dontUseSetuptoolsCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList mkScript scripts)}
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user