Skip to content

Commit

Permalink
Merge pull request #90 from jwodder/gh-89
Browse files Browse the repository at this point in the history
Don't run onbuild step for editable builds with Hatch
  • Loading branch information
jwodder authored Jul 20, 2024
2 parents 55946c8 + 371f3fd commit 614f54b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v3.2.0 (in development)
v3.1.2 (in development)
-----------------------
- Drop support for Python 3.7
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
step for editable builds

v3.1.1 (2024-04-29)
-------------------
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog
v3.2.0 (in development)
-----------------------
- Drop support for Python 3.7
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
step for editable builds


v3.1.1 (2024-04-29)
Expand Down
2 changes: 1 addition & 1 deletion src/versioningit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<https://versioningit.rtfd.io> for more information.
"""

__version__ = "3.2.0.dev1"
__version__ = "3.1.2.dev1"
__author__ = "John Thorvald Wodder II"
__author_email__ = "[email protected]"
__license__ = "MIT"
Expand Down
5 changes: 4 additions & 1 deletion src/versioningit/hatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self.__tmpdir = Path(tempfile.mkdtemp())

def initialize(self, _version: str, build_data: dict[str, Any]) -> None:
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
init_logging()
if self.target_name == "wheel" and version == "editable":
log.debug("Not running onbuild step for editable build")
return None
version_source = self.metadata.hatch.version.source
if not isinstance(version_source, VersioningitSource):
raise RuntimeError(
Expand Down
8 changes: 8 additions & 0 deletions test/test_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ def test_editable_mode(cmd: list[str], tmp_path: Path) -> None:
assert get_repo_status(srcdir) == status
info = readcmd(sys.executable, "-m", "pip", "show", "mypackage")
assert parse_version_from_metadata(info) == details.version
version_var = readcmd(
sys.executable, "-c", "import mypackage; print(mypackage.__version__)"
)
assert version_var == "NOT SET"
for f in details.files:
f.check(srcdir, "project")
finally:
Expand All @@ -425,6 +429,10 @@ def test_editable_mode_hatch(tmp_path: Path) -> None:
assert get_repo_status(srcdir) == status
info = readcmd(sys.executable, "-m", "pip", "show", "mypackage")
assert parse_version_from_metadata(info) == details.version
version_var = readcmd(
sys.executable, "-c", "import mypackage; print(mypackage.__version__)"
)
assert version_var == "NOT SET"
for f in details.files:
f.check(srcdir, "project")
finally:
Expand Down

0 comments on commit 614f54b

Please sign in to comment.