poetry.script extras seems to be ignored, and scripts are always installed
- Poetry version: 1.2.2
- Python version: 3.10.4
- OS version and name: macOS 12.5.1
- pyproject.toml:
- [x] I am on the latest stable Poetry version, installed using a recommended method.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- [x] I have consulted the FAQ and blog for any relevant entries or release notes.
- [ ] If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
I'm trying to install a CLI script only if a given extra is supplied. Here's the config:
[tool.poetry.scripts]
textual = { callable = "textual.cli.cli:run", extras = ["dev"] }
My understand is that textual will be installed on the path only if the "dev" extras has been requested.
After running poetry install there is a textual on the path, which is broken because of missing dependancies. I would expect that poetry would only install textual with poetry install --extras dev.
Please provide a complete pyproject.toml as per the issue template. Thanks!
https://gist.github.com/willmcgugan/5bde2e5f49d59600b1a27f660011e915
the extras are dropped here
but if you use the apparently undeprecated "reference" variant instead, which does preserve the extras, you will encounter https://github.com/python-poetry/poetry/issues/5297. It looks as though this never was fixed, only masked by the extras being lost altogether. Perhaps something like #3431 wants reviving.
either way, there seems to be no code that tries to avoid installing the script at poetry install time based on extras.
I think that would happen, if it happened, in this block. Currently I don't think the EditableBuilder knows which extras are in scope.
probably not too hard to make this work, if you are motivated to do so. That this is so thoroughly broken and no-one has previously noticed suggests that you may be the only person in the world who might be motivated by this...!
please keep in mind this would only work if the user is using Poetry, pip will install all defined scripts (and that won't ever change)
please keep in mind this would only work if the user is using Poetry,
pipwill install all defined scripts (and that won't ever change)
That's probably a good reason not to introduce such option.
putting some flesh on that: https://packaging.python.org/en/latest/specifications/entry-points/ says
Using extras for an entry point is no longer recommended. Consumers should support parsing them from existing distributions, but may then ignore them. New publishing tools need not support specifying extras.
So perhaps an MR that cleaned up the code so as not even to try and do this would be just as welcome as one that made it work
I will close #8841, but it's worth a look for those following this issue, as it has additional details and a repo for reproducibility.