Loading pkgs/development/tools/poetry2nix/poetry2nix/default.nix +6 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ }: let # Poetry2nix version version = "1.21.0"; version = "1.22.0"; inherit (poetryLib) isCompatible readTOML moduleName; Loading Loading @@ -211,7 +211,7 @@ lib.makeScope pkgs.newScope (self: { __toPluginAble = toPluginAble self; inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook wheelUnpackHook; inherit (hooks) pipBuildHook removePathDependenciesHook removeGitDependenciesHook poetry2nixFixupHook wheelUnpackHook; } // lib.optionalAttrs (! super ? setuptools-scm) { # The canonical name is setuptools-scm setuptools-scm = super.setuptools_scm; Loading Loading @@ -313,7 +313,10 @@ lib.makeScope pkgs.newScope (self: { app = py.pkgs.buildPythonPackage ( passedAttrs // inputAttrs // { nativeBuildInputs = inputAttrs.nativeBuildInputs ++ [ py.pkgs.removePathDependenciesHook ]; nativeBuildInputs = inputAttrs.nativeBuildInputs ++ [ py.pkgs.removePathDependenciesHook py.pkgs.removeGitDependenciesHook ]; } // { pname = moduleName pyProject.tool.poetry.name; version = pyProject.tool.poetry.version; Loading pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix +21 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,28 @@ in substitutions = { inherit pythonInterpreter; yj = "${buildPackages.yj}/bin/yj"; pyprojectPatchScript = "${./pyproject-without-path.py}"; pyprojectPatchScript = "${./pyproject-without-special-deps.py}"; fields = [ "path" ]; kind = "path"; }; } ./remove-path-dependencies.sh } ./remove-special-dependencies.sh ) { }; removeGitDependenciesHook = callPackage ({}: makeSetupHook { name = "remove-git-dependencies.sh"; deps = [ ]; substitutions = { inherit pythonInterpreter; yj = "${buildPackages.yj}/bin/yj"; pyprojectPatchScript = "${./pyproject-without-special-deps.py}"; fields = [ "git" "branch" "rev" "tag" ]; kind = "git"; }; } ./remove-special-dependencies.sh ) { }; Loading pkgs/development/tools/poetry2nix/poetry2nix/hooks/pyproject-without-path.pydeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line #!/usr/bin/env python # Patch out path dependencies from a pyproject.json file import json import sys data = json.load(sys.stdin) def get_deep(o, path): for p in path.split('.'): o = o.get(p, {}) return o for dep in get_deep(data, 'tool.poetry.dependencies').values(): if isinstance(dep, dict): try: del dep['path']; except KeyError: pass else: dep['version'] = '*' json.dump(data, sys.stdout, indent=4) pkgs/development/tools/poetry2nix/poetry2nix/hooks/pyproject-without-special-deps.py 0 → 100644 +52 −0 Original line number Diff line number Diff line #!/usr/bin/env python # Patch out special dependencies (git and path) from a pyproject.json file import argparse import json import sys def main(input, output, fields_to_remove): data = json.load(input) try: deps = data["tool"]["poetry"]["dependencies"] except KeyError: pass else: for dep in deps.values(): if isinstance(dep, dict): any_removed = False for field in fields_to_remove: any_removed |= dep.pop(field, None) is not None if any_removed: dep["version"] = "*" json.dump(data, output, separators=(",", ":")) if __name__ == "__main__": p = argparse.ArgumentParser() p.add_argument( "-i", "--input", type=argparse.FileType("r"), default=sys.stdin, help="Location from which to read input JSON", ) p.add_argument( "-o", "--output", type=argparse.FileType("w"), default=sys.stdout, help="Location to write output JSON", ) p.add_argument( "-f", "--fields-to-remove", nargs="+", help="The fields to remove from the dependency's JSON", ) args = p.parse_args() main(args.input, args.output, args.fields_to_remove) pkgs/development/tools/poetry2nix/poetry2nix/hooks/remove-path-dependencies.shdeleted 100644 → 0 +0 −12 Original line number Diff line number Diff line remove-path-dependencies-hook() { if ! test -f pyproject.toml; then return fi # Tell poetry not to resolve the path dependencies. Any version is fine! @yj@ -tj < pyproject.toml | @pythonInterpreter@ @pyprojectPatchScript@ > pyproject.json @yj@ -jt < pyproject.json > pyproject.toml rm pyproject.json } postPatchHooks+=(remove-path-dependencies-hook) Loading
pkgs/development/tools/poetry2nix/poetry2nix/default.nix +6 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ }: let # Poetry2nix version version = "1.21.0"; version = "1.22.0"; inherit (poetryLib) isCompatible readTOML moduleName; Loading Loading @@ -211,7 +211,7 @@ lib.makeScope pkgs.newScope (self: { __toPluginAble = toPluginAble self; inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook wheelUnpackHook; inherit (hooks) pipBuildHook removePathDependenciesHook removeGitDependenciesHook poetry2nixFixupHook wheelUnpackHook; } // lib.optionalAttrs (! super ? setuptools-scm) { # The canonical name is setuptools-scm setuptools-scm = super.setuptools_scm; Loading Loading @@ -313,7 +313,10 @@ lib.makeScope pkgs.newScope (self: { app = py.pkgs.buildPythonPackage ( passedAttrs // inputAttrs // { nativeBuildInputs = inputAttrs.nativeBuildInputs ++ [ py.pkgs.removePathDependenciesHook ]; nativeBuildInputs = inputAttrs.nativeBuildInputs ++ [ py.pkgs.removePathDependenciesHook py.pkgs.removeGitDependenciesHook ]; } // { pname = moduleName pyProject.tool.poetry.name; version = pyProject.tool.poetry.version; Loading
pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix +21 −2 Original line number Diff line number Diff line Loading @@ -21,9 +21,28 @@ in substitutions = { inherit pythonInterpreter; yj = "${buildPackages.yj}/bin/yj"; pyprojectPatchScript = "${./pyproject-without-path.py}"; pyprojectPatchScript = "${./pyproject-without-special-deps.py}"; fields = [ "path" ]; kind = "path"; }; } ./remove-path-dependencies.sh } ./remove-special-dependencies.sh ) { }; removeGitDependenciesHook = callPackage ({}: makeSetupHook { name = "remove-git-dependencies.sh"; deps = [ ]; substitutions = { inherit pythonInterpreter; yj = "${buildPackages.yj}/bin/yj"; pyprojectPatchScript = "${./pyproject-without-special-deps.py}"; fields = [ "git" "branch" "rev" "tag" ]; kind = "git"; }; } ./remove-special-dependencies.sh ) { }; Loading
pkgs/development/tools/poetry2nix/poetry2nix/hooks/pyproject-without-path.pydeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line #!/usr/bin/env python # Patch out path dependencies from a pyproject.json file import json import sys data = json.load(sys.stdin) def get_deep(o, path): for p in path.split('.'): o = o.get(p, {}) return o for dep in get_deep(data, 'tool.poetry.dependencies').values(): if isinstance(dep, dict): try: del dep['path']; except KeyError: pass else: dep['version'] = '*' json.dump(data, sys.stdout, indent=4)
pkgs/development/tools/poetry2nix/poetry2nix/hooks/pyproject-without-special-deps.py 0 → 100644 +52 −0 Original line number Diff line number Diff line #!/usr/bin/env python # Patch out special dependencies (git and path) from a pyproject.json file import argparse import json import sys def main(input, output, fields_to_remove): data = json.load(input) try: deps = data["tool"]["poetry"]["dependencies"] except KeyError: pass else: for dep in deps.values(): if isinstance(dep, dict): any_removed = False for field in fields_to_remove: any_removed |= dep.pop(field, None) is not None if any_removed: dep["version"] = "*" json.dump(data, output, separators=(",", ":")) if __name__ == "__main__": p = argparse.ArgumentParser() p.add_argument( "-i", "--input", type=argparse.FileType("r"), default=sys.stdin, help="Location from which to read input JSON", ) p.add_argument( "-o", "--output", type=argparse.FileType("w"), default=sys.stdout, help="Location to write output JSON", ) p.add_argument( "-f", "--fields-to-remove", nargs="+", help="The fields to remove from the dependency's JSON", ) args = p.parse_args() main(args.input, args.output, args.fields_to_remove)
pkgs/development/tools/poetry2nix/poetry2nix/hooks/remove-path-dependencies.shdeleted 100644 → 0 +0 −12 Original line number Diff line number Diff line remove-path-dependencies-hook() { if ! test -f pyproject.toml; then return fi # Tell poetry not to resolve the path dependencies. Any version is fine! @yj@ -tj < pyproject.toml | @pythonInterpreter@ @pyprojectPatchScript@ > pyproject.json @yj@ -jt < pyproject.json > pyproject.toml rm pyproject.json } postPatchHooks+=(remove-path-dependencies-hook)