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

Fix script entrypoints with extras #3431

Closed
wants to merge 1 commit into from
Closed

Fix script entrypoints with extras #3431

wants to merge 1 commit into from

Conversation

akeeman
Copy link
Contributor

@akeeman akeeman commented Nov 30, 2020

  • Added tests for changed code.
  • Updated documentation for changed code.

  • Resolve invalid script entry point file when script has extras
  • Don't add script file when not all extras are selected

Consider this pyproject.toml file, which contains a script that has an extra (as implemented, but not yet documented -> #1181)

# pyproject.toml
# ...

[tool.poetry.extras]
my_extra = []

[tool.poetry.scripts]
foo = {callable = "my_package:foo", extras = ["my_extra"]}

Installing the above with poetry install givens you a script file including the

#!/path/to/python
from my_package import foo

if __name__ == '__main__':
    foo[my_extra]()

The last line is obviously incorrect. It should have been

    foo()

In my opinion the file shouldn't have been installed at all in the first place, as those extras often go along with installing some optional packages to let them work. So I chose to skip the installation of the entrypoint as a whole if not all given extras are demanded. Note that I say "in my opinion", as this is different from setuptools. Setuptools will always install all script entrypoints.

@abn
Copy link
Member

abn commented Mar 21, 2021

This will need to move to https://github.com/python-poetry/poetry-core as the relevant logic is now there.

@abn abn closed this Mar 21, 2021
@akeeman
Copy link
Contributor Author

akeeman commented Mar 22, 2021

So, no fixes for v1.1? Or does this no longer fix the problem, because it worked well on an earlier 1.1.x version?

@abn
Copy link
Member

abn commented Mar 22, 2021

@akeeman apologies. I groked the issue incorrectly. Reopening.

@abn abn reopened this Mar 22, 2021
@akeeman
Copy link
Contributor Author

akeeman commented Mar 22, 2021

That explains a lot! Thanks.

@akeeman
Copy link
Contributor Author

akeeman commented Jun 22, 2021

Hi, can this pr be handled some time? It should be an easy fix for a simple but annoying problem. Yet it's open for several months now...

@neersighted neersighted self-assigned this Nov 15, 2021
@akeeman
Copy link
Contributor Author

akeeman commented Jun 15, 2022

@neersighted any thoughts? The problem still exists in 1.1.13

@finswimmer
Copy link
Member

Looks like this is fixed in the current preview release (1.2.0b2). Can you confirm it?

@akeeman
Copy link
Contributor Author

akeeman commented Jun 16, 2022

1.2.0b2 indeed does not have the issue. Is there any news on when it'll come out of beta?
1.2.0b2 does install the executable even when the extra was not asked for.

What's new for me is that poetry run my-command works fine in 1.1.13, because it doesn't seem to call the generated executable. It can act as a workaround.

@neersighted
Copy link
Member

1.2.0b2 indeed does not have the issue. Is there any news on when it'll come out of beta? 1.2.0b2 does install the executable even when the extra was not asked for.

#5586

Is it worth rebasing this PR to not install entrypoints when the required extra is not installed? I understand we're not doing anything /wrong/ currently because that's the pip behavior, but I'm open to being convinced that not installing entrypoints is beneficial to the user.

@akeeman
Copy link
Contributor Author

akeeman commented Aug 24, 2022

I guess it would be better to do that in a separate pr pr, so let's not do the convincing here.

Copy link

This pull request 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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants