1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 build,
6 coverage,
7 git,
8 packaging,
9 pytestCheckHook,
10 pytest-rerunfailures,
11 pythonOlder,
12 setuptools,
13 toml,
14 wheel,
15}:
16
17buildPythonPackage rec {
18 pname = "setuptools-git-versioning";
19 version = "2.0.0";
20 format = "pyproject";
21
22 src = fetchFromGitHub {
23 owner = "dolfinus";
24 repo = "setuptools-git-versioning";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-xugK/JOVA53nCK8bB0gPkhIREmy0+/OthsydfYRCYno=";
27 };
28
29 nativeBuildInputs = [
30 setuptools
31 wheel
32 ];
33
34 propagatedBuildInputs = [
35 packaging
36 setuptools
37 ] ++ lib.optionals (pythonOlder "3.11") [ toml ];
38
39 pythonImportsCheck = [ "setuptools_git_versioning" ];
40
41 nativeCheckInputs = [
42 build
43 coverage
44 git
45 pytestCheckHook
46 pytest-rerunfailures
47 toml
48 ];
49
50 preCheck = ''
51 # so that its built binary is accessible by tests
52 export PATH="$out/bin:$PATH"
53 '';
54
55 # limit tests because the full suite takes several minutes to run
56 pytestFlagsArray = [
57 "-m"
58 "important"
59 ];
60
61 disabledTests = [
62 # runs an isolated build that uses internet to download dependencies
63 "test_config_not_used"
64 ];
65
66 meta = with lib; {
67 description = "Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP-440";
68 mainProgram = "setuptools-git-versioning";
69 homepage = "https://github.com/dolfinus/setuptools-git-versioning";
70 changelog = "https://github.com/dolfinus/setuptools-git-versioning/blob/${src.rev}/CHANGELOG.rst";
71 license = licenses.mit;
72 maintainers = with maintainers; [ tjni ];
73 };
74}