pip: add test can-build-setuptools

to ensure that a setuptools dependency doesn't raise a collision
This commit is contained in:
DavHau 2024-01-07 19:57:57 +07:00 committed by mergify[bot]
parent a6837ba21e
commit 935df57a46
5 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,42 @@
# An example package with dependencies defined via pyproject.toml
{
config,
lib,
dream2nix,
...
}: let
pyproject = lib.importTOML (config.mkDerivation.src + /pyproject.toml);
in {
imports = [
dream2nix.modules.dream2nix.pip
];
deps = {nixpkgs, ...}: {
python = nixpkgs.python310;
};
inherit (pyproject.project) name version;
mkDerivation = {
src = ./.;
propagatedBuildInputs = [
config.pip.drvs.setuptools.public
];
};
buildPythonPackage = {
format = lib.mkForce "pyproject";
pythonImportsCheck = [
"my_tool"
];
};
pip = {
pypiSnapshotDate = "2023-08-27";
requirementsList =
pyproject.build-system.requires
or []
++ pyproject.project.dependencies;
flattenDependencies = true;
};
}

View File

@ -0,0 +1,32 @@
{
description = "My flake with dream2nix packages";
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
};
outputs = inputs @ {
self,
dream2nix,
nixpkgs,
...
}: let
system = "x86_64-linux";
in {
# All packages defined in ./packages/<name> are automatically added to the flake outputs
# e.g., 'packages/hello/default.nix' becomes '.#packages.hello'
packages.${system}.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system};
modules = [
./default.nix
{
paths.projectRoot = ./.;
# can be changed to ".git" or "flake.nix" to get rid of .project-root
paths.projectRootFile = "flake.nix";
paths.package = ./.;
}
];
};
};
}

View File

@ -0,0 +1,18 @@
{
"fetchPipMetadata": {
"sources": {
"setuptools": {
"sha256": "3d8083eed2d13afc9426f227b24fd1659489ec107c0e86cec2ffdde5c92e790b",
"type": "url",
"url": "https://files.pythonhosted.org/packages/4f/ab/0bcfebdfc3bfa8554b2b2c97a555569c4c1ebc74ea288741ea8326c51906/setuptools-68.1.2-py3-none-any.whl",
"version": "68.1.2"
}
},
"targets": {
"default": {
"setuptools": []
}
}
},
"invalidationHash": "6be3a43e2b4f000cc9324bfc4eacca5646d482d679a78865167b72f0291a3c63"
}

View File

@ -0,0 +1,9 @@
from setuptools import setup
def main():
print("Hello World!")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,14 @@
[build-system]
requires = [ "setuptools" ]
build-backend = "setuptools.build_meta"
[project]
name = "my-tool"
description = "my tool"
version = "1.0.0"
dependencies = [
"setuptools"
]
[project.scripts]
my-tool = "my_tool:main"