mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 08:41:42 -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 != { };
|
||||
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 { };
|
||||
hasScripts = scripts != { };
|
||||
scriptsPackage = self.mkPoetryScriptsPackage {
|
||||
inherit python scripts;
|
||||
inherit python scripts projectDir;
|
||||
};
|
||||
|
||||
hasEditable = editablePackageSources != { };
|
||||
|
@ -264,7 +264,7 @@ lib.makeScope pkgs.newScope (self: {
|
|||
}:
|
||||
let
|
||||
poetryPython = self.mkPoetryPackages {
|
||||
inherit pyproject poetrylock overrides python pwd preferWheels editablePackageSources;
|
||||
inherit projectDir pyproject poetrylock overrides python pwd preferWheels editablePackageSources;
|
||||
};
|
||||
|
||||
inherit (poetryPython) poetryPackages;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ lib
|
||||
, scripts
|
||||
, python
|
||||
, projectDir ? null
|
||||
}:
|
||||
let
|
||||
mkScript = bin: entrypoint:
|
||||
|
@ -15,6 +16,11 @@ let
|
|||
import sys
|
||||
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
|
||||
sys.path.insert(0, "")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue