Skip to content

Commit 614f54b

Browse files
authored
Merge pull request #90 from jwodder/gh-89
Don't run onbuild step for editable builds with Hatch
2 parents 55946c8 + 371f3fd commit 614f54b

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
v3.2.0 (in development)
1+
v3.1.2 (in development)
22
-----------------------
33
- Drop support for Python 3.7
4+
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
5+
step for editable builds
46

57
v3.1.1 (2024-04-29)
68
-------------------

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Changelog
66
v3.2.0 (in development)
77
-----------------------
88
- Drop support for Python 3.7
9+
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
10+
step for editable builds
911

1012

1113
v3.1.1 (2024-04-29)

src/versioningit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<https://versioningit.rtfd.io> for more information.
4444
"""
4545

46-
__version__ = "3.2.0.dev1"
46+
__version__ = "3.1.2.dev1"
4747
__author__ = "John Thorvald Wodder II"
4848
__author_email__ = "[email protected]"
4949
__license__ = "MIT"

src/versioningit/hatch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
7373
super().__init__(*args, **kwargs)
7474
self.__tmpdir = Path(tempfile.mkdtemp())
7575

76-
def initialize(self, _version: str, build_data: dict[str, Any]) -> None:
76+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
7777
init_logging()
78+
if self.target_name == "wheel" and version == "editable":
79+
log.debug("Not running onbuild step for editable build")
80+
return None
7881
version_source = self.metadata.hatch.version.source
7982
if not isinstance(version_source, VersioningitSource):
8083
raise RuntimeError(

test/test_end2end.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ def test_editable_mode(cmd: list[str], tmp_path: Path) -> None:
399399
assert get_repo_status(srcdir) == status
400400
info = readcmd(sys.executable, "-m", "pip", "show", "mypackage")
401401
assert parse_version_from_metadata(info) == details.version
402+
version_var = readcmd(
403+
sys.executable, "-c", "import mypackage; print(mypackage.__version__)"
404+
)
405+
assert version_var == "NOT SET"
402406
for f in details.files:
403407
f.check(srcdir, "project")
404408
finally:
@@ -425,6 +429,10 @@ def test_editable_mode_hatch(tmp_path: Path) -> None:
425429
assert get_repo_status(srcdir) == status
426430
info = readcmd(sys.executable, "-m", "pip", "show", "mypackage")
427431
assert parse_version_from_metadata(info) == details.version
432+
version_var = readcmd(
433+
sys.executable, "-c", "import mypackage; print(mypackage.__version__)"
434+
)
435+
assert version_var == "NOT SET"
428436
for f in details.files:
429437
f.check(srcdir, "project")
430438
finally:

0 commit comments

Comments
 (0)