Skip to content

Commit

Permalink
Merge branch 'master' into reinout-version-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout authored Jun 16, 2024
2 parents 89e0b50 + a1455cf commit 7ee64b6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Changelog for zest.releaser
``pkg_resources``.
[reinout]

- Build distributions in an isolated environment.
Otherwise `build` cannot install packages needed for the build system, for example `hatchling`.
Fixes `issue 448 <https://github.com/zestsoftware/zest.releaser/issues/448>`_.
[maurits]


9.1.3 (2024-02-07)
------------------
Expand Down
25 changes: 18 additions & 7 deletions zest/releaser/release.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# GPL, (c) Reinout van Rees

from build import ProjectBuilder
from build.env import DefaultIsolatedEnv
from colorama import Fore
from urllib import request
from urllib.error import HTTPError
Expand Down Expand Up @@ -147,14 +148,24 @@ def _upload_distributions(self, package):
"Making a source distribution of a fresh tag checkout (in %s).",
self.data["tagworkingdir"],
)
builder = ProjectBuilder(source_dir=".", runner=_project_builder_runner)
builder.build("sdist", "./dist/")
if self.zest_releaser_config.create_wheel():
logger.info(
"Making a wheel of a fresh tag checkout (in %s).",
self.data["tagworkingdir"],
with DefaultIsolatedEnv() as env:
# We use an isolated env, otherwise `build` cannot install packages
# needed for the build system, for example `hatchling`.
# See https://github.com/zestsoftware/zest.releaser/issues/448
builder = ProjectBuilder.from_isolated_env(
env,
source_dir=".",
runner=_project_builder_runner,
)
builder.build("wheel", "./dist/")
env.install(builder.build_system_requires)
builder.build("sdist", "./dist/")
if self.zest_releaser_config.create_wheel():
logger.info(
"Making a wheel of a fresh tag checkout (in %s).",
self.data["tagworkingdir"],
)
env.install(builder.get_requires_for_build("wheel"))
builder.build("wheel", "./dist/")
if not self.zest_releaser_config.upload_pypi():
logger.info("Upload to PyPI was disabled in the configuration.")
return
Expand Down
4 changes: 2 additions & 2 deletions zest/releaser/tests/functional-git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ known on PyPI:
creating src/tha.example.egg-info
...
Creating ...
removing 'tha.example-0.1' ...
removing 'tha_example-0.1' ...
Question: Upload to pypi (y/N)?
Our reply: yes
MOCK twine dispatch upload ... dist/tha.example-0.1.tar.gz
MOCK twine dispatch upload ... dist/tha_example-0.1.tar.gz

There is now a tag:

Expand Down
4 changes: 2 additions & 2 deletions zest/releaser/tests/functional-with-hooks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ The release script tags the release and uploads it:
creating src/tha.example.egg-info
...
Creating ...
removing 'tha.example-0.1' ...
removing 'tha_example-0.1' ...
releaser_before_upload
Question: Upload to pypi (Y/n)?
Our reply: y
MOCK twine dispatch upload ... dist/tha.example-0.1.tar.gz
MOCK twine dispatch upload ... dist/tha_example-0.1.tar.gz
releaser_after


Expand Down
4 changes: 2 additions & 2 deletions zest/releaser/tests/pyproject-toml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ known on PyPI:
creating src/tha.example.egg-info
...
Creating ...
removing 'tha.example-0.1' ...
removing 'tha_example-0.1' ...
Question: Upload to pypi (y/N)?
Our reply: yes
MOCK twine dispatch upload ... dist/tha.example-0.1.tar.gz
MOCK twine dispatch upload ... dist/tha_example-0.1.tar.gz

There is now a tag:

Expand Down

0 comments on commit 7ee64b6

Please sign in to comment.