fasthtml-tailwindcss 4.3.3__tar.gz → 4.3.3.post1__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.
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/.gitignore +2 -2
- fasthtml_tailwindcss-4.3.3.post1/PKG-INFO +153 -0
- fasthtml_tailwindcss-4.3.3.post1/README.md +125 -0
- fasthtml_tailwindcss-4.3.3.post1/packages/cli/LICENSE +21 -0
- fasthtml_tailwindcss-4.3.3.post1/packages/cli/README.md +5 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1/packages/cli}/hatch_build.py +16 -6
- fasthtml_tailwindcss-4.3.3.post1/packages/cli/pyproject.toml +34 -0
- fasthtml_tailwindcss-4.3.3.post1/packages/cli/src/fasthtml_tailwindcss_cli/__init__.py +7 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/pyproject.toml +16 -9
- fasthtml_tailwindcss-4.3.3.post1/scripts/check_release.py +109 -0
- fasthtml_tailwindcss-4.3.3.post1/scripts/filter_publish.py +25 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/__init__.py +42 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/build.py +64 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/client.py +128 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/compiler.py +40 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/config.py +57 -0
- fasthtml_tailwindcss-4.3.3.post1/src/fasthtml_tailwindcss/worker.py +122 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/tests/conftest.py +7 -9
- fasthtml_tailwindcss-4.3.3.post1/tests/test_build.py +32 -0
- fasthtml_tailwindcss-4.3.3.post1/tests/test_component.py +139 -0
- fasthtml_tailwindcss-4.3.3.post1/tests/test_releases.py +96 -0
- fasthtml_tailwindcss-4.3.3.post1/tests/test_sessions.py +98 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/tests/test_uvicorn.py +30 -27
- fasthtml_tailwindcss-4.3.3/PKG-INFO +0 -133
- fasthtml_tailwindcss-4.3.3/README.md +0 -105
- fasthtml_tailwindcss-4.3.3/src/fasthtml_tailwindcss/__init__.py +0 -33
- fasthtml_tailwindcss-4.3.3/src/fasthtml_tailwindcss/_client.py +0 -156
- fasthtml_tailwindcss-4.3.3/src/fasthtml_tailwindcss/_worker.py +0 -133
- fasthtml_tailwindcss-4.3.3/tests/test_component.py +0 -83
- fasthtml_tailwindcss-4.3.3/tests/test_sessions.py +0 -95
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/LICENSE +0 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1/packages/cli}/TAILWIND-LICENSE +0 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1/packages/cli}/binaries.json +0 -0
- {fasthtml_tailwindcss-4.3.3 → fasthtml_tailwindcss-4.3.3.post1}/src/fasthtml_tailwindcss/py.typed +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fasthtml-tailwindcss
|
|
3
|
+
Version: 4.3.3.post1
|
|
4
|
+
Summary: Tailwind CSS for FastHTML with a persistent development watcher and a build command for production CSS.
|
|
5
|
+
Project-URL: Documentation, https://github.com/SpaceShaman/fasthtml-tailwindcss#readme
|
|
6
|
+
Project-URL: Homepage, https://github.com/SpaceShaman/fasthtml-tailwindcss
|
|
7
|
+
Project-URL: Issues, https://github.com/SpaceShaman/fasthtml-tailwindcss/issues
|
|
8
|
+
Project-URL: Repository, https://github.com/SpaceShaman/fasthtml-tailwindcss
|
|
9
|
+
Author-email: SpaceShaman <spaceshaman@tuta.io>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: components,css,fasthtml,tailwindcss,web
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
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: Programming Language :: Python :: 3.15
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: filelock>=3.16
|
|
24
|
+
Requires-Dist: python-fasthtml>=0.14.13
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: fasthtml-tailwindcss-cli<5,>=4; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# fasthtml-tailwindcss
|
|
30
|
+
|
|
31
|
+
[](LICENSE)
|
|
32
|
+
[](https://github.com/SpaceShaman/fasthtml-tailwindcss/actions/workflows/release.yml)
|
|
33
|
+
[](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
34
|
+
[](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
35
|
+
[](https://github.com/AnswerDotAI/fasthtml)
|
|
36
|
+
[](https://tailwindcss.com/)
|
|
37
|
+
[](https://github.com/astral-sh/uv)
|
|
38
|
+
[](https://docs.pytest.org/)
|
|
39
|
+
[](https://github.com/astral-sh/ruff)
|
|
40
|
+
|
|
41
|
+
Tailwind CSS for [FastHTML](https://github.com/AnswerDotAI/fasthtml) with a persistent development watcher and a build command for production CSS.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
| Environment | uv | pip |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Development and builds | `uv add "fasthtml-tailwindcss[dev]"` | `pip install "fasthtml-tailwindcss[dev]"` |
|
|
48
|
+
| Production | `uv add fasthtml-tailwindcss` | `pip install fasthtml-tailwindcss` |
|
|
49
|
+
|
|
50
|
+
The `dev` extra installs the standalone compiler through [fasthtml-tailwindcss-cli](https://pypi.org/project/fasthtml-tailwindcss-cli/). No Node.js or npm is needed. Production only needs the wrapper and generated CSS.
|
|
51
|
+
|
|
52
|
+
On Alpine Linux, the compiler also needs:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
apk add --no-cache libstdc++ libgcc
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from fasthtml.common import Div, FastHTML, StaticImmutable
|
|
62
|
+
from fasthtml_tailwindcss import TailwindHead
|
|
63
|
+
|
|
64
|
+
app = FastHTML(hdrs=[TailwindHead(watch=True)])
|
|
65
|
+
app.mount("/static", StaticImmutable(directory="static"), name="static")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@app.route("/")
|
|
69
|
+
def get():
|
|
70
|
+
return Div("Hello", cls="rounded-lg bg-blue-500 p-4 text-white")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`TailwindHead` creates the output directory and adds a stylesheet link. `vurl` versions the URL by content, and `StaticImmutable` lets browsers cache the CSS until it changes.
|
|
74
|
+
|
|
75
|
+
### Watch mode
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
uv run uvicorn main:app --reload
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For `app/main.py`, run `uv run --directory app uvicorn main:app --reload` from the project directory.
|
|
82
|
+
|
|
83
|
+
With `watch=True`, compilation starts on the first page render and CSS rebuilds when sources change. The watcher survives server reloads, restarts if settings change, and stops 15 seconds after the last application stops using it. Refresh the browser to see changes; automatic browser refresh and stylesheet updates during HTMX fragment swaps are not included.
|
|
84
|
+
|
|
85
|
+
### Production
|
|
86
|
+
|
|
87
|
+
Use `TailwindHead()` with the default `watch=False` in the application, then build CSS in your deployment pipeline with the `dev` extra installed:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
uv run fasthtml-tailwindcss build main:app
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The command imports the app and builds minified CSS using its `TailwindHead` settings. The app must have exactly one `TailwindHead` in `hdrs`. For `app/main.py`, run `build app.main:app` from the project directory or `build main:app` from `app/`; both write to `app/static/tailwind.css` by default.
|
|
94
|
+
|
|
95
|
+
Deploy the generated CSS alongside the application. With `watch=False`, `TailwindHead` only links the stylesheet; it does not run the compiler.
|
|
96
|
+
|
|
97
|
+
## Options
|
|
98
|
+
|
|
99
|
+
All configuration is passed to `TailwindHead`:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
TailwindHead(
|
|
103
|
+
watch=True,
|
|
104
|
+
css="@theme { --color-brand: #7854f7; }",
|
|
105
|
+
output="static/app.css",
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- `watch`: enable the persistent development compiler. Defaults to `False`.
|
|
110
|
+
- `sources`: files or directories to scan. Defaults to the working directory; with a custom input, its own source detection applies unless extra sources are supplied.
|
|
111
|
+
- `input`: custom stylesheet, such as `input="assets/app.css"`, replacing the built-in `@import "tailwindcss"`. Relative CSS imports resolve from that file.
|
|
112
|
+
- `css`: CSS appended after the input, useful for `@theme`, variants, and `@source inline(...)`.
|
|
113
|
+
- `output`: CSS file path, defaulting to `./static/tailwind.css`. The stylesheet URL follows this path, so mount its directory at the corresponding URL.
|
|
114
|
+
|
|
115
|
+
Paths are relative to the working directory. The build command uses the application module's directory; run the server from that directory too. Temporary files and compiler logs live in `.fasthtml-tailwindcss/`, which you can add to `.gitignore`.
|
|
116
|
+
|
|
117
|
+
Use complete class names such as `"bg-red-500"`; Tailwind cannot detect names constructed with `f"bg-{color}-500"`. Classes in installed component libraries need explicit sources or safelisting.
|
|
118
|
+
|
|
119
|
+
For inline Lucide SVG icons with typed names and editor autocomplete, see [fasthtml-lucide](https://github.com/SpaceShaman/fasthtml-lucide).
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
### Setup and tests
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
uv sync --group build --group test --extra dev
|
|
127
|
+
uv run --group test --extra dev pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Build
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
uv build --no-sources
|
|
134
|
+
uv build packages/cli --no-sources
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
CLI wheel builds download and verify the official executable using SHA-256. Supported platforms are Linux x64/ARM64 (glibc 2.28+ or musl 1.2+), macOS 13+ (Intel/Apple Silicon), and Windows x64. Building a CLI wheel needs network access unless the verified binary is already available locally.
|
|
138
|
+
|
|
139
|
+
### Automated releases
|
|
140
|
+
|
|
141
|
+
GitHub Actions checks daily for a new stable [Tailwind CSS release](https://github.com/tailwindlabs/tailwindcss/releases), then builds and tests both packages before publishing them to PyPI. Both package versions track the Tailwind version; wrapper-only fixes may add a `.postN` suffix.
|
|
142
|
+
|
|
143
|
+
The [Release workflow](.github/workflows/release.yml) builds and tests both packages before publishing through PyPI Trusted Publishing. Configure the same publisher (`SpaceShaman/fasthtml-tailwindcss`, workflow `release.yml`, environment `pypi`) for both PyPI projects, and allow workflow version commits on the default branch.
|
|
144
|
+
|
|
145
|
+
## Links
|
|
146
|
+
|
|
147
|
+
- [GitHub repository](https://github.com/SpaceShaman/fasthtml-tailwindcss)
|
|
148
|
+
- [PyPI package](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
149
|
+
- [Tailwind CLI package](https://pypi.org/project/fasthtml-tailwindcss-cli/)
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
The wrapper and Tailwind CSS are MIT licensed. The CLI package includes both license notices.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# fasthtml-tailwindcss
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://github.com/SpaceShaman/fasthtml-tailwindcss/actions/workflows/release.yml)
|
|
5
|
+
[](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
6
|
+
[](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
7
|
+
[](https://github.com/AnswerDotAI/fasthtml)
|
|
8
|
+
[](https://tailwindcss.com/)
|
|
9
|
+
[](https://github.com/astral-sh/uv)
|
|
10
|
+
[](https://docs.pytest.org/)
|
|
11
|
+
[](https://github.com/astral-sh/ruff)
|
|
12
|
+
|
|
13
|
+
Tailwind CSS for [FastHTML](https://github.com/AnswerDotAI/fasthtml) with a persistent development watcher and a build command for production CSS.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
| Environment | uv | pip |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Development and builds | `uv add "fasthtml-tailwindcss[dev]"` | `pip install "fasthtml-tailwindcss[dev]"` |
|
|
20
|
+
| Production | `uv add fasthtml-tailwindcss` | `pip install fasthtml-tailwindcss` |
|
|
21
|
+
|
|
22
|
+
The `dev` extra installs the standalone compiler through [fasthtml-tailwindcss-cli](https://pypi.org/project/fasthtml-tailwindcss-cli/). No Node.js or npm is needed. Production only needs the wrapper and generated CSS.
|
|
23
|
+
|
|
24
|
+
On Alpine Linux, the compiler also needs:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
apk add --no-cache libstdc++ libgcc
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from fasthtml.common import Div, FastHTML, StaticImmutable
|
|
34
|
+
from fasthtml_tailwindcss import TailwindHead
|
|
35
|
+
|
|
36
|
+
app = FastHTML(hdrs=[TailwindHead(watch=True)])
|
|
37
|
+
app.mount("/static", StaticImmutable(directory="static"), name="static")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@app.route("/")
|
|
41
|
+
def get():
|
|
42
|
+
return Div("Hello", cls="rounded-lg bg-blue-500 p-4 text-white")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`TailwindHead` creates the output directory and adds a stylesheet link. `vurl` versions the URL by content, and `StaticImmutable` lets browsers cache the CSS until it changes.
|
|
46
|
+
|
|
47
|
+
### Watch mode
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
uv run uvicorn main:app --reload
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For `app/main.py`, run `uv run --directory app uvicorn main:app --reload` from the project directory.
|
|
54
|
+
|
|
55
|
+
With `watch=True`, compilation starts on the first page render and CSS rebuilds when sources change. The watcher survives server reloads, restarts if settings change, and stops 15 seconds after the last application stops using it. Refresh the browser to see changes; automatic browser refresh and stylesheet updates during HTMX fragment swaps are not included.
|
|
56
|
+
|
|
57
|
+
### Production
|
|
58
|
+
|
|
59
|
+
Use `TailwindHead()` with the default `watch=False` in the application, then build CSS in your deployment pipeline with the `dev` extra installed:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
uv run fasthtml-tailwindcss build main:app
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The command imports the app and builds minified CSS using its `TailwindHead` settings. The app must have exactly one `TailwindHead` in `hdrs`. For `app/main.py`, run `build app.main:app` from the project directory or `build main:app` from `app/`; both write to `app/static/tailwind.css` by default.
|
|
66
|
+
|
|
67
|
+
Deploy the generated CSS alongside the application. With `watch=False`, `TailwindHead` only links the stylesheet; it does not run the compiler.
|
|
68
|
+
|
|
69
|
+
## Options
|
|
70
|
+
|
|
71
|
+
All configuration is passed to `TailwindHead`:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
TailwindHead(
|
|
75
|
+
watch=True,
|
|
76
|
+
css="@theme { --color-brand: #7854f7; }",
|
|
77
|
+
output="static/app.css",
|
|
78
|
+
)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- `watch`: enable the persistent development compiler. Defaults to `False`.
|
|
82
|
+
- `sources`: files or directories to scan. Defaults to the working directory; with a custom input, its own source detection applies unless extra sources are supplied.
|
|
83
|
+
- `input`: custom stylesheet, such as `input="assets/app.css"`, replacing the built-in `@import "tailwindcss"`. Relative CSS imports resolve from that file.
|
|
84
|
+
- `css`: CSS appended after the input, useful for `@theme`, variants, and `@source inline(...)`.
|
|
85
|
+
- `output`: CSS file path, defaulting to `./static/tailwind.css`. The stylesheet URL follows this path, so mount its directory at the corresponding URL.
|
|
86
|
+
|
|
87
|
+
Paths are relative to the working directory. The build command uses the application module's directory; run the server from that directory too. Temporary files and compiler logs live in `.fasthtml-tailwindcss/`, which you can add to `.gitignore`.
|
|
88
|
+
|
|
89
|
+
Use complete class names such as `"bg-red-500"`; Tailwind cannot detect names constructed with `f"bg-{color}-500"`. Classes in installed component libraries need explicit sources or safelisting.
|
|
90
|
+
|
|
91
|
+
For inline Lucide SVG icons with typed names and editor autocomplete, see [fasthtml-lucide](https://github.com/SpaceShaman/fasthtml-lucide).
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
### Setup and tests
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
uv sync --group build --group test --extra dev
|
|
99
|
+
uv run --group test --extra dev pytest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Build
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
uv build --no-sources
|
|
106
|
+
uv build packages/cli --no-sources
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
CLI wheel builds download and verify the official executable using SHA-256. Supported platforms are Linux x64/ARM64 (glibc 2.28+ or musl 1.2+), macOS 13+ (Intel/Apple Silicon), and Windows x64. Building a CLI wheel needs network access unless the verified binary is already available locally.
|
|
110
|
+
|
|
111
|
+
### Automated releases
|
|
112
|
+
|
|
113
|
+
GitHub Actions checks daily for a new stable [Tailwind CSS release](https://github.com/tailwindlabs/tailwindcss/releases), then builds and tests both packages before publishing them to PyPI. Both package versions track the Tailwind version; wrapper-only fixes may add a `.postN` suffix.
|
|
114
|
+
|
|
115
|
+
The [Release workflow](.github/workflows/release.yml) builds and tests both packages before publishing through PyPI Trusted Publishing. Configure the same publisher (`SpaceShaman/fasthtml-tailwindcss`, workflow `release.yml`, environment `pypi`) for both PyPI projects, and allow workflow version commits on the default branch.
|
|
116
|
+
|
|
117
|
+
## Links
|
|
118
|
+
|
|
119
|
+
- [GitHub repository](https://github.com/SpaceShaman/fasthtml-tailwindcss)
|
|
120
|
+
- [PyPI package](https://pypi.org/project/fasthtml-tailwindcss/)
|
|
121
|
+
- [Tailwind CLI package](https://pypi.org/project/fasthtml-tailwindcss-cli/)
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
The wrapper and Tailwind CSS are MIT licensed. The CLI package includes both license notices.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SpaceShaman
|
|
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,5 @@
|
|
|
1
|
+
# fasthtml-tailwindcss-cli
|
|
2
|
+
|
|
3
|
+
Platform-specific wheels containing the official standalone Tailwind CSS CLI binary. It is installed as the `dev` extra of [fasthtml-tailwindcss](https://pypi.org/project/fasthtml-tailwindcss/) and is not needed to serve a prebuilt stylesheet.
|
|
4
|
+
|
|
5
|
+
The package version matches the bundled Tailwind CSS release. See the [project repository](https://github.com/SpaceShaman/fasthtml-tailwindcss) for usage and release details.
|
|
@@ -49,7 +49,7 @@ def download_binary(url, binary, expected):
|
|
|
49
49
|
|
|
50
50
|
class CustomBuildHook(BuildHookInterface):
|
|
51
51
|
def initialize(self, version, build_data):
|
|
52
|
-
if self.target_name
|
|
52
|
+
if self.target_name not in {"wheel", "editable"}:
|
|
53
53
|
return
|
|
54
54
|
root = Path(self.root)
|
|
55
55
|
manifest = json.loads((root / "binaries.json").read_text())
|
|
@@ -60,14 +60,24 @@ class CustomBuildHook(BuildHookInterface):
|
|
|
60
60
|
raise RuntimeError(f"No official standalone Tailwind binary for {target}")
|
|
61
61
|
suffix = ".exe" if target.startswith("windows-") else ""
|
|
62
62
|
asset = f"tailwindcss-{target}{suffix}"
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
binary = (
|
|
64
|
+
root
|
|
65
|
+
/ "src"
|
|
66
|
+
/ "fasthtml_tailwindcss_cli"
|
|
67
|
+
/ "bin"
|
|
68
|
+
/ f"tailwindcss{suffix}"
|
|
69
|
+
)
|
|
65
70
|
binary.parent.mkdir(parents=True, exist_ok=True)
|
|
66
|
-
url =
|
|
67
|
-
|
|
71
|
+
url = (
|
|
72
|
+
"https://github.com/tailwindlabs/tailwindcss/releases/download/"
|
|
73
|
+
f"v{manifest['version']}/{asset}"
|
|
74
|
+
)
|
|
75
|
+
download_binary(url, binary, manifest["sha256"][asset])
|
|
68
76
|
binary.chmod(0o755)
|
|
77
|
+
if self.target_name == "editable":
|
|
78
|
+
return
|
|
69
79
|
build_data["pure_python"] = False
|
|
70
80
|
build_data["tag"] = f"py3-none-{TARGETS[target]}"
|
|
71
81
|
build_data["artifacts"].append(
|
|
72
|
-
f"src/
|
|
82
|
+
f"src/fasthtml_tailwindcss_cli/bin/tailwindcss{suffix}"
|
|
73
83
|
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fasthtml-tailwindcss-cli"
|
|
3
|
+
version = "4.3.3"
|
|
4
|
+
description = "Platform-specific Tailwind CSS standalone CLI binary for fasthtml-tailwindcss."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE", "TAILWIND-LICENSE"]
|
|
9
|
+
authors = [{ name = "SpaceShaman", email = "spaceshaman@tuta.io" }]
|
|
10
|
+
keywords = ["tailwindcss", "cli", "binary"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
"Programming Language :: Python :: 3.13",
|
|
17
|
+
"Programming Language :: Python :: 3.14",
|
|
18
|
+
"Programming Language :: Python :: 3.15",
|
|
19
|
+
"Topic :: Software Development :: Build Tools",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["hatchling>=1.27"]
|
|
24
|
+
build-backend = "hatchling.build"
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
packages = ["src/fasthtml_tailwindcss_cli"]
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.sdist]
|
|
30
|
+
include = ["/src", "/hatch_build.py", "/binaries.json", "/pyproject.toml", "/README.md", "/LICENSE", "/TAILWIND-LICENSE"]
|
|
31
|
+
exclude = ["/src/fasthtml_tailwindcss_cli/bin"]
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.hooks.custom]
|
|
34
|
+
path = "hatch_build.py"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fasthtml-tailwindcss"
|
|
3
|
-
version = "4.3.3"
|
|
4
|
-
description = "Tailwind CSS for FastHTML with a persistent
|
|
3
|
+
version = "4.3.3.post1"
|
|
4
|
+
description = "Tailwind CSS for FastHTML with a persistent development watcher and a build command for production CSS."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
license = "MIT"
|
|
8
|
-
license-files = ["LICENSE"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
9
|
authors = [{ name = "SpaceShaman", email = "spaceshaman@tuta.io" }]
|
|
10
10
|
keywords = ["components", "css", "fasthtml", "tailwindcss", "web"]
|
|
11
11
|
classifiers = [
|
|
@@ -19,7 +19,16 @@ classifiers = [
|
|
|
19
19
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
20
|
"Typing :: Typed",
|
|
21
21
|
]
|
|
22
|
-
dependencies = ["filelock>=3.16", "
|
|
22
|
+
dependencies = ["filelock>=3.16", "python-fasthtml>=0.14.13"]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = ["fasthtml-tailwindcss-cli>=4,<5"]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
fasthtml-tailwindcss = "fasthtml_tailwindcss.build:main"
|
|
29
|
+
|
|
30
|
+
[tool.uv.sources]
|
|
31
|
+
fasthtml-tailwindcss-cli = { path = "packages/cli" }
|
|
23
32
|
|
|
24
33
|
[project.urls]
|
|
25
34
|
Documentation = "https://github.com/SpaceShaman/fasthtml-tailwindcss#readme"
|
|
@@ -28,6 +37,7 @@ Issues = "https://github.com/SpaceShaman/fasthtml-tailwindcss/issues"
|
|
|
28
37
|
Repository = "https://github.com/SpaceShaman/fasthtml-tailwindcss"
|
|
29
38
|
|
|
30
39
|
[dependency-groups]
|
|
40
|
+
build = ["hatchling>=1.27"]
|
|
31
41
|
test = ["httpx", "pytest", "uvicorn"]
|
|
32
42
|
|
|
33
43
|
[build-system]
|
|
@@ -38,8 +48,5 @@ build-backend = "hatchling.build"
|
|
|
38
48
|
packages = ["src/fasthtml_tailwindcss"]
|
|
39
49
|
|
|
40
50
|
[tool.hatch.build.targets.sdist]
|
|
41
|
-
include = ["/src", "/
|
|
42
|
-
exclude = ["/src/
|
|
43
|
-
|
|
44
|
-
[tool.hatch.build.hooks.custom]
|
|
45
|
-
path = "hatch_build.py"
|
|
51
|
+
include = ["/src", "/packages/cli", "/pyproject.toml", "/README.md", "/LICENSE", "/tests", "/scripts"]
|
|
52
|
+
exclude = ["/packages/cli/src/fasthtml_tailwindcss_cli/bin"]
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import re
|
|
4
|
+
import tomllib
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from urllib.error import HTTPError
|
|
7
|
+
from urllib.request import Request, urlopen
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def github_json(url):
|
|
11
|
+
headers = {
|
|
12
|
+
"Accept": "application/vnd.github+json",
|
|
13
|
+
"User-Agent": "fasthtml-tailwindcss",
|
|
14
|
+
}
|
|
15
|
+
if token := os.environ.get("GH_TOKEN"):
|
|
16
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
17
|
+
with urlopen(Request(url, headers=headers), timeout=30) as response:
|
|
18
|
+
return json.load(response)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def project_version(path):
|
|
22
|
+
return tomllib.loads(Path(path).read_text())["project"]["version"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def set_project_version(path, version):
|
|
26
|
+
path = Path(path)
|
|
27
|
+
text = path.read_text()
|
|
28
|
+
path.write_text(
|
|
29
|
+
re.sub(r'(?m)^version = "[^"]+"$', f'version = "{version}"', text, count=1)
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def pypi_files(name, version):
|
|
34
|
+
try:
|
|
35
|
+
with urlopen(
|
|
36
|
+
f"https://pypi.org/pypi/{name}/{version}/json", timeout=30
|
|
37
|
+
) as response:
|
|
38
|
+
return {item["filename"] for item in json.load(response)["urls"]}
|
|
39
|
+
except HTTPError as error:
|
|
40
|
+
if error.code != 404:
|
|
41
|
+
raise
|
|
42
|
+
return set()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
manifest_path = Path("packages/cli/binaries.json")
|
|
46
|
+
cli_project = Path("packages/cli/pyproject.toml")
|
|
47
|
+
cli_license = Path("packages/cli/TAILWIND-LICENSE")
|
|
48
|
+
wrapper_project = Path("pyproject.toml")
|
|
49
|
+
wrapper_version = project_version(wrapper_project)
|
|
50
|
+
cli_version = project_version(cli_project)
|
|
51
|
+
manifest = json.loads(manifest_path.read_text())
|
|
52
|
+
if cli_version.split(".post")[0] != manifest["version"]:
|
|
53
|
+
raise ValueError("CLI package version must match binaries.json")
|
|
54
|
+
release = github_json(
|
|
55
|
+
"https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest"
|
|
56
|
+
)
|
|
57
|
+
latest = release["tag_name"].removeprefix("v")
|
|
58
|
+
if not re.fullmatch(r"\d+\.\d+\.\d+", latest):
|
|
59
|
+
raise ValueError(f"Expected a stable Tailwind release, got {latest!r}")
|
|
60
|
+
|
|
61
|
+
if tuple(map(int, latest.split("."))) > tuple(
|
|
62
|
+
map(int, cli_version.split(".post")[0].split("."))
|
|
63
|
+
):
|
|
64
|
+
hashes = {}
|
|
65
|
+
for asset in release["assets"]:
|
|
66
|
+
if asset["name"] in manifest["sha256"]:
|
|
67
|
+
digest = asset.get("digest", "")
|
|
68
|
+
if not re.fullmatch(r"sha256:[0-9a-f]{64}", digest):
|
|
69
|
+
raise RuntimeError(f"Missing SHA256 digest for {asset['name']}")
|
|
70
|
+
hashes[asset["name"]] = digest.removeprefix("sha256:")
|
|
71
|
+
if hashes.keys() != manifest["sha256"].keys():
|
|
72
|
+
raise RuntimeError("Upstream release is missing a supported platform")
|
|
73
|
+
manifest_path.write_text(
|
|
74
|
+
json.dumps({"version": latest, "sha256": hashes}, indent=2) + "\n"
|
|
75
|
+
)
|
|
76
|
+
with urlopen(
|
|
77
|
+
f"https://raw.githubusercontent.com/tailwindlabs/tailwindcss/v{latest}/LICENSE",
|
|
78
|
+
timeout=30,
|
|
79
|
+
) as response:
|
|
80
|
+
cli_license.write_bytes(response.read())
|
|
81
|
+
set_project_version(cli_project, latest)
|
|
82
|
+
set_project_version(wrapper_project, latest)
|
|
83
|
+
wrapper_version = cli_version = latest
|
|
84
|
+
|
|
85
|
+
wrapper_expected = {
|
|
86
|
+
f"fasthtml_tailwindcss-{wrapper_version}-py3-none-any.whl",
|
|
87
|
+
f"fasthtml_tailwindcss-{wrapper_version}.tar.gz",
|
|
88
|
+
}
|
|
89
|
+
tags = [
|
|
90
|
+
"manylinux_2_28_x86_64",
|
|
91
|
+
"manylinux_2_28_aarch64",
|
|
92
|
+
"musllinux_1_2_x86_64",
|
|
93
|
+
"musllinux_1_2_aarch64",
|
|
94
|
+
"macosx_13_0_x86_64",
|
|
95
|
+
"macosx_13_0_arm64",
|
|
96
|
+
"win_amd64",
|
|
97
|
+
]
|
|
98
|
+
cli_expected = {
|
|
99
|
+
f"fasthtml_tailwindcss_cli-{cli_version}-py3-none-{tag}.whl" for tag in tags
|
|
100
|
+
}
|
|
101
|
+
cli_expected.add(f"fasthtml_tailwindcss_cli-{cli_version}.tar.gz")
|
|
102
|
+
wrapper_missing = wrapper_expected - pypi_files(
|
|
103
|
+
"fasthtml-tailwindcss", wrapper_version
|
|
104
|
+
)
|
|
105
|
+
cli_missing = cli_expected - pypi_files("fasthtml-tailwindcss-cli", cli_version)
|
|
106
|
+
|
|
107
|
+
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
|
|
108
|
+
output.write(f"version={wrapper_version}\n")
|
|
109
|
+
output.write(f"release={str(bool(wrapper_missing or cli_missing)).lower()}\n")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import tomllib
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from urllib.error import HTTPError
|
|
5
|
+
from urllib.request import urlopen
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def published_files(project, release):
|
|
9
|
+
try:
|
|
10
|
+
with urlopen(
|
|
11
|
+
f"https://pypi.org/pypi/{project}/{release}/json", timeout=30
|
|
12
|
+
) as response:
|
|
13
|
+
return {item["filename"] for item in json.load(response)["urls"]}
|
|
14
|
+
except HTTPError as error:
|
|
15
|
+
if error.code == 404:
|
|
16
|
+
return set()
|
|
17
|
+
raise
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
for path in (Path("pyproject.toml"), Path("packages/cli/pyproject.toml")):
|
|
21
|
+
project = tomllib.loads(path.read_text())["project"]
|
|
22
|
+
published = published_files(project["name"], project["version"])
|
|
23
|
+
for artifact in Path("dist").iterdir():
|
|
24
|
+
if artifact.name in published:
|
|
25
|
+
artifact.unlink()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from weakref import finalize
|
|
4
|
+
|
|
5
|
+
from fasthtml.common import Link, vurl
|
|
6
|
+
|
|
7
|
+
from .client import Session
|
|
8
|
+
from .config import configuration
|
|
9
|
+
|
|
10
|
+
__all__ = ["TailwindHead"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TailwindHead:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
watch: bool = False,
|
|
18
|
+
sources: Sequence[str | Path] | None = None,
|
|
19
|
+
input: str | Path | None = None,
|
|
20
|
+
css: str | None = None,
|
|
21
|
+
output: str | Path = "./static/tailwind.css",
|
|
22
|
+
) -> None:
|
|
23
|
+
self._config = configuration(
|
|
24
|
+
sources=sources, input=input, css=css, output=output
|
|
25
|
+
)
|
|
26
|
+
(Path(self._config.root) / self._config.output).parent.mkdir(
|
|
27
|
+
parents=True, exist_ok=True
|
|
28
|
+
)
|
|
29
|
+
self._session = Session(self._config) if watch else None
|
|
30
|
+
if self._session is not None:
|
|
31
|
+
finalize(self, self._session.close)
|
|
32
|
+
|
|
33
|
+
def __deepcopy__(self, memo):
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
def __ft__(self):
|
|
37
|
+
if self._session is not None:
|
|
38
|
+
self._session.start()
|
|
39
|
+
if self._session.error:
|
|
40
|
+
raise RuntimeError(self._session.error)
|
|
41
|
+
path = "/" + self._config.output
|
|
42
|
+
return Link(rel="stylesheet", href=vurl(path, root=self._config.root))
|