-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption). -
OS version and name: Ubuntu 18.04
-
Poetry version: Poetry 0.12.15
-
Link of a Gist with the contents of your pyproject.toml file: N/A
Issue
The current implementation of poetry.masontry.api:build_wheel does not use metadata_directory per PEP-517. This makes it difficult to implement customizations by overriding prepare_metadata_for_build_wheel since the output files are not actually used in the wheel. For example, the following does not work:
# pyproject.toml
# ...
[tool.intreehooks]
build-backend = "pyproject"
[build-system]
requires = ["poetry>=0.12", "intreehooks"]
build-backend = "intreehooks:loader"# pyproject.py
from pathlib import Path
from poetry.masonry.api import (
build_sdist,
build_wheel,
get_requires_for_build_wheel,
get_requires_for_build_sdist,
prepare_metadata_for_build_wheel as _prepare_metadata_for_build_wheel,
)
from poetry.poetry import Poetry
def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
name = _prepare_metadata_for_build_wheel(metadata_directory, config_settings)
poetry = Poetry.create(".")
metadata = Path(metadata_directory) / name / 'METADATA'
deps = [d.to_pep_508() for d in poetry.package.dev_requires]
text = metadata.read_text(encoding='utf-8')
try:
index = text.index('\n\n')
except ValueError:
index = len(text)
new_requires = '\n'.join(
f'Requires-Dist: {d}'
for d in deps
)
new_text = f'{text[:index]}\n{new_requires}{text[index:]}'
metadata.write_text(new_text, encoding='utf-8')
return nameThe METADATA file edited by prepare_metadata_for_build_wheel is used by pip for the wheel requirements, however the file is not included in the wheel, since build_wheel seems to generate a new one.