summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/hooks/pypa-build-hook-test.nix
blob: 4153c21ca4f97e0fed334b2c4e7f4e74b77ca76c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ pythonOnBuildForHost, runCommand }: {
  dont-propagate-conflicting-deps = let
    # customize a package so that its store paths differs
    mkConflict = pkg: pkg.overrideAttrs { some_modification = true; };
    # minimal pyproject.toml for the example project
    pyprojectToml = builtins.toFile "pyproject.toml" ''
      [project]
      name = "my-project"
      version = "1.0.0"
    '';
    # the source of the example project
    projectSource = runCommand "my-project-source" {} ''
      mkdir -p $out/src
      cp ${pyprojectToml} $out/pyproject.toml
      touch $out/src/__init__.py
    '';
    in
    # this build must never triger conflicts
    pythonOnBuildForHost.pkgs.buildPythonPackage {
      pname = "dont-propagate-conflicting-deps";
      version = "0.0.0";
      src = projectSource;
      format = "pyproject";
      propagatedBuildInputs = [
        # At least one dependency of `build` should be included here to
        # keep the test meaningful
        (mkConflict pythonOnBuildForHost.pkgs.tomli)
        # setuptools is also needed to build the example project
        pythonOnBuildForHost.pkgs.setuptools
      ];
    };
}