diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..28a13ef --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "GitPython"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 6d1d42c..a602c7a 100644 --- a/setup.py +++ b/setup.py @@ -8,11 +8,21 @@ def git_version(version): """Return version with local version identifier.""" import git - repo = git.Repo('.git') + + try: + repo = git.Repo('.git') + except git.NoSuchPathError: + # Not in a git repo, assume install through PyPI / source distribution + return version + repo.git.status() # assert versions are increasing - latest_tag = repo.git.describe( - match='v[0-9]*', tags=True, abbrev=0) + try: + latest_tag = repo.git.describe( + match='v[0-9]*', tags=True, abbrev=0) + except git.exc.GitCommandError: + # No tags found + latest_tag = version assert parse_version(latest_tag) <= parse_version(version), ( latest_tag, version) sha = repo.head.commit.hexsha[:8]