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

Add CLI option -m to run as module #1389

Merged
merged 1 commit into from
May 11, 2023
Merged

Conversation

michasng
Copy link
Contributor

This change resolves #702.
Adding -m applies the corresponding python cli option.
In this case, the script is no longer a file path, but a module path, so foo.fee as opposed to foo/fee.py, hence in order to find the script_path, we need to convert the module path to a file path.
Note that this can also run directories as modules by running the __main__.py file inside of it.

@CLAassistant
Copy link

CLAassistant commented May 11, 2023

CLA assistant check
All committers have signed the CLA.

if options.module:
script_path = str(options.script).replace(".", "/")
if os.path.isdir(script_path):
script_path += "/__main__.py"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would / work on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thankfully yes, I'm on windows and python can handle it apparently. Even when I mix / and \ it seems.

Copy link
Contributor

Choose a reason for hiding this comment

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

os.path.join ?

@FeodorFitsner FeodorFitsner merged commit 699efe8 into flet-dev:main May 11, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
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.

Flet CLI to run an app from a module?
4 participants