mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
poetry: Remove hacky build steps
Poetry can now be built normally.
This commit is contained in:
parent
e570b38501
commit
d053ef9922
1 changed files with 4 additions and 28 deletions
|
@ -1,52 +1,28 @@
|
||||||
{ lib, poetry2nix, python, fetchFromGitHub, runtimeShell }:
|
{ lib, poetry2nix, python, fetchFromGitHub }:
|
||||||
|
|
||||||
|
|
||||||
poetry2nix.mkPoetryApplication {
|
poetry2nix.mkPoetryApplication {
|
||||||
|
|
||||||
inherit python;
|
inherit python;
|
||||||
|
|
||||||
pyproject = ./pyproject.toml;
|
projectDir = ./.;
|
||||||
poetrylock = ./poetry.lock;
|
|
||||||
|
|
||||||
src = fetchFromGitHub (lib.importJSON ./src.json);
|
src = fetchFromGitHub (lib.importJSON ./src.json);
|
||||||
|
|
||||||
# "Vendor" dependencies (for build-system support)
|
# "Vendor" dependencies (for build-system support)
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
for path in ''${PYTHONPATH//:/ }; do
|
for path in ''${PYTHONPATH//:/ }; do echo $path; done | uniq | while read path; do
|
||||||
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
|
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Poetry is a bit special in that it can't use itself as the `build-system` property in pyproject.toml.
|
postInstall = ''
|
||||||
# That's why we need to hackily install outputs completely manually.
|
|
||||||
#
|
|
||||||
# For projects using poetry normally overriding the installPhase is not required.
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
mkdir -p $out/lib/${python.libPrefix}/site-packages
|
|
||||||
cp -r poetry $out/lib/${python.libPrefix}/site-packages
|
|
||||||
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cat > $out/bin/poetry <<EOF
|
|
||||||
#!${python.interpreter}
|
|
||||||
import sys
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sys.path.append("$out/lib/${python.libPrefix}/site-packages")
|
|
||||||
from poetry.console import main
|
|
||||||
main()
|
|
||||||
EOF
|
|
||||||
chmod +x $out/bin/poetry
|
|
||||||
|
|
||||||
mkdir -p "$out/share/bash-completion/completions"
|
mkdir -p "$out/share/bash-completion/completions"
|
||||||
"$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
|
"$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
|
||||||
mkdir -p "$out/share/zsh/vendor-completions"
|
mkdir -p "$out/share/zsh/vendor-completions"
|
||||||
"$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
|
"$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
|
||||||
mkdir -p "$out/share/fish/vendor_completions.d"
|
mkdir -p "$out/share/fish/vendor_completions.d"
|
||||||
"$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
|
"$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Propagating dependencies leads to issues downstream
|
# Propagating dependencies leads to issues downstream
|
||||||
|
|
Loading…
Add table
Reference in a new issue