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

Pyproject.toml package list entry cannot be directed to different target #9605

Closed
matgrioni opened this issue Aug 5, 2024 · 4 comments
Closed
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@matgrioni
Copy link

Description

Documentation on pyproject.toml suggests that the following syntax is supported.

[tool.poetry]
# ...
packages = [
    { include = "my_package", from = "lib", to = "target_package" },
]

My understanding of what this should do is that a local install of the package in question should probably support import target_package.

I am not seeing this however and my_package is resolved as the module name. Is this feature actually supported or do I misunderstand something?

Workarounds

No real workaround. Rename the folder in the source to the desired target name I suppose.

Poetry Installation Method

install.python-poetry.org

Operating System

Windows 11

Poetry Version

1.8.3

Poetry Configuration

cache-dir = "C:\\Users\\matgr\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\matgr\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

Doesn't seem applicable. poetry install command succeeds, and logs don't reveal anything apparently obvious (would rather not scrub data if not needed).
@matgrioni matgrioni added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 5, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Aug 5, 2024

do I misunderstand something?

you have not said what commands you are running, what happened, what you expected to happen. So it is hard to guess.

Suggest providing a sample repository showing whatever it is you are seeing

Perhaps python-poetry/poetry-core#672 will help you to understand what this does

@matgrioni
Copy link
Author

I am using poetry only for dependency management in a monorepo structure.

Folder structure

monorepo/
  | my_project/
      | src/
       - component.py
      | tests/
       - test_component.py
  - pyproject.toml

pyproject.toml

[tool.poetry]
name = "monorepo"
version = "0.0.0"
packages = [
    {include = "src", from = "my_project", to = "my_project"}
]

[tool.poetry.dependencies]
python = "^3.10"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

If I run:

poetry lock
poetry install
poetry shell
python

>>> import my_project # <-- raises import error
>>> import src # <-- resolves to monorepo/myproject/src. Expectation is that this line fails and first line succeeds

Looking at the change you provided it looks like for local install this might be expected. I have no idea why this is though and if I run poetry build the .tar.gz created also has a src/ folder and not a my_module folder.

image

@dimbleby
Copy link
Contributor

dimbleby commented Aug 5, 2024

Seems expected then. Of course the source distribution should look like the source, perhaps you want to care about the wheel.

Please close.

Copy link

github-actions bot commented Sep 5, 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 Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants