Implement briefcase publish web for PythonAnywhere
#2678
Replies: 3 comments 5 replies
-
|
Thanks for starting this discussion, @filiplajszczak! The Some additional thoughts and suggestions:
Regarding the open questions:
I agree this would make sense once the implementation is in place and available in a public release
Yes - this should definitely happen
Yes - that would make sense. This would effectively end up a consequence of there being no registered plugin implementation for s3.
Given that PythonAnywhere will have a number of configuration settings, I'd suggest using a full table for configuration, rather than a bunch of long individual setting names - e.g.: [tool.briefcase.app.myapp.web.pythonanywhere]
username = "myuser"
domain = "..."
...I don't know if the use case of running on PythonAnywhere is especially likely - but if it's easy enough to accomodate by having a fallback value if you can identify that the code is running on PythonAnywhere, then we might as well support that.
Again, I'm not sure how likely the "running on PythonAnywhere" use case actually is - but if it's easy enough to accomodate, then we might as well do so.
There's potentially some overlap with #2279. While we don't want to encourage storing API tokens in
That seems as good as any - unless we go down the path of making
If that's helpful for diagnostic purposes, then we might as well. |
Beta Was this translation helpful? Give feedback.
-
Packaging as source of truth
There's no straightforward way to trigger a remote unzip on PythonAnywhere via the API, so the deployment would still be individual file uploads.
Agreed — using the ZIP contents to determine which files to upload (rather than walking the build directory directly) makes sense as a clean boundary between "what was packaged" and "what happens to be in the build tree". That resolves the
Is Where
|
Beta Was this translation helpful? Give feedback.
-
|
The plugin interface was implemented in #2701, and the original proposal has been realized as pythonanywhere-briefcase-plugin. With #2720 and beeware/beeware-tutorial#63, the plugin is also mentioned in Briefcase docs and the BeeWare tutorial. Once both documentation PRs are merged, I believe this discussion can be closed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Implement the
pythonanywherepublication channel forbriefcase publish web,allowing users to deploy a built static web app to PythonAnywhere with a single command.
Background
The
StaticWebPublishCommandalready exists as a placeholder withs3as the default (and only)publication channel, but
publish_app()is currently not implemented.I'm happy to prepare the issue and later PR once the final shape is agreed upon.
The scaffolding was discussed in person with @freakboy3742 but let's reiterate here and discuss some detail.
Proposed Behavior
Running
briefcase publish webwould:API_TOKENis set viaself.tools.os.environ,following the existing briefcase practice for accessing environment variables.
pyproject.toml(e.g.,
pythonanywhere_usernameunder the web platform section) and setPYTHONANYWHERE_USERNAMEin the environment before importingpythonanywhere-core,as the library uses this to construct API endpoints at class instantiation time.
wwwdirectory to PythonAnywhere using theFiles API (recursive directory upload).
/to the uploaded directory.Configuration
Users would add their PythonAnywhere username to
pyproject.toml:The resulting site would be available at
myuser.pythonanywhere.com.Dependencies
This relies on
pythonanywhere-core,which has been updated with the necessary features:
Files.tree_post()for recursive directory uploadWebapp.create()now acceptsvirtualenv_path=Nonefor static sitesPYTHONANYWHERE_USERNAMEenv var support for running outside PythonAnywherepythonanywhere-corewould be an optional dependency, installed viabriefcase[pythonanywhere].Documentation
This would include documentation for the
publishcommand with PythonAnywhere configuration. Could this also be included in the Briefcase tutorial? PythonAnywhere's free tier would make it an accessible way for new users to deploy their first web app.Open Questions
PublishCommand.__call__()already checks that the app has been built (binary_pathexists) and raises an error if not._publish_app()has a TODO to verify the app has been packaged. Shouldpublishauto-trigger a build if the app hasn't been built yet, or continue to require the user to build first?s3channel, which has no implementation, be removed as part of this work?pythonanywhere_usernamethe right config key, and is[tool.briefcase.app.myapp.web]the right section for it? When running on PythonAnywhere itself, the username is already available in the environment — should briefcase detect this and only require the config key when running locally?API_TOKENbe the only supported way to provide credentials, or should there be an alternative (e.g., prompting the user interactively)?briefcase[pythonanywhere]the right extra name for the optional dependency?PYTHONANYWHERE_CLIENTbe set tobriefcase/{version}so API requests are identifiable?Platform Considerations
This only affects the
web/staticplatform — no impact on other platforms. PythonAnywhere provides free-tier hosting, making it a practical default channel for deploying Briefcase web apps.Beta Was this translation helpful? Give feedback.
All reactions