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

Single-file or env-only packages not allowed? #8292

Closed
con-f-use opened this issue Aug 9, 2023 · 6 comments
Closed

Single-file or env-only packages not allowed? #8292

con-f-use opened this issue Aug 9, 2023 · 6 comments
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@con-f-use
Copy link

Don't actually know if it's a bug, nothing at all (because already implemented) or a feature; request.

Assuming my project to be packaged is a single file next to pyproject.toml in the file system hierarchy (i.e. in the same directory as pyproject.toml).

tree ./
./
├── myproject.py
└── pyproject.toml

can I get poetry to accept that? I.e. what does the package attribute have to look like?

[tool.poetry]
name = "myproject"
version = "0.1.0"
description = "Single file project"
authors = ["confus"]
packages = [{include = "myproject", from = "."}]   # and similar don't work

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

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

Related: what if I just wanted to use poetry for the dependency pinning functionality, i.e. just to distribute a reliably reproducible virtual environment? Does that work? If not, consider this a issue a feature request.

@con-f-use con-f-use added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Aug 9, 2023
@dimbleby
Copy link
Contributor

dimbleby commented Aug 9, 2023

You don't need to put anything special in the packages section of pyproject.toml, this Just Works.

Please close.

@con-f-use
Copy link
Author

Can you give an example of it just working, because it doesn't for me.

@finswimmer
Copy link
Member

Just remove packages = [{include = "myproject", from = "."}] from the pyproject.toml. Poetry will then look for a myproject and src/myproject folder. If it cannot find one, Poetry will not install the project itself in editable mode, but otherwise it's fine with this.

@con-f-use
Copy link
Author

con-f-use commented Aug 10, 2023

My apologies, seems like it's indeed looking for all three of ./myproject.py, ./myproject/ and ./src/myproject. I have no idea, why it initially didn't (I did try omitting packages in pyproject.toml before creating the issue). Maybe I typoed the filename. Thanks for your patience.

That being said, a way to omitt the project name and version (without poetry defaulting to anything) would sure be nice. Just to prevent accidentally packaging/pypi-uploading something that is not intended to be shared in that way.

@johnthagen
Copy link
Contributor

Copy link

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants