diff --git a/packages/build-support/drv-parts/backends/buildPythonPackage/implementation.nix b/packages/build-support/drv-parts/backends/buildPythonPackage/implementation.nix index 562a308..cc747c4 100644 --- a/packages/build-support/drv-parts/backends/buildPythonPackage/implementation.nix +++ b/packages/build-support/drv-parts/backends/buildPythonPackage/implementation.nix @@ -9,9 +9,19 @@ let "flit" "wheel" ]; + + hasPyproject = config.format == "pyproject" && config.pyprojectToml != null; + + pyproject = if hasPyproject then + lib.importTOML config.pyprojectToml + else + null; in { + pname = lib.mkIf hasPyproject (lib.mkDefault pyproject.tool.poetry.name); + version = lib.mkIf hasPyproject (lib.mkDefault pyproject.tool.poetry.version); + deps = { pkgs, python3Packages, ... }: { inherit (python3Packages) python diff --git a/packages/build-support/drv-parts/backends/buildPythonPackage/interface.nix b/packages/build-support/drv-parts/backends/buildPythonPackage/interface.nix index 8f31ddf..1801d8b 100644 --- a/packages/build-support/drv-parts/backends/buildPythonPackage/interface.nix +++ b/packages/build-support/drv-parts/backends/buildPythonPackage/interface.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ config, lib, ... }: with lib; let @@ -19,6 +19,15 @@ in "wheel" "other" ]; + default = if config.pyprojectToml != null then "pyproject" else "setuptools"; + defaultText = '' + "pyproject" if pyprojectToml is set, otherwise "setuptools". + ''; + }; + pyprojectToml = mkOption { + description = "pyproject.toml file used for extracting package metadata"; + type = with types; nullOr path; + default = null; }; catchConflicts = flag true "If true, abort package build if a package name appears more than once in dependency tree."; dontWrapPythonPrograms = flag false "Skip wrapping of Python programs.";