-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support the metadata directory (as per PEP-517) for build_wheel #4647
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
Changes from all commits
e74b501
bc82d73
283ce3b
bd615ee
eb81747
2f3b273
cf299fc
fc08e7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Re-use pre-existing ``.dist-info`` dir when creating wheels via the build backend APIs (PEP 517) and the ``metadata_directory`` argument is passed -- by :user:`pelson`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,6 +231,13 @@ class bdist_wheel(Command): | |
| None, | ||
| "Python tag (cp32|cp33|cpNN) for abi3 wheel tag [default: false]", | ||
| ), | ||
| ( | ||
| "dist-info-dir=", | ||
| None, | ||
| "directory where a pre-generated dist-info can be found (e.g. as a " | ||
| "result of calling the PEP517 'prepare_metadata_for_build_wheel' " | ||
| "method)", | ||
| ), | ||
| ] | ||
|
|
||
| boolean_options = ["keep-temp", "skip-build", "relative", "universal"] | ||
|
|
@@ -243,6 +250,7 @@ def initialize_options(self) -> None: | |
| self.format = "zip" | ||
| self.keep_temp = False | ||
| self.dist_dir: str | None = None | ||
| self.dist_info_dir = None | ||
| self.egginfo_dir: str | None = None | ||
| self.root_is_pure: bool | None = None | ||
| self.skip_build = False | ||
|
|
@@ -261,8 +269,9 @@ def finalize_options(self) -> None: | |
| bdist_base = self.get_finalized_command("bdist").bdist_base | ||
| self.bdist_dir = os.path.join(bdist_base, "wheel") | ||
|
|
||
| egg_info = cast(egg_info_cls, self.distribution.get_command_obj("egg_info")) | ||
| egg_info.ensure_finalized() # needed for correct `wheel_dist_name` | ||
| if self.dist_info_dir is None: | ||
| egg_info = cast(egg_info_cls, self.distribution.get_command_obj("egg_info")) | ||
| egg_info.ensure_finalized() # needed for correct `wheel_dist_name` | ||
|
|
||
| self.data_dir = self.wheel_dist_name + ".data" | ||
| self.plat_name_supplied = bool(self.plat_name) | ||
|
|
@@ -447,7 +456,16 @@ def run(self): | |
| f"{safer_version(self.distribution.get_version())}.dist-info" | ||
| ) | ||
| distinfo_dir = os.path.join(self.bdist_dir, distinfo_dirname) | ||
| self.egg2dist(self.egginfo_dir, distinfo_dir) | ||
| if self.dist_info_dir: | ||
| # Use the given dist-info directly. | ||
| log.debug(f"reusing {self.dist_info_dir}") | ||
| shutil.copytree(self.dist_info_dir, distinfo_dir) | ||
| # Egg info is still generated, so remove it now to avoid it getting | ||
| # copied into the wheel. | ||
|
Comment on lines
+463
to
+464
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know why egg info is still generated? Is it because other commands might have generated it? What happens if the line for While I'm okay with this approach, I'm also somewhat apprehensive, as it is perpetuating and reinforcing the expectation that egg-info is generated, even when it's not needed, making it harder in the future to correct this suboptimal approach. For example, this project also has the goal to someday obviate egg-info altogether, and to generate dist-info directly, and adding this additional handling of egg-info will likely complicate that work (though maybe not too much). I wonder - how much do other commands from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looks like
I've added a specific test for this. Previously the test would have passed.
Yes, I appreciate that. IMO, this change does add an additional place where you have to think about egg-info, but I believe it is already necessary to deal with |
||
| shutil.rmtree(self.egginfo_dir) | ||
| else: | ||
| # Convert the generated egg-info into dist-info. | ||
| self.egg2dist(self.egginfo_dir, distinfo_dir) | ||
|
|
||
| self.write_wheelfile(distinfo_dir) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.