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 tomli,
15}:
16
17buildPythonPackage rec {
18 pname = "setuptools-git-versioning";
19 version = "2.1.0";
20 format = "pyproject";
21
22 src = fetchFromGitHub {
23 owner = "dolfinus";
24 repo = "setuptools-git-versioning";
25 tag = "v${version}";
26 hash = "sha256-Slf6tq83LajdTnr98SuCiFIdm/6auzftnARLAOBgyng=";
27 };
28
29 build-system = [
30 setuptools
31 ];
32
33 dependencies = [
34 packaging
35 setuptools
36 ]
37 ++ lib.optionals (pythonOlder "3.11") [ tomli ];
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 enabledTestMarks = [
57 "important"
58 ];
59
60 disabledTests = [
61 # runs an isolated build that uses internet to download dependencies
62 "test_config_not_used"
63 ];
64
65 meta = with lib; {
66 description = "Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP-440";
67 mainProgram = "setuptools-git-versioning";
68 homepage = "https://github.com/dolfinus/setuptools-git-versioning";
69 changelog = "https://github.com/dolfinus/setuptools-git-versioning/blob/${src.rev}/CHANGELOG.rst";
70 license = licenses.mit;
71 maintainers = with maintainers; [ tjni ];
72 };
73}