Skip to content

Commit

Permalink
Fix: url-specified source packages
Browse files Browse the repository at this point in the history
This fixes #1695
where the wrong hash (unpacked vs .tar.gz-file-hash) was used.
  • Loading branch information
TyberiusPrime committed Jun 11, 2024
1 parent 304f823 commit 51f5d09
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mk-poetry-dep.nix
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ pythonPackages.callPackage
sha256 = fileInfo.hash;
}
else if isUrl then
builtins.fetchTarball
builtins.fetchurl
{
inherit (source) url;
sha256 = fileInfo.hash;
Expand Down
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ in
mysqlclient = callTest ./mysqlclient { };
jq = callTest ./jq { };
ubersmith = callTest ./ubersmith { };
use-url-src = callTest ./use-url-src { };
use-url-wheel = callTest ./use-url-wheel { };
returns = callTest ./returns { };
option = callTest ./option { };
Expand Down
18 changes: 18 additions & 0 deletions tests/use-url-src/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ lib, poetry2nix, python3, stdenv }:
let
args = {
python = python3;
projectDir = ./.;
preferWheels = true;
};
py = poetry2nix.mkPoetryPackages args;
app = poetry2nix.mkPoetryApplication args;
url_nix_store = py.python.pkgs.requests.src;
url_is_wheel = url_nix_store.isWheel or false;
is_wheel_attr_test = x: lib.warnIf (!stdenv.isLinux && url_is_wheel)
"url should resolve to a not wheel"
x;
is_wheel_test = x: assert lib.strings.hasSuffix "tar.gz" url_nix_store; x;
app_builds = x: assert lib.isDerivation app; x;
in
lib.pipe app [ is_wheel_attr_test is_wheel_test app_builds ]
153 changes: 153 additions & 0 deletions tests/use-url-src/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/use-url-src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "use-url-src"
version = "0.1.0"
description = "asserts that .tar.gz via .url works"
authors = [
"tyberius prime <tyberius_prime@coonabibba.de>"
]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.10"
requests = {url = "https://files.pythonhosted.org/packages/63/70/2bf7780ad2d390a8d301ad0b550f1581eadbd9a20f896afe06353c2a2913/requests-2.32.3.tar.gz"}


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"


6 changes: 6 additions & 0 deletions tests/use-url-src/use_url_src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import requests
import sys


def main():
pass

0 comments on commit 51f5d09

Please sign in to comment.