mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-05 17:21:39 -05:00
Respect subdirectory from poetry.lock when fetching sources
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
d70fd3ee09
commit
65ab8f0aab
5 changed files with 139 additions and 46 deletions
|
@ -178,54 +178,61 @@ pythonPackages.callPackage
|
|||
# Interpreters should declare what wheel types they're compatible with (python type + ABI)
|
||||
# Here we can then choose a file based on that info.
|
||||
src =
|
||||
if isGit then
|
||||
(
|
||||
builtins.fetchGit ({
|
||||
inherit (source) url;
|
||||
rev = source.resolved_reference or source.reference;
|
||||
ref = sourceSpec.branch or (if sourceSpec ? tag then "refs/tags/${sourceSpec.tag}" else "HEAD");
|
||||
} // (
|
||||
lib.optionalAttrs
|
||||
(((sourceSpec ? rev) || (sourceSpec ? branch) || (source ? resolved_reference) || (source ? reference))
|
||||
&& (lib.versionAtLeast builtins.nixVersion "2.4"))
|
||||
let
|
||||
srcRoot =
|
||||
if isGit then
|
||||
(
|
||||
builtins.fetchGit ({
|
||||
inherit (source) url;
|
||||
rev = source.resolved_reference or source.reference;
|
||||
ref = sourceSpec.branch or (if sourceSpec ? tag then "refs/tags/${sourceSpec.tag}" else "HEAD");
|
||||
} // (
|
||||
lib.optionalAttrs
|
||||
(((sourceSpec ? rev) || (sourceSpec ? branch) || (source ? resolved_reference) || (source ? reference))
|
||||
&& (lib.versionAtLeast builtins.nixVersion "2.4"))
|
||||
{
|
||||
allRefs = true;
|
||||
}) // (
|
||||
lib.optionalAttrs (lib.versionAtLeast builtins.nixVersion "2.4") {
|
||||
submodules = true;
|
||||
})
|
||||
)
|
||||
)
|
||||
else if isWheelUrl then
|
||||
builtins.fetchurl
|
||||
{
|
||||
allRefs = true;
|
||||
}) // (
|
||||
lib.optionalAttrs (lib.versionAtLeast builtins.nixVersion "2.4") {
|
||||
submodules = true;
|
||||
})
|
||||
)
|
||||
)
|
||||
else if isWheelUrl then
|
||||
builtins.fetchurl
|
||||
{
|
||||
inherit (source) url;
|
||||
sha256 = fileInfo.hash;
|
||||
}
|
||||
else if isUrl then
|
||||
builtins.fetchTarball
|
||||
{
|
||||
inherit (source) url;
|
||||
sha256 = fileInfo.hash;
|
||||
}
|
||||
else if isDirectory then
|
||||
(poetryLib.cleanPythonSources { src = localDepPath; })
|
||||
else if isFile then
|
||||
localDepPath
|
||||
else if isLegacy then
|
||||
fetchFromLegacy
|
||||
{
|
||||
pname = name;
|
||||
inherit python;
|
||||
inherit (fileInfo) file hash;
|
||||
inherit (source) url;
|
||||
}
|
||||
inherit (source) url;
|
||||
sha256 = fileInfo.hash;
|
||||
}
|
||||
else if isUrl then
|
||||
builtins.fetchTarball
|
||||
{
|
||||
inherit (source) url;
|
||||
sha256 = fileInfo.hash;
|
||||
}
|
||||
else if isDirectory then
|
||||
(poetryLib.cleanPythonSources { src = localDepPath; })
|
||||
else if isFile then
|
||||
localDepPath
|
||||
else if isLegacy then
|
||||
fetchFromLegacy
|
||||
{
|
||||
pname = name;
|
||||
inherit python;
|
||||
inherit (fileInfo) file hash;
|
||||
inherit (source) url;
|
||||
}
|
||||
else
|
||||
fetchFromPypi {
|
||||
pname = name;
|
||||
inherit (fileInfo) file hash kind;
|
||||
inherit version;
|
||||
};
|
||||
in
|
||||
if source ? subdirectory then
|
||||
srcRoot + "/${source.subdirectory}"
|
||||
else
|
||||
fetchFromPypi {
|
||||
pname = name;
|
||||
inherit (fileInfo) file hash kind;
|
||||
inherit version;
|
||||
};
|
||||
srcRoot;
|
||||
}
|
||||
)
|
||||
{ }
|
||||
|
|
|
@ -141,6 +141,7 @@ in
|
|||
contourpy-no-wheel = callTest ./contourpy-no-wheel { };
|
||||
pytesseract = callTest ./pytesseract { };
|
||||
sphinx5 = callTest ./sphinx5 { };
|
||||
subdirectory = callTest ./subdirectory { };
|
||||
} // lib.optionalAttrs (!stdenv.isDarwin) {
|
||||
# Test deadlocks on darwin, sandboxing issue?
|
||||
dependency-environment = callTest ./dependency-environment { };
|
||||
|
|
14
tests/subdirectory/default.nix
Normal file
14
tests/subdirectory/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ lib, poetry2nix, postgresql_14, runCommandCC, stdenv }:
|
||||
|
||||
let env = poetry2nix.mkPoetryEnv { projectDir = ./.; };
|
||||
in if stdenv.isDarwin then
|
||||
env
|
||||
else
|
||||
runCommandCC "subdirectory-test"
|
||||
{
|
||||
PSYCOPG_IMPL = "python";
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath [ postgresql_14 ];
|
||||
} ''
|
||||
'${env}/bin/python' -c 'import psycopg'
|
||||
touch "$out"
|
||||
''
|
58
tests/subdirectory/poetry.lock
generated
Normal file
58
tests/subdirectory/poetry.lock
generated
Normal file
|
@ -0,0 +1,58 @@
|
|||
# This file is automatically @generated by Poetry and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "psycopg"
|
||||
version = "3.1.10"
|
||||
description = "PostgreSQL database adapter for Python"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = []
|
||||
develop = false
|
||||
|
||||
[package.dependencies]
|
||||
typing-extensions = ">=4.1"
|
||||
tzdata = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
|
||||
[package.extras]
|
||||
binary = ["psycopg-binary (==3.1.10)"]
|
||||
c = ["psycopg-c (==3.1.10)"]
|
||||
dev = ["black (>=23.1.0)", "dnspython (>=2.1)", "flake8 (>=4.0)", "mypy (>=1.4.1)", "types-setuptools (>=57.4)", "wheel (>=0.37)"]
|
||||
docs = ["Sphinx (>=5.0)", "furo (==2022.6.21)", "sphinx-autobuild (>=2021.3.14)", "sphinx-autodoc-typehints (>=1.12)"]
|
||||
pool = ["psycopg-pool"]
|
||||
test = ["anyio (>=3.6.2)", "mypy (>=1.4.1)", "pproxy (>=2.7)", "pytest (>=6.2.5)", "pytest-cov (>=3.0)", "pytest-randomly (>=3.5)"]
|
||||
|
||||
[package.source]
|
||||
type = "git"
|
||||
url = "https://github.com/psycopg/psycopg.git"
|
||||
reference = "3.1.10"
|
||||
resolved_reference = "8d2ba2d7587116b65911cdccdf24af0413f17865"
|
||||
subdirectory = "psycopg"
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.7.1"
|
||||
description = "Backported and Experimental Type Hints for Python 3.7+"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"},
|
||||
{file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tzdata"
|
||||
version = "2023.3"
|
||||
description = "Provider of IANA time zone data"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2"
|
||||
files = [
|
||||
{file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"},
|
||||
{file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "57aea2a6ff62c054b7524aaf8ace8a91628f19986f8076ff0fc42f651c45b595"
|
13
tests/subdirectory/pyproject.toml
Normal file
13
tests/subdirectory/pyproject.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[tool.poetry]
|
||||
name = "subdirectory-test"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = []
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
psycopg = {git = "https://github.com/psycopg/psycopg.git", rev = "3.1.10", subdirectory = "psycopg"}
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Loading…
Add table
Reference in a new issue