mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
Add projectDir to import path for scripts packages
This ensures that packages retain their editable property despite not being in the current working directory.
This commit is contained in:
parent
aee8f04296
commit
94ef93f039
2 changed files with 9 additions and 3 deletions
|
@ -105,7 +105,7 @@ lib.makeScope pkgs.newScope (self: {
|
||||||
}:
|
}:
|
||||||
assert scripts != { };
|
assert scripts != { };
|
||||||
import ./shell-scripts.nix {
|
import ./shell-scripts.nix {
|
||||||
inherit lib python scripts;
|
inherit lib python scripts projectDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -130,7 +130,7 @@ lib.makeScope pkgs.newScope (self: {
|
||||||
scripts = pyProject.tool.poetry.scripts or { };
|
scripts = pyProject.tool.poetry.scripts or { };
|
||||||
hasScripts = scripts != { };
|
hasScripts = scripts != { };
|
||||||
scriptsPackage = self.mkPoetryScriptsPackage {
|
scriptsPackage = self.mkPoetryScriptsPackage {
|
||||||
inherit python scripts;
|
inherit python scripts projectDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
hasEditable = editablePackageSources != { };
|
hasEditable = editablePackageSources != { };
|
||||||
|
@ -264,7 +264,7 @@ lib.makeScope pkgs.newScope (self: {
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
poetryPython = self.mkPoetryPackages {
|
poetryPython = self.mkPoetryPackages {
|
||||||
inherit pyproject poetrylock overrides python pwd preferWheels editablePackageSources;
|
inherit projectDir pyproject poetrylock overrides python pwd preferWheels editablePackageSources;
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (poetryPython) poetryPackages;
|
inherit (poetryPython) poetryPackages;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{ lib
|
{ lib
|
||||||
, scripts
|
, scripts
|
||||||
, python
|
, python
|
||||||
|
, projectDir ? null
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
mkScript = bin: entrypoint:
|
mkScript = bin: entrypoint:
|
||||||
|
@ -15,6 +16,11 @@ let
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
${lib.optionalString (projectDir != null) ''
|
||||||
|
# Add projectDir to load path
|
||||||
|
sys.path.insert(0, "${builtins.toString projectDir}")
|
||||||
|
''}
|
||||||
|
|
||||||
# Insert "" to add CWD to import path
|
# Insert "" to add CWD to import path
|
||||||
sys.path.insert(0, "")
|
sys.path.insert(0, "")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue