mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-05 09:11:39 -05:00
fix: support nullified editablePackageSources in mkPoetryEnv
See these docs: 99c7956835/README.md (L86)
They say that any dependency passed as `null` is forced to be non editable, even if it is marked as `develop = true` in `pyproject.toml`.
However, this was not being the case.
Added a test to prove the need for the fix.
@moduon MT-83
This commit is contained in:
parent
b39ae43cf6
commit
1baca43506
7 changed files with 72 additions and 1 deletions
10
default.nix
10
default.nix
|
@ -287,12 +287,20 @@ lib.makeScope pkgs.newScope (self: {
|
||||||
(name: value: projectDir + "/${value.path}")
|
(name: value: projectDir + "/${value.path}")
|
||||||
(lib.filterAttrs (name: dep: dep.develop or false && hasAttr "path" dep) set);
|
(lib.filterAttrs (name: dep: dep.develop or false && hasAttr "path" dep) set);
|
||||||
|
|
||||||
editablePackageSources' = (
|
excludedEditablePackageNames = builtins.filter
|
||||||
|
(pkg: editablePackageSources."${pkg}" == null)
|
||||||
|
(builtins.attrNames editablePackageSources);
|
||||||
|
|
||||||
|
allEditablePackageSources = (
|
||||||
(getEditableDeps (pyProject.tool.poetry."dependencies" or { }))
|
(getEditableDeps (pyProject.tool.poetry."dependencies" or { }))
|
||||||
// (getEditableDeps (pyProject.tool.poetry."dev-dependencies" or { }))
|
// (getEditableDeps (pyProject.tool.poetry."dev-dependencies" or { }))
|
||||||
// editablePackageSources
|
// editablePackageSources
|
||||||
);
|
);
|
||||||
|
|
||||||
|
editablePackageSources' = builtins.removeAttrs
|
||||||
|
allEditablePackageSources
|
||||||
|
excludedEditablePackageNames;
|
||||||
|
|
||||||
poetryPython = self.mkPoetryPackages {
|
poetryPython = self.mkPoetryPackages {
|
||||||
inherit pyproject poetrylock overrides python pwd preferWheels pyProject;
|
inherit pyproject poetrylock overrides python pwd preferWheels pyProject;
|
||||||
editablePackageSources = editablePackageSources';
|
editablePackageSources = editablePackageSources';
|
||||||
|
|
|
@ -43,6 +43,7 @@ builtins.removeAttrs
|
||||||
in-list = callTest ./in-list { };
|
in-list = callTest ./in-list { };
|
||||||
cli = poetry2nix;
|
cli = poetry2nix;
|
||||||
path-deps = callTest ./path-deps { };
|
path-deps = callTest ./path-deps { };
|
||||||
|
path-deps-develop = callTest ./path-deps-develop { };
|
||||||
path-deps-level2 = callTest ./path-deps-level2 { };
|
path-deps-level2 = callTest ./path-deps-level2 { };
|
||||||
operators = callTest ./operators { };
|
operators = callTest ./operators { };
|
||||||
preferWheel = callTest ./prefer-wheel { };
|
preferWheel = callTest ./prefer-wheel { };
|
||||||
|
|
21
tests/path-deps-develop/default.nix
Normal file
21
tests/path-deps-develop/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{ lib, poetry2nix, python3, runCommand }:
|
||||||
|
|
||||||
|
let env = poetry2nix.mkPoetryEnv {
|
||||||
|
python = python3;
|
||||||
|
projectDir = ./.;
|
||||||
|
editablePackageSources = {
|
||||||
|
dep1 = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
lib.debug.runTests {
|
||||||
|
testDepFound = {
|
||||||
|
expected = "0\n";
|
||||||
|
expr = builtins.readFile (runCommand "path-deps-develop-import" { } ''
|
||||||
|
echo using ${env}
|
||||||
|
${env}/bin/python -c 'import dep1'
|
||||||
|
echo $? > $out
|
||||||
|
'');
|
||||||
|
};
|
||||||
|
}
|
0
tests/path-deps-develop/dep1/dep1/__init__.py
Normal file
0
tests/path-deps-develop/dep1/dep1/__init__.py
Normal file
6
tests/path-deps-develop/dep1/setup.py
Normal file
6
tests/path-deps-develop/dep1/setup.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="dep1",
|
||||||
|
packages=find_packages(),
|
||||||
|
)
|
20
tests/path-deps-develop/poetry.lock
generated
Normal file
20
tests/path-deps-develop/poetry.lock
generated
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
[[package]]
|
||||||
|
name = "dep1"
|
||||||
|
version = "0.0.0"
|
||||||
|
description = ""
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
develop = true
|
||||||
|
|
||||||
|
[package.source]
|
||||||
|
type = "directory"
|
||||||
|
url = "dep1"
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
lock-version = "1.1"
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
content-hash = "fda111f4898026d22d40f4d601bf3782b8ef7795da41cb780d59894a4732f8bc"
|
||||||
|
|
||||||
|
[metadata.files]
|
||||||
|
dep1 = []
|
15
tests/path-deps-develop/pyproject.toml
Normal file
15
tests/path-deps-develop/pyproject.toml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[tool.poetry]
|
||||||
|
name = "path_deps_develop"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["Your Name <you@example.com>"]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = ">=3.6"
|
||||||
|
dep1 = {path = "dep1", develop = true}
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
Loading…
Add table
Reference in a new issue