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 pyproject = true; 21 22 src = fetchFromGitHub { 23 owner = "dolfinus"; 24 repo = "setuptools-git-versioning"; 25 tag = "v${version}"; 26 hash = "sha256-Slf6tq83LajdTnr98SuCiFIdm/6auzftnARLAOBgyng="; 27 }; 28 29 postPatch = '' 30 # Because the .git dir is missing, it falls back to using version 0.0.1 31 # Instead we use the version specified in the derivation 32 substituteInPlace setup.py --replace-fail \ 33 'version=version_from_git(root=here, dev_template="{tag}.post{ccount}")' \ 34 "version='${version}'" 35 ''; 36 37 build-system = [ 38 setuptools 39 ]; 40 41 dependencies = [ 42 packaging 43 setuptools 44 ] 45 ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 46 47 pythonImportsCheck = [ "setuptools_git_versioning" ]; 48 49 nativeCheckInputs = [ 50 build 51 coverage 52 git 53 pytestCheckHook 54 pytest-rerunfailures 55 toml 56 ]; 57 58 preCheck = '' 59 # so that its built binary is accessible by tests 60 export PATH="$out/bin:$PATH" 61 ''; 62 63 # limit tests because the full suite takes several minutes to run 64 enabledTestMarks = [ 65 "important" 66 ]; 67 68 disabledTests = [ 69 # runs an isolated build that uses internet to download dependencies 70 "test_config_not_used" 71 ]; 72 73 meta = with lib; { 74 description = "Use git repo data (latest tag, current commit hash, etc) for building a version number according PEP-440"; 75 mainProgram = "setuptools-git-versioning"; 76 homepage = "https://github.com/dolfinus/setuptools-git-versioning"; 77 changelog = "https://github.com/dolfinus/setuptools-git-versioning/blob/${src.rev}/CHANGELOG.rst"; 78 license = licenses.mit; 79 maintainers = with maintainers; [ tjni ]; 80 }; 81}