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

packaged app: use executable named for the project and main function #7670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bluss
Copy link
Contributor

@bluss bluss commented Sep 24, 2024

Summary

Create a function main as the default for a packaged app. Configure the default executable as:

example-packaged-app = "example_packaged_app:main"

Which is often what you want - the executable has the same name as the app.
The purpose is to more often hit what the user wants, so they don't have
to even rename the command to start developing.

Test Plan

  • existing tests are updated

@@ -1423,7 +1423,7 @@ fn init_virtual_project() -> Result<()> {
dependencies = []

[project.scripts]
hello = "foo:hello"
foo = "foo:main"
Copy link
Contributor Author

@bluss bluss Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm mistaken here, but I think this test shows that uv init --virtual is already creating something with a build system and executable, this is fishy.

Copy link
Member

@zanieb zanieb Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is fishy — --virtual is legacy now but shouldn't be doing this. Let's tackle it separately though.

@bluss bluss changed the title Use main as default function in packaged app packaged app: use executable named for the project and function main Sep 24, 2024
@bluss bluss changed the title packaged app: use executable named for the project and function main packaged app: use executable named for the project and main function Sep 24, 2024
@bluss
Copy link
Contributor Author

bluss commented Sep 24, 2024

I asked @zanieb briefly in discord before posting this one. It's a small but "opinionated" change I guess. Next step could be to add a minimal __main__.py.

@@ -247,7 +247,7 @@ requires-python = ">=3.11"
dependencies = []

[project.scripts]
hello = "example_packaged_app:hello"
example-packaged-app = "example_packaged_app:hello"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be :main right?

Copy link
Contributor Author

@bluss bluss Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, fixed.

Also I'm very used to force pushing but shouldn't do that since you squash merge here anyway. I just haven't learned the lesson yet..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we force push all the time, don't worry about that.

Create a function main as the default for a packaged app.
Configure the default executable as:

example-packaged-app = "example_packaged_app:main"

Which is often what you want - the executable has the same name as the
app.
@zanieb
Copy link
Member

zanieb commented Sep 27, 2024

I'm off today but I'll try to get this in early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants