pythonanywhere-briefcase-plugin 0.0.1a3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonanywhere_briefcase_plugin-0.0.1a3/LICENSE +21 -0
- pythonanywhere_briefcase_plugin-0.0.1a3/PKG-INFO +86 -0
- pythonanywhere_briefcase_plugin-0.0.1a3/README.md +63 -0
- pythonanywhere_briefcase_plugin-0.0.1a3/pyproject.toml +63 -0
- pythonanywhere_briefcase_plugin-0.0.1a3/src/pythonanywhere_briefcase_plugin/__init__.py +4 -0
- pythonanywhere_briefcase_plugin-0.0.1a3/src/pythonanywhere_briefcase_plugin/channel.py +96 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PythonAnywhere
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pythonanywhere-briefcase-plugin
|
|
3
|
+
Version: 0.0.1a3
|
|
4
|
+
Summary: A Briefcase publication channel plugin for deploying static web apps to PythonAnywhere.
|
|
5
|
+
Keywords: briefcase,pythonanywhere,deployment,web,static
|
|
6
|
+
Author: Filip Lajszczak
|
|
7
|
+
Author-email: Filip Lajszczak <filip@lajszczak.dev>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Requires-Dist: pythonanywhere-core>=0.3.0
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# pythonanywhere-briefcase-plugin
|
|
25
|
+
|
|
26
|
+
A [Briefcase](https://briefcase.readthedocs.io/) publication channel plugin for deploying static web apps to [PythonAnywhere](https://www.pythonanywhere.com/).
|
|
27
|
+
|
|
28
|
+
> **Note:** This package depends on the publication channels feature in Briefcase, which has not been included in a release yet. Until it is released, install Briefcase from main:
|
|
29
|
+
> ```
|
|
30
|
+
> pip install git+https://github.com/beeware/briefcase@main
|
|
31
|
+
> ```
|
|
32
|
+
|
|
33
|
+
## Prerequisites
|
|
34
|
+
|
|
35
|
+
* A PythonAnywhere account
|
|
36
|
+
* An API token (from your [Account page](https://www.pythonanywhere.com/account/#api_token))
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```console
|
|
41
|
+
$ pip install pythonanywhere-briefcase-plugin
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
Build and package your web app:
|
|
47
|
+
|
|
48
|
+
```console
|
|
49
|
+
$ briefcase create web static
|
|
50
|
+
$ briefcase build web static
|
|
51
|
+
$ briefcase package web static
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Set your PythonAnywhere API token:
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
$ export API_TOKEN=your-api-token-here
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Publish:
|
|
61
|
+
|
|
62
|
+
```console
|
|
63
|
+
$ briefcase publish web static
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Your app will be deployed to `https://<username>.pythonanywhere.com/`.
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
Full documentation is available at [https://briefcase.pythonanywhere.com/](https://briefcase.pythonanywhere.com/).
|
|
71
|
+
|
|
72
|
+
## Contributing
|
|
73
|
+
|
|
74
|
+
Development requires [uv](https://docs.astral.sh/uv/getting-started/installation/).
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
$ git clone https://github.com/pythonanywhere/pythonanywhere-briefcase-plugin.git
|
|
78
|
+
$ cd pythonanywhere-briefcase-plugin
|
|
79
|
+
$ uv sync
|
|
80
|
+
$ uvx pre-commit install
|
|
81
|
+
$ uv run pytest
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT license.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# pythonanywhere-briefcase-plugin
|
|
2
|
+
|
|
3
|
+
A [Briefcase](https://briefcase.readthedocs.io/) publication channel plugin for deploying static web apps to [PythonAnywhere](https://www.pythonanywhere.com/).
|
|
4
|
+
|
|
5
|
+
> **Note:** This package depends on the publication channels feature in Briefcase, which has not been included in a release yet. Until it is released, install Briefcase from main:
|
|
6
|
+
> ```
|
|
7
|
+
> pip install git+https://github.com/beeware/briefcase@main
|
|
8
|
+
> ```
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
* A PythonAnywhere account
|
|
13
|
+
* An API token (from your [Account page](https://www.pythonanywhere.com/account/#api_token))
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```console
|
|
18
|
+
$ pip install pythonanywhere-briefcase-plugin
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
Build and package your web app:
|
|
24
|
+
|
|
25
|
+
```console
|
|
26
|
+
$ briefcase create web static
|
|
27
|
+
$ briefcase build web static
|
|
28
|
+
$ briefcase package web static
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Set your PythonAnywhere API token:
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
$ export API_TOKEN=your-api-token-here
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Publish:
|
|
38
|
+
|
|
39
|
+
```console
|
|
40
|
+
$ briefcase publish web static
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Your app will be deployed to `https://<username>.pythonanywhere.com/`.
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
Full documentation is available at [https://briefcase.pythonanywhere.com/](https://briefcase.pythonanywhere.com/).
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
Development requires [uv](https://docs.astral.sh/uv/getting-started/installation/).
|
|
52
|
+
|
|
53
|
+
```console
|
|
54
|
+
$ git clone https://github.com/pythonanywhere/pythonanywhere-briefcase-plugin.git
|
|
55
|
+
$ cd pythonanywhere-briefcase-plugin
|
|
56
|
+
$ uv sync
|
|
57
|
+
$ uvx pre-commit install
|
|
58
|
+
$ uv run pytest
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT license.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pythonanywhere-briefcase-plugin"
|
|
3
|
+
version = "0.0.1a3"
|
|
4
|
+
description = "A Briefcase publication channel plugin for deploying static web apps to PythonAnywhere."
|
|
5
|
+
requires-python = ">= 3.10"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "Filip Lajszczak", email = "filip@lajszczak.dev"},
|
|
11
|
+
]
|
|
12
|
+
keywords = ["briefcase", "pythonanywhere", "deployment", "web", "static"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Topic :: Software Development",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"pythonanywhere-core >= 0.3.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["uv_build >= 0.7.2, < 0.8"]
|
|
31
|
+
build-backend = "uv_build"
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
test = [
|
|
35
|
+
"pytest >= 9.0",
|
|
36
|
+
"pytest-cov >= 7.0",
|
|
37
|
+
"pytest-mock >= 3.10",
|
|
38
|
+
"responses >= 0.25",
|
|
39
|
+
]
|
|
40
|
+
dev = [
|
|
41
|
+
{include-group = "test"},
|
|
42
|
+
"briefcase @ git+https://github.com/beeware/briefcase@fca2cab707794f169b61fe2641d31af262bc5566",
|
|
43
|
+
"ruff >= 0.11",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.entry-points."briefcase.channels.web.static"]
|
|
47
|
+
pythonanywhere = "pythonanywhere_briefcase_plugin:PythonAnywherePublicationChannel"
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
extend-select = [
|
|
54
|
+
"E", "W", "F", "UP", "B", "I", "RUF",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[tool.coverage.run]
|
|
58
|
+
branch = true
|
|
59
|
+
source_pkgs = ["pythonanywhere_briefcase_plugin"]
|
|
60
|
+
|
|
61
|
+
[tool.coverage.report]
|
|
62
|
+
show_missing = true
|
|
63
|
+
skip_covered = true
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
from zipfile import ZipFile
|
|
8
|
+
|
|
9
|
+
from briefcase.channels.base import BasePublicationChannel
|
|
10
|
+
from briefcase.exceptions import BriefcaseCommandError
|
|
11
|
+
from pythonanywhere_core.base import get_username
|
|
12
|
+
from pythonanywhere_core.exceptions import (
|
|
13
|
+
AuthenticationError,
|
|
14
|
+
NoTokenError,
|
|
15
|
+
PythonAnywhereApiException,
|
|
16
|
+
)
|
|
17
|
+
from pythonanywhere_core.files import Files
|
|
18
|
+
from pythonanywhere_core.webapp import Webapp
|
|
19
|
+
|
|
20
|
+
import pythonanywhere_briefcase_plugin
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from briefcase.channels.base import PublishCommandAPI
|
|
24
|
+
from briefcase.config import AppConfig
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PythonAnywherePublicationChannel(BasePublicationChannel):
|
|
28
|
+
@property
|
|
29
|
+
def name(self) -> str:
|
|
30
|
+
return "pythonanywhere"
|
|
31
|
+
|
|
32
|
+
def _resolve_username(self, app: AppConfig) -> str:
|
|
33
|
+
username = getattr(app, "pythonanywhere_username", None)
|
|
34
|
+
if username:
|
|
35
|
+
return username
|
|
36
|
+
|
|
37
|
+
return get_username()
|
|
38
|
+
|
|
39
|
+
def _resolve_domain(self, app: AppConfig) -> str:
|
|
40
|
+
domain = getattr(app, "pythonanywhere_domain", None)
|
|
41
|
+
if domain:
|
|
42
|
+
return domain
|
|
43
|
+
|
|
44
|
+
username = self._resolve_username(app)
|
|
45
|
+
return f"{username}.pythonanywhere.com"
|
|
46
|
+
|
|
47
|
+
def publish_app(self, app: AppConfig, command: PublishCommandAPI, **options):
|
|
48
|
+
dist_path = command.distribution_path(app)
|
|
49
|
+
if not dist_path.exists():
|
|
50
|
+
raise BriefcaseCommandError(
|
|
51
|
+
f"Distribution artifact not found: {dist_path}\n\n"
|
|
52
|
+
"Run 'briefcase package web static' first."
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
os.environ["PYTHONANYWHERE_CLIENT"] = (
|
|
56
|
+
f"pythonanywhere-briefcase-plugin/{pythonanywhere_briefcase_plugin.__version__}"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
username = self._resolve_username(app)
|
|
60
|
+
domain = self._resolve_domain(app)
|
|
61
|
+
remote_path = f"/home/{username}/{app.app_name}"
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
65
|
+
with ZipFile(dist_path) as zf:
|
|
66
|
+
zf.extractall(tmpdir)
|
|
67
|
+
Files().tree_post(tmpdir, remote_path)
|
|
68
|
+
|
|
69
|
+
webapp = Webapp(domain)
|
|
70
|
+
try:
|
|
71
|
+
webapp.get()
|
|
72
|
+
except PythonAnywhereApiException:
|
|
73
|
+
webapp.create(
|
|
74
|
+
python_version="3.13",
|
|
75
|
+
virtualenv_path=None,
|
|
76
|
+
project_path=Path(remote_path),
|
|
77
|
+
nuke=False,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
webapp.create_static_file_mapping("/", Path(remote_path))
|
|
81
|
+
webapp.reload()
|
|
82
|
+
except NoTokenError as e:
|
|
83
|
+
raise BriefcaseCommandError(
|
|
84
|
+
"PythonAnywhere API token not found.\n\n"
|
|
85
|
+
"Set the API_TOKEN environment variable with "
|
|
86
|
+
"your token from\n"
|
|
87
|
+
"https://www.pythonanywhere.com/account/#api_token"
|
|
88
|
+
) from e
|
|
89
|
+
except AuthenticationError as e:
|
|
90
|
+
raise BriefcaseCommandError(
|
|
91
|
+
"PythonAnywhere API authentication failed.\n\n"
|
|
92
|
+
"Check that your API_TOKEN environment variable "
|
|
93
|
+
"contains a valid token."
|
|
94
|
+
) from e
|
|
95
|
+
except PythonAnywhereApiException as e:
|
|
96
|
+
raise BriefcaseCommandError(f"PythonAnywhere API error: {e}") from e
|