at master 1.3 kB view raw
1{ 2 buildPythonPackage, 3 lib, 4 hatchling, 5}: 6{ 7 pname, 8 version, 9 dependencies ? [ ], 10 optional-dependencies ? { }, 11 passthru ? { }, 12 meta ? { }, 13}: 14 15# Create a "fake" meta package to satisfy a dependency on a package, but don't actually build it. 16# This is useful for packages that have a split binary/source dichotomy like psycopg2/psycopg2-binary, 17# where we want to use the former, but some projects declare a dependency on the latter. 18 19buildPythonPackage { 20 inherit 21 pname 22 version 23 dependencies 24 optional-dependencies 25 meta 26 passthru 27 ; 28 29 pyproject = true; 30 31 # Make a minimal pyproject.toml that can be built 32 unpackPhase = '' 33 cat > pyproject.toml << EOF 34 [project] 35 name = "${pname}" 36 version = "${version}" 37 dependencies = ${builtins.toJSON (map lib.getName dependencies)} 38 39 [project.optional-dependencies] 40 ${lib.optionalString (optional-dependencies != { }) ( 41 (lib.concatStringsSep "\n" ( 42 lib.mapAttrsToList ( 43 group: deps: group + " = " + builtins.toJSON (map lib.getName deps) 44 ) optional-dependencies 45 )) 46 )} 47 48 [tool.hatch.build.targets.wheel] 49 bypass-selection = true 50 51 [build-system] 52 requires = ["hatchling"] 53 build-backend = "hatchling.build" 54 EOF 55 ''; 56 57 build-system = [ hatchling ]; 58}