Skip to content
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

poetry.masonry.api.build_wheel disregards metadata_directory #1078

Closed
3 tasks done
chrahunt opened this issue May 5, 2019 · 4 comments · Fixed by python-poetry/poetry-core#487
Closed
3 tasks done
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/feature Feature requests/implementations

Comments

@chrahunt
Copy link

chrahunt commented May 5, 2019

  • 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 (-vvv option).

  • 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 name

The 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.

@stale
Copy link

stale bot commented Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2019
@chrahunt
Copy link
Author

Still relevant.

@finswimmer
Copy link
Member

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/feature Feature requests/implementations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants