-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to the hatchling
build backend.
#2331
Conversation
This should elminate flaky CI due to ephemeral dirs in the source root created by the setuptools build backend which were not multi-process safe. The `hatchling` build backend supports metadata plugins and it performs isolated builds making it a good replacement for the prior setuptools hack for effecting dynamic `Requires-Python` to enable Python 3.13 shadow-support. Unfortunately, there is no nice way to specify an in-tree plugin; so we actually use a very thin in-tree build backend that wraps `hatchling.build`, to allow discovery of our in-tree plugin.
@@ -451,7 +452,7 @@ def spawn_download_distributions( | |||
|
|||
if not build_isolation: | |||
download_cmd.append("--no-build-isolation") | |||
extra_env.update(PEP517_BACKEND_PATH=os.pathsep.join(sys.path)) | |||
pex_extra_sys_path.extend(sys.path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that Pex uses an in-tree build backend, it unearthed this latent bug where PEP517_BACKEND_PATH
would get stomped with the backend-path. As such, both here in spawn download and lower in spawn install wheel, we now pass non-isolated-build sys.path
via PEX_EXTRA_SYS_PATH
instead.
@@ -46,7 +47,12 @@ def build_pex_pex(output_file: PurePath, verbosity: int = 0) -> None: | |||
subprocess.run(args, check=True) | |||
|
|||
|
|||
def describe_git_rev() -> str: | |||
def describe_rev() -> str: | |||
if not os.path.isdir(".git") and os.path.isfile("PKG-INFO"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was always a bug, I just never tried unpacking our sdist and doing a build from there before. That now works.
subprocess.check_call( | ||
args=[build_system.venv_pex.pex, "-c", "import {}".format(build_system.build_backend)] | ||
args=[build_system.venv_pex.pex, "-c", "import {}".format(build_system.build_backend)], | ||
env=build_system.env, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This env carries the backend-path via PEX_EXTRA_SYS_PATH
which is needed to have the build see our now in-tree build backend.
@@ -55,5 +55,6 @@ def test_load_build_system_pyproject_custom_repos( | |||
build_system = load_build_system(current_target, custom_resolver, pex_project_dir) | |||
assert isinstance(build_system, BuildSystem) | |||
subprocess.check_call( | |||
args=[build_system.venv_pex.pex, "-c", "import {}".format(build_system.build_backend)] | |||
args=[build_system.venv_pex.pex, "-c", "import {}".format(build_system.build_backend)], | |||
env=build_system.env, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default Pip for Python 2.7 (19.x) was too old to handle in-tree build backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late to the party, but LGTM
This should elminate flaky CI due to ephemeral dirs in the source root
created by the setuptools build backend which were not multi-process
safe.
The
hatchling
build backend supports metadata plugins and it performsisolated builds making it a good replacement for the prior setuptools
hack for effecting dynamic
Requires-Python
to enable Python 3.13shadow-support. Unfortunately, there is no nice way to specify an
in-tree plugin; so we actually use a very thin in-tree build backend
that wraps
hatchling.build
, to allow discovery of our in-tree plugin.