pytailwindcss 0.2.0__tar.gz → 0.3.1__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.
@@ -0,0 +1,50 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
+
4
+ name: Run tests
5
+
6
+ on:
7
+ push:
8
+ pull_request:
9
+
10
+ jobs:
11
+ tests:
12
+
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: [ "3.11", "3.12", "3.13", "3.14" ]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v6
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ - name: Install dependencies
25
+ run: uv sync
26
+ - name: Test with pytest
27
+ run: uv run pytest
28
+
29
+ release:
30
+ needs: [ tests ]
31
+ if: success() && startsWith(github.ref, 'refs/tags/')
32
+ runs-on: ubuntu-24.04
33
+ environment: release
34
+
35
+ permissions:
36
+ contents: read
37
+ id-token: write
38
+
39
+ steps:
40
+ - uses: actions/checkout@v5
41
+
42
+ - name: Install uv
43
+ uses: astral-sh/setup-uv@v6
44
+ with:
45
+ python-version: '3.11'
46
+
47
+ - name: Build
48
+ run: uv build
49
+
50
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,18 @@
1
+ name: pre-commit
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [ main ]
7
+
8
+ jobs:
9
+ pre-commit:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0
15
+ - uses: actions/setup-python@v2
16
+ - uses: pre-commit/action@v3.0.0
17
+ with:
18
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,145 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # pytype static type analyzer
135
+ .pytype/
136
+
137
+ # Cython debug symbols
138
+ cython_debug/
139
+
140
+ .DS_Store
141
+ .idea
142
+ src/pytailwindcss/bin
143
+ src/tests/build
144
+ .claude
145
+ .history
@@ -0,0 +1,36 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.4.0
4
+ hooks:
5
+ - id: check-added-large-files
6
+ - id: check-ast
7
+ - id: check-case-conflict
8
+ - id: check-json
9
+ - id: check-merge-conflict
10
+ - id: check-symlinks
11
+ - id: check-yaml
12
+ - id: debug-statements
13
+ - id: detect-private-key
14
+ - id: end-of-file-fixer
15
+ - id: trailing-whitespace
16
+ - id: mixed-line-ending
17
+ - id: requirements-txt-fixer
18
+ - repo: https://github.com/psf/black
19
+ rev: 23.3.0
20
+ hooks:
21
+ - id: black
22
+ args: [ --line-length=119 ]
23
+ - repo: https://github.com/pycqa/isort
24
+ rev: 5.12.0
25
+ hooks:
26
+ - id: isort
27
+ args: [ "--profile", "black", "--filter-files" ]
28
+ - repo: https://github.com/PyCQA/flake8
29
+ rev: 6.0.0
30
+ hooks:
31
+ - id: flake8
32
+ additional_dependencies:
33
+ - flake8-bugbear
34
+ - flake8-comprehensions
35
+ - flake8-tidy-imports
36
+ - flake8-typing-imports
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytailwindcss
3
+ Version: 0.3.1
4
+ Summary: Standalone Tailwind CSS CLI, installable via pip. Use Tailwind CSS without Node.js.
5
+ Project-URL: Homepage, https://github.com/timonweb/pytailwindcss
6
+ Author-email: Tim Kamanin <tim@timonweb.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: cli,css,tailwind
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
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 :: Libraries
20
+ Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Standalone Tailwind CSS CLI, installable via pip
25
+
26
+ Use *Tailwind CSS* without *Node.js* — install it via pip.
27
+
28
+ ## Why
29
+
30
+ *Tailwind CSS* is notoriously dependent on *Node.js*. If you're a *Python* developer, this dependency may not be welcome
31
+ in your team, your Docker container, or your inner circle.
32
+
33
+ The *Tailwind CSS* team recently announced a new standalone CLI build that gives you the full power of *Tailwind CLI* in
34
+ a self-contained executable — no *Node.js* or `npm` required.
35
+
36
+ However, installing the standalone CLI isn't as easy as running `npm install`.
37
+
38
+ That's why I created this package to make it as simple as running the `pip install` command. Now you can install the standalone *Tailwind CLI* via `pip` by running:
39
+
40
+ ```bash
41
+ pip install pytailwindcss
42
+ ```
43
+
44
+ Now you can run `tailwindcss` in your terminal:
45
+
46
+ ```bash
47
+ tailwindcss -i input.css -o output.css --minify
48
+ ```
49
+
50
+ Voilà!
51
+
52
+ ## Get started
53
+
54
+ 1. Install `pytailwindcss` via `pip`:
55
+
56
+ ```bash
57
+ pip install pytailwindcss
58
+ ```
59
+
60
+ 2. **[Recommended]** Preinstall the `tailwindcss` binary:
61
+
62
+ ```bash
63
+ tailwindcss_install
64
+ ```
65
+
66
+ By default, the latest binary version will be downloaded. To pin to a specific Tailwind CSS version, set the `TAILWINDCSS_VERSION` environment variable before running the command:
67
+
68
+ ```bash
69
+ # In a Dockerfile
70
+ ENV TAILWINDCSS_VERSION=v4.1.16
71
+ RUN tailwindcss_install
72
+
73
+ # On Linux/macOS
74
+ export TAILWINDCSS_VERSION=v4.1.16
75
+ tailwindcss_install
76
+
77
+ # On Windows (cmd)
78
+ set TAILWINDCSS_VERSION=v4.1.16
79
+ tailwindcss_install
80
+
81
+ # On Windows (PowerShell)
82
+ $env:TAILWINDCSS_VERSION="v4.1.16"
83
+ tailwindcss_install
84
+ ```
85
+
86
+ To see a list of available Tailwind CSS releases, visit: https://github.com/tailwindlabs/tailwindcss/releases
87
+
88
+ If you skip this step, the binary will be downloaded automatically on the first run of the `tailwindcss` command.
89
+
90
+ 3. The `tailwindcss` command should now be available in your terminal. Try running it:
91
+
92
+ ```bash
93
+ tailwindcss
94
+ ```
95
+
96
+ You should see the help output for the `tailwindcss` command. If you skipped step 2, the binary will be downloaded automatically on this first run. Use `tailwindcss` to create a new project or work with an existing *Tailwind CSS* project.
97
+
98
+ 4. Create a new *Tailwind CSS* project by navigating to your project directory and initializing it:
99
+
100
+ ```bash
101
+ tailwindcss init
102
+ ```
103
+
104
+ This command creates the default *tailwind.config.js* file.
105
+
106
+ 5. Start a watcher to compile CSS automatically during development:
107
+
108
+ ```bash
109
+ tailwindcss -i input.css -o output.css --watch
110
+ ```
111
+
112
+ 6. Compile and minify your CSS for production:
113
+
114
+ ```bash
115
+ tailwindcss -i input.css -o output.css --minify
116
+ ```
117
+
118
+ That's it! For more information on using *Tailwind CSS* and its CLI, refer to the [official Tailwind CSS documentation](https://tailwindcss.com/docs).
119
+
120
+ ## Caveats
121
+
122
+ While this approach simplifies your setup, there are some trade-offs. Without *Node.js*, you won't be able to install third-party plugins or additional dependencies for your *Tailwind CSS* setup. However, this might not be a dealbreaker for most use cases.
123
+
124
+ You can still customize *Tailwind CSS* via the *tailwind.config.js* file, and the standalone build includes all official *Tailwind CSS* plugins: `@tailwindcss/aspect-ratio`, `@tailwindcss/forms`, `@tailwindcss/line-clamp`, and `@tailwindcss/typography`. This covers approximately 90% of typical *Tailwind CSS* usage scenarios.
125
+
126
+ Here's what the *Tailwind CSS* team says about the standalone build:
127
+ > If you're working on a project where you don't otherwise need *Node.js* or `npm`, the standalone build can be a great choice. If Tailwind was the only reason you had a package.json file, this is probably going to feel like a nicer solution.
128
+
129
+ ## Bugs and Suggestions
130
+
131
+ Found a bug or have a suggestion? Please use the issue tracker on GitHub:
132
+
133
+ [https://github.com/timonweb/pytailwindcss/issues](https://github.com/timonweb/pytailwindcss/issues)
134
+
135
+ 2021 - 2025 (c) Tim Kamanin — [A Full-Stack Django and Wagtail Developer](https://timonweb.com)
@@ -0,0 +1,112 @@
1
+ # Standalone Tailwind CSS CLI, installable via pip
2
+
3
+ Use *Tailwind CSS* without *Node.js* — install it via pip.
4
+
5
+ ## Why
6
+
7
+ *Tailwind CSS* is notoriously dependent on *Node.js*. If you're a *Python* developer, this dependency may not be welcome
8
+ in your team, your Docker container, or your inner circle.
9
+
10
+ The *Tailwind CSS* team recently announced a new standalone CLI build that gives you the full power of *Tailwind CLI* in
11
+ a self-contained executable — no *Node.js* or `npm` required.
12
+
13
+ However, installing the standalone CLI isn't as easy as running `npm install`.
14
+
15
+ That's why I created this package to make it as simple as running the `pip install` command. Now you can install the standalone *Tailwind CLI* via `pip` by running:
16
+
17
+ ```bash
18
+ pip install pytailwindcss
19
+ ```
20
+
21
+ Now you can run `tailwindcss` in your terminal:
22
+
23
+ ```bash
24
+ tailwindcss -i input.css -o output.css --minify
25
+ ```
26
+
27
+ Voilà!
28
+
29
+ ## Get started
30
+
31
+ 1. Install `pytailwindcss` via `pip`:
32
+
33
+ ```bash
34
+ pip install pytailwindcss
35
+ ```
36
+
37
+ 2. **[Recommended]** Preinstall the `tailwindcss` binary:
38
+
39
+ ```bash
40
+ tailwindcss_install
41
+ ```
42
+
43
+ By default, the latest binary version will be downloaded. To pin to a specific Tailwind CSS version, set the `TAILWINDCSS_VERSION` environment variable before running the command:
44
+
45
+ ```bash
46
+ # In a Dockerfile
47
+ ENV TAILWINDCSS_VERSION=v4.1.16
48
+ RUN tailwindcss_install
49
+
50
+ # On Linux/macOS
51
+ export TAILWINDCSS_VERSION=v4.1.16
52
+ tailwindcss_install
53
+
54
+ # On Windows (cmd)
55
+ set TAILWINDCSS_VERSION=v4.1.16
56
+ tailwindcss_install
57
+
58
+ # On Windows (PowerShell)
59
+ $env:TAILWINDCSS_VERSION="v4.1.16"
60
+ tailwindcss_install
61
+ ```
62
+
63
+ To see a list of available Tailwind CSS releases, visit: https://github.com/tailwindlabs/tailwindcss/releases
64
+
65
+ If you skip this step, the binary will be downloaded automatically on the first run of the `tailwindcss` command.
66
+
67
+ 3. The `tailwindcss` command should now be available in your terminal. Try running it:
68
+
69
+ ```bash
70
+ tailwindcss
71
+ ```
72
+
73
+ You should see the help output for the `tailwindcss` command. If you skipped step 2, the binary will be downloaded automatically on this first run. Use `tailwindcss` to create a new project or work with an existing *Tailwind CSS* project.
74
+
75
+ 4. Create a new *Tailwind CSS* project by navigating to your project directory and initializing it:
76
+
77
+ ```bash
78
+ tailwindcss init
79
+ ```
80
+
81
+ This command creates the default *tailwind.config.js* file.
82
+
83
+ 5. Start a watcher to compile CSS automatically during development:
84
+
85
+ ```bash
86
+ tailwindcss -i input.css -o output.css --watch
87
+ ```
88
+
89
+ 6. Compile and minify your CSS for production:
90
+
91
+ ```bash
92
+ tailwindcss -i input.css -o output.css --minify
93
+ ```
94
+
95
+ That's it! For more information on using *Tailwind CSS* and its CLI, refer to the [official Tailwind CSS documentation](https://tailwindcss.com/docs).
96
+
97
+ ## Caveats
98
+
99
+ While this approach simplifies your setup, there are some trade-offs. Without *Node.js*, you won't be able to install third-party plugins or additional dependencies for your *Tailwind CSS* setup. However, this might not be a dealbreaker for most use cases.
100
+
101
+ You can still customize *Tailwind CSS* via the *tailwind.config.js* file, and the standalone build includes all official *Tailwind CSS* plugins: `@tailwindcss/aspect-ratio`, `@tailwindcss/forms`, `@tailwindcss/line-clamp`, and `@tailwindcss/typography`. This covers approximately 90% of typical *Tailwind CSS* usage scenarios.
102
+
103
+ Here's what the *Tailwind CSS* team says about the standalone build:
104
+ > If you're working on a project where you don't otherwise need *Node.js* or `npm`, the standalone build can be a great choice. If Tailwind was the only reason you had a package.json file, this is probably going to feel like a nicer solution.
105
+
106
+ ## Bugs and Suggestions
107
+
108
+ Found a bug or have a suggestion? Please use the issue tracker on GitHub:
109
+
110
+ [https://github.com/timonweb/pytailwindcss/issues](https://github.com/timonweb/pytailwindcss/issues)
111
+
112
+ 2021 - 2025 (c) Tim Kamanin — [A Full-Stack Django and Wagtail Developer](https://timonweb.com)
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "pytailwindcss"
3
+ version = "0.3.1"
4
+ description = "Standalone Tailwind CSS CLI, installable via pip. Use Tailwind CSS without Node.js."
5
+ authors = [{ name = "Tim Kamanin", email = "tim@timonweb.com" }]
6
+ readme = "README.md"
7
+ license = { text = "MIT" }
8
+ keywords = ["cli", "tailwind", "css"]
9
+ requires-python = ">=3.11"
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: MIT License",
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
+ "Operating System :: OS Independent",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Topic :: Utilities",
21
+ "Environment :: Web Environment"
22
+ ]
23
+ dependencies = []
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/timonweb/pytailwindcss"
27
+
28
+ [project.scripts]
29
+ tailwindcss = "pytailwindcss.__main__:main"
30
+ tailwindcss_install = "pytailwindcss.__main__:install"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "pytest>=9.0.3",
35
+ "pre-commit>=4.6.0",
36
+ ]
37
+
38
+ [build-system]
39
+ requires = ["hatchling"]
40
+ build-backend = "hatchling.build"
41
+
42
+ [tool.hatch.build.targets.wheel]
43
+ packages = ["src/pytailwindcss"]
@@ -9,7 +9,7 @@ def make_subprocess_run_kwargs(cwd=None, env=None, live_output=False):
9
9
  """
10
10
  opts = {
11
11
  "cwd": cwd or os.getcwd(),
12
- "env": env or {},
12
+ "env": env or None,
13
13
  }
14
14
  if live_output is False:
15
15
  opts.update(
File without changes
@@ -0,0 +1,22 @@
1
+ import os
2
+ import shutil
3
+ from contextlib import contextmanager
4
+
5
+
6
+ @contextmanager
7
+ def clean_dir(path):
8
+ delete_anything(path)
9
+ try:
10
+ yield
11
+ finally:
12
+ delete_anything(path)
13
+
14
+
15
+ def delete_anything(path):
16
+ path = str(path)
17
+ if not os.path.exists(path):
18
+ return None
19
+
20
+ if os.path.isfile(path):
21
+ return os.remove(path)
22
+ return shutil.rmtree(path)
@@ -0,0 +1,38 @@
1
+ import pytest
2
+
3
+ import pytailwindcss
4
+ from pytailwindcss.exceptions import PyTailwindCssBinaryNotFound
5
+ from pytailwindcss.utils import get_bin_path
6
+
7
+ from .contexts import clean_dir
8
+
9
+
10
+ def test_successful_run():
11
+ """
12
+ It installs the executable and successfully runs the CLI.
13
+ """
14
+ with clean_dir(get_bin_path()):
15
+ pytailwindcss.install()
16
+ output = pytailwindcss.run("--help")
17
+ assert "tailwindcss" in output.lower()
18
+
19
+
20
+ def test_successful_run_from_custom_bin_path():
21
+ """
22
+ It installs the executable and successfully runs the CLI from a custom path.
23
+ """
24
+ ALTERNATIVE_BIN_PATH = "/tmp/test-bin/tailwindcss"
25
+
26
+ with clean_dir(ALTERNATIVE_BIN_PATH):
27
+ pytailwindcss.install(bin_path=ALTERNATIVE_BIN_PATH)
28
+ output = pytailwindcss.run("--help", bin_path=ALTERNATIVE_BIN_PATH)
29
+ assert "tailwindcss" in output.lower()
30
+
31
+
32
+ def test_unsuccessful_run():
33
+ """
34
+ It fails to run build command because executable is not installed.
35
+ """
36
+ with clean_dir(get_bin_path()):
37
+ with pytest.raises(PyTailwindCssBinaryNotFound):
38
+ pytailwindcss.run("build")