Skip to content

Commit c3dfd93

Browse files
Vipitisalmarklein
andauthored
detect submodules as repo (#5)
Co-authored-by: Almar Klein <almar@almarklein.org>
1 parent ab723a3 commit c3dfd93

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The "installation":
1818

1919
* Add the `_version.py` to the root of your library (next to the `__init__.py`).
2020
* Set the project name and `__version__` string.
21-
* In your `__init__.py`, use `from _version import __version__, version_info`.
21+
* In your `__init__.py`, use `from ._version import __version__, version_info`.
2222
* In `pyproject.toml` use `dynamic = ["version"]`.
2323
* The Flit build tool will now detect your project version. Other tools may
2424
need an extra line, e.g. `[tool.hatch.version]` `path = "lib_name/_version.py"`.

_version.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
_version.py v1.2
2+
_version.py v1.3
33
44
Simple version string management, using a hard-coded version string
55
for simplicity and compatibility, while adding git info at runtime.
@@ -30,8 +30,9 @@
3030
logger = logging.getLogger(project_name)
3131

3232
# Get whether this is a repo. If so, repo_dir is the path, otherwise None.
33+
# .git is a dir in a normal repo and a file when in a submodule.
3334
repo_dir = Path(__file__).parents[1]
34-
repo_dir = repo_dir if repo_dir.joinpath(".git").is_dir() else None
35+
repo_dir = repo_dir if repo_dir.joinpath(".git").exists() else None
3536

3637

3738
def get_version():

0 commit comments

Comments
 (0)