[Poetry] Is it possible to use poetry without defining a package? So purely for pinning dependencies for a venv

The title says it all: Is it possible to use poetry without defining a package? So purely for pinning dependencies for a well-defined python virtual environment. Meaning what would a pyproject.toml for poetry look like, that doesn’t define an actual package, just a list of dependencies to be able reproduce an exact virtual environment from the lock file? In that case my target would not be a sharable artifact, but the virutal environment itself.

All attempts I’ve made just led to things like:

poetry.core.masonry.utils.module.ModuleOrPackageNotFound: No file/folder found for package justenv

# ...

ValueError: /build/source/justenv does not contain any element

# ...

File ".../lib/python3.10/pathlib.py", line 369, in _make_selector
      pat = pattern_parts[0]
  IndexError: tuple index out of range

# ... and my absolute favourite error, just this on stderr:

'name'

As far as I know this is not possible. I must say that last time I looked at this was a long time ago (in the context of this question), but I doubt it changed and your question seems to confirm it.

Does it have to be Poetry?

Coincidentally this kind of use case is somewhat being discussed currently:

Sadly it has to, because I need to use poetry2nix for what I have in mind. I opened an issue with the poetry crowd. I don’t expect much from them. Thanks for the link!

Have you considered just defining a dummy package and not actually building it?

Nah, turns out I was just being dumb the whole time. Poetry is totally fine with just having no package at all. Don’t know what I typoed the first ten times so it didn’t work:

Still absolutely requires a name, version and description, though. :frowning_face:

You can follow this feature request which discusses this issue

1 Like

It’s totally possible to use Poetry solely for dependency management:

[tool.poetry]
package-mode = false

More info: Basic usage | Documentation | Poetry - Python dependency management and packaging made easy

1 Like