mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 08:41:42 -05:00
Add support for eggs
This commit is contained in:
parent
c81412189e
commit
cebf3ced84
8 changed files with 94 additions and 9 deletions
|
@ -1,4 +1,5 @@
|
|||
[
|
||||
"egg",
|
||||
"tar",
|
||||
"tar.bz2",
|
||||
"tar.gz",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3Packages.poetry
|
||||
#! nix-shell -i python3 -p python3 poetry
|
||||
|
||||
# Run code generation used by poetry2nix
|
||||
|
||||
|
@ -10,5 +10,6 @@ EXT_FILE = 'extensions.json'
|
|||
|
||||
if __name__ == '__main__':
|
||||
with open(EXT_FILE, 'w') as f:
|
||||
ext = sorted(ext.lstrip('.') for ext in SUPPORTED_EXTENSIONS)
|
||||
f.write(json.dumps(ext, indent=2))
|
||||
ext = set(ext.lstrip('.') for ext in SUPPORTED_EXTENSIONS)
|
||||
ext.add('egg')
|
||||
f.write(json.dumps(sorted(ext), indent=2) + '\n')
|
||||
|
|
|
@ -30,8 +30,9 @@
|
|||
supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")");
|
||||
matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null;
|
||||
hasSupportedExtension = fname: builtins.match supportedRegex fname != null;
|
||||
isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname;
|
||||
in
|
||||
builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file) files;
|
||||
builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files;
|
||||
|
||||
toPath = s: pwd + "/${s}";
|
||||
|
||||
|
@ -48,19 +49,33 @@
|
|||
|
||||
fileInfo = let
|
||||
isBdist = f: lib.strings.hasSuffix "whl" f.file;
|
||||
isSdist = f: ! isBdist f;
|
||||
isSdist = f: ! isBdist f && ! isEgg f;
|
||||
isEgg = f: lib.strings.hasSuffix ".egg" f.file;
|
||||
|
||||
binaryDist = selectWheel fileCandidates;
|
||||
sourceDist = builtins.filter isSdist fileCandidates;
|
||||
lockFileEntry = if (builtins.length sourceDist) > 0 then builtins.head sourceDist else builtins.head binaryDist;
|
||||
eggs = builtins.filter isEgg fileCandidates;
|
||||
|
||||
lockFileEntry = builtins.head (sourceDist ++ binaryDist ++ eggs);
|
||||
|
||||
_isEgg = isEgg lockFileEntry;
|
||||
|
||||
in
|
||||
rec {
|
||||
inherit (lockFileEntry) file hash;
|
||||
name = file;
|
||||
format = if lib.strings.hasSuffix ".whl" name then "wheel" else "setuptools";
|
||||
kind = if format == "setuptools" then "source" else (builtins.elemAt (lib.strings.splitString "-" name) 2);
|
||||
format =
|
||||
if _isEgg then "egg"
|
||||
else if lib.strings.hasSuffix ".whl" name then "wheel"
|
||||
else "setuptools";
|
||||
kind =
|
||||
if _isEgg then python.pythonVersion
|
||||
else if format == "setuptools" then "source"
|
||||
else (builtins.elemAt (lib.strings.splitString "-" name) 2);
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
buildPythonPackage {
|
||||
pname = name;
|
||||
version = version;
|
||||
|
|
|
@ -21,6 +21,9 @@ in
|
|||
cli = poetry2nix;
|
||||
path-deps = pkgs.callPackage ./path-deps { inherit poetry2nix; };
|
||||
|
||||
# Egg support not yet in channel, uncomment when channel progressed
|
||||
# eggs = pkgs.callPackage ./eggs { inherit poetry2nix; };
|
||||
|
||||
inherit (poetry2nix) doc;
|
||||
|
||||
# manylinux requires nixpkgs with https://github.com/NixOS/nixpkgs/pull/75763
|
||||
|
|
14
tests/eggs/default.nix
Normal file
14
tests/eggs/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ lib, poetry2nix, python3, runCommandNoCC }:
|
||||
let
|
||||
drv = poetry2nix.mkPoetryApplication {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetrylock = ./poetry.lock;
|
||||
src = lib.cleanSource ./.;
|
||||
};
|
||||
|
||||
in
|
||||
runCommandNoCC "egg-test" {} ''
|
||||
${drv}/bin/egg-test
|
||||
touch $out
|
||||
''
|
9
tests/eggs/eggs.py
Normal file
9
tests/eggs/eggs.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import pyasn1
|
||||
|
||||
|
||||
def main():
|
||||
print("egg-test")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
26
tests/eggs/poetry.lock
generated
Normal file
26
tests/eggs/poetry.lock
generated
Normal file
|
@ -0,0 +1,26 @@
|
|||
[[package]]
|
||||
category = "main"
|
||||
description = "ASN.1 types and codecs"
|
||||
name = "pyasn1"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "0.4.8"
|
||||
|
||||
[metadata]
|
||||
content-hash = "298cfae3c2c9739a70741fb47853558fcdda285eb1d561fedf8a36b79d3f64f1"
|
||||
python-versions = "^3.6"
|
||||
|
||||
[metadata.files]
|
||||
pyasn1 = [
|
||||
{file = "pyasn1-0.4.8-py2.4.egg", hash = "sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"},
|
||||
{file = "pyasn1-0.4.8-py2.5.egg", hash = "sha256:0458773cfe65b153891ac249bcf1b5f8f320b7c2ce462151f8fa74de8934becf"},
|
||||
{file = "pyasn1-0.4.8-py2.6.egg", hash = "sha256:5c9414dcfede6e441f7e8f81b43b34e834731003427e5b09e4e00e3172a10f00"},
|
||||
{file = "pyasn1-0.4.8-py2.7.egg", hash = "sha256:6e7545f1a61025a4e58bb336952c5061697da694db1cae97b116e9c46abcf7c8"},
|
||||
{file = "pyasn1-0.4.8-py3.1.egg", hash = "sha256:78fa6da68ed2727915c4767bb386ab32cdba863caa7dbe473eaae45f9959da86"},
|
||||
{file = "pyasn1-0.4.8-py3.2.egg", hash = "sha256:08c3c53b75eaa48d71cf8c710312316392ed40899cb34710d092e96745a358b7"},
|
||||
{file = "pyasn1-0.4.8-py3.3.egg", hash = "sha256:03840c999ba71680a131cfaee6fab142e1ed9bbd9c693e285cc6aca0d555e576"},
|
||||
{file = "pyasn1-0.4.8-py3.4.egg", hash = "sha256:7ab8a544af125fb704feadb008c99a88805126fb525280b2270bb25cc1d78a12"},
|
||||
{file = "pyasn1-0.4.8-py3.5.egg", hash = "sha256:e89bf84b5437b532b0803ba5c9a5e054d21fec423a89952a74f87fa2c9b7bce2"},
|
||||
{file = "pyasn1-0.4.8-py3.6.egg", hash = "sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359"},
|
||||
{file = "pyasn1-0.4.8-py3.7.egg", hash = "sha256:99fcc3c8d804d1bc6d9a099921e39d827026409a58f2a720dcdb89374ea0c776"},
|
||||
]
|
16
tests/eggs/pyproject.toml
Normal file
16
tests/eggs/pyproject.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[tool.poetry]
|
||||
name = "eggs"
|
||||
version = "0.1.0"
|
||||
description = "poetry2nix test"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.6"
|
||||
pyasn1 = "^0.4.8"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
egg-test = "eggs:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.masonry.api"
|
Loading…
Add table
Reference in a new issue