python-lucide 0.2.12__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.
- python_lucide-0.2.12/PKG-INFO +318 -0
- python_lucide-0.2.12/README.md +296 -0
- python_lucide-0.2.12/pyproject.toml +140 -0
- python_lucide-0.2.12/src/lucide/__init__.py +18 -0
- python_lucide-0.2.12/src/lucide/cli.py +418 -0
- python_lucide-0.2.12/src/lucide/config.py +10 -0
- python_lucide-0.2.12/src/lucide/core.py +281 -0
- python_lucide-0.2.12/src/lucide/data/__init__.py +5 -0
- python_lucide-0.2.12/src/lucide/data/lucide-icons.db +0 -0
- python_lucide-0.2.12/src/lucide/db.py +104 -0
- python_lucide-0.2.12/src/lucide/dev_utils.py +260 -0
- python_lucide-0.2.12/tests/__init__.py +1 -0
- python_lucide-0.2.12/tests/cli_test.py +153 -0
- python_lucide-0.2.12/tests/core_test.py +578 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: python-lucide
|
|
3
|
+
Version: 0.2.12
|
|
4
|
+
Summary: A Python package for working with Lucide icons
|
|
5
|
+
Keywords: lucide,icons,svg,sqlite
|
|
6
|
+
Author: Mike Macpherson
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Project-URL: Bug Tracker, https://github.com/mmacpherson/python-lucide/issues
|
|
19
|
+
Project-URL: Homepage, https://github.com/mmacpherson/python-lucide
|
|
20
|
+
Project-URL: Source Code, https://github.com/mmacpherson/python-lucide
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# python-lucide
|
|
24
|
+
|
|
25
|
+
[](https://badge.fury.io/py/python-lucide)
|
|
26
|
+
[](https://pypi.org/project/python-lucide/)
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
[](https://github.com/mmacpherson/python-lucide/actions/workflows/ci.yml)
|
|
29
|
+
[](https://github.com/lucide-icons/lucide/releases)
|
|
30
|
+
[](https://pypi.org/project/python-lucide/)
|
|
31
|
+
[](https://github.com/astral-sh/uv)
|
|
32
|
+
|
|
33
|
+
A Python package that provides easy access to all [Lucide
|
|
34
|
+
icons](https://lucide.dev/) as SVG strings. Just import and use any Lucide icon
|
|
35
|
+
in your Python projects, with no javascript in sight.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
- 🎨 **Access 1600+ Lucide icons** directly from Python
|
|
39
|
+
- 🛠**Customize icons** with classes, sizes, colors, and other SVG attributes
|
|
40
|
+
- 🚀 **Framework-friendly** with examples for FastHTML, Flask, Django, and more
|
|
41
|
+
- 📦 **Lightweight** with minimal dependencies
|
|
42
|
+
- 🔧 **Customizable icon sets** - include only the icons you need
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
```bash
|
|
46
|
+
pip install python-lucide
|
|
47
|
+
```
|
|
48
|
+
This installs the package with a pre-built database of all Lucide icons, ready to use immediately.
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
```python
|
|
52
|
+
from lucide import lucide_icon
|
|
53
|
+
|
|
54
|
+
# Get an icon
|
|
55
|
+
svg = lucide_icon("house")
|
|
56
|
+
|
|
57
|
+
# Add CSS classes
|
|
58
|
+
svg = lucide_icon("settings", cls="icon icon-settings")
|
|
59
|
+
|
|
60
|
+
# Customize size
|
|
61
|
+
svg = lucide_icon("arrow-up", width="32", height="32")
|
|
62
|
+
|
|
63
|
+
# Customize colors (stroke for outline, fill for interior)
|
|
64
|
+
svg = lucide_icon("heart", stroke="red", fill="pink")
|
|
65
|
+
|
|
66
|
+
# Customize stroke properties
|
|
67
|
+
svg = lucide_icon("chart-line", stroke_width="3", stroke_linecap="round")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Icon Customization
|
|
71
|
+
All Lucide icons use `stroke` for their outline color and `fill` for their interior color:
|
|
72
|
+
```python
|
|
73
|
+
# Looking for how to change colors? Use stroke and fill:
|
|
74
|
+
lucide_icon("user", stroke="blue") # Blue outline
|
|
75
|
+
lucide_icon("user", fill="currentColor") # Inherit color from CSS
|
|
76
|
+
lucide_icon("user", stroke="#ff6b6b") # Hex colors work too
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Framework Integration Examples
|
|
80
|
+
|
|
81
|
+
### FastHTML
|
|
82
|
+
```python
|
|
83
|
+
from fasthtml.common import *
|
|
84
|
+
from lucide import lucide_icon
|
|
85
|
+
|
|
86
|
+
app, rt = fast_app()
|
|
87
|
+
|
|
88
|
+
@rt('/')
|
|
89
|
+
def get():
|
|
90
|
+
return Titled("Hello Icons",
|
|
91
|
+
H1("Welcome"),
|
|
92
|
+
# Wrap icon output in NotStr to prevent HTML escaping
|
|
93
|
+
NotStr(lucide_icon("house", cls="icon")),
|
|
94
|
+
P("This is a simple FastHTML app with Lucide icons.")
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
serve()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Flask
|
|
101
|
+
```python
|
|
102
|
+
from flask import Flask
|
|
103
|
+
from lucide import lucide_icon
|
|
104
|
+
|
|
105
|
+
app = Flask(__name__)
|
|
106
|
+
|
|
107
|
+
@app.route('/icons/<icon_name>')
|
|
108
|
+
def serve_icon(icon_name):
|
|
109
|
+
svg = lucide_icon(icon_name, cls="icon", stroke="currentColor")
|
|
110
|
+
return svg, 200, {'Content-Type': 'image/svg+xml'}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Django
|
|
114
|
+
```python
|
|
115
|
+
# In your views.py
|
|
116
|
+
from django.http import HttpResponse
|
|
117
|
+
from lucide import lucide_icon
|
|
118
|
+
|
|
119
|
+
def icon_view(request, icon_name):
|
|
120
|
+
svg = lucide_icon(icon_name, cls="icon-lg", width="32", height="32")
|
|
121
|
+
return HttpResponse(svg, content_type='image/svg+xml')
|
|
122
|
+
|
|
123
|
+
# In your templates (as a template tag)
|
|
124
|
+
from django import template
|
|
125
|
+
from django.utils.safestring import mark_safe
|
|
126
|
+
from lucide import lucide_icon
|
|
127
|
+
|
|
128
|
+
register = template.Library()
|
|
129
|
+
|
|
130
|
+
@register.simple_tag
|
|
131
|
+
def icon(name, **kwargs):
|
|
132
|
+
return mark_safe(lucide_icon(name, **kwargs))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### FastAPI
|
|
136
|
+
```python
|
|
137
|
+
from fastapi import FastAPI
|
|
138
|
+
from fastapi.responses import Response
|
|
139
|
+
from lucide import lucide_icon
|
|
140
|
+
|
|
141
|
+
app = FastAPI()
|
|
142
|
+
|
|
143
|
+
@app.get("/icons/{icon_name}")
|
|
144
|
+
def get_icon(icon_name: str, size: int = 24, color: str = "currentColor"):
|
|
145
|
+
svg = lucide_icon(icon_name, width=size, height=size, stroke=color)
|
|
146
|
+
return Response(content=svg, media_type="image/svg+xml")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## API Reference
|
|
150
|
+
|
|
151
|
+
### `lucide_icon()`
|
|
152
|
+
Retrieves and customizes a Lucide icon.
|
|
153
|
+
```python
|
|
154
|
+
lucide_icon(
|
|
155
|
+
icon_name: str,
|
|
156
|
+
cls: str = "",
|
|
157
|
+
fallback_text: str | None = None,
|
|
158
|
+
width: str | int | None = None,
|
|
159
|
+
height: str | int | None = None,
|
|
160
|
+
fill: str | None = None,
|
|
161
|
+
stroke: str | None = None,
|
|
162
|
+
stroke_width: str | int | None = None,
|
|
163
|
+
stroke_linecap: str | None = None,
|
|
164
|
+
stroke_linejoin: str | None = None,
|
|
165
|
+
) -> str
|
|
166
|
+
```
|
|
167
|
+
**Parameters:**
|
|
168
|
+
- `icon_name`: Name of the Lucide icon to retrieve
|
|
169
|
+
- `cls`: CSS classes to add to the SVG element (space-separated)
|
|
170
|
+
- `fallback_text`: Text to display if the icon is not found
|
|
171
|
+
- `width`: Width of the SVG element
|
|
172
|
+
- `height`: Height of the SVG element
|
|
173
|
+
- `fill`: Fill color for the icon
|
|
174
|
+
- `stroke`: Stroke color for the icon (outline color)
|
|
175
|
+
- `stroke_width`: Width of the stroke
|
|
176
|
+
- `stroke_linecap`: How the ends of strokes are rendered ("round", "butt", "square")
|
|
177
|
+
- `stroke_linejoin`: How corners are rendered ("round", "miter", "bevel")
|
|
178
|
+
|
|
179
|
+
**Returns:** SVG string
|
|
180
|
+
|
|
181
|
+
**Example:**
|
|
182
|
+
```python
|
|
183
|
+
# Full customization example
|
|
184
|
+
icon = lucide_icon(
|
|
185
|
+
"activity",
|
|
186
|
+
cls="icon icon-activity animated",
|
|
187
|
+
width=48,
|
|
188
|
+
height=48,
|
|
189
|
+
stroke="rgb(59, 130, 246)",
|
|
190
|
+
stroke_width=2.5,
|
|
191
|
+
stroke_linecap="round",
|
|
192
|
+
stroke_linejoin="round"
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### `get_icon_list()`
|
|
197
|
+
Returns a list of all available icon names.
|
|
198
|
+
```python
|
|
199
|
+
from lucide import get_icon_list
|
|
200
|
+
|
|
201
|
+
icons = get_icon_list()
|
|
202
|
+
print(f"Available icons: {len(icons)}")
|
|
203
|
+
print(icons[:5]) # ['activity', 'airplay', 'alarm-check', ...]
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Advanced Usage
|
|
207
|
+
|
|
208
|
+
### Building a Custom Icon Set
|
|
209
|
+
If you want to include only specific icons or use a different version of Lucide:
|
|
210
|
+
```bash
|
|
211
|
+
# Build with specific icons only
|
|
212
|
+
lucide-db -i home,settings,user,heart,star -o custom-icons.db
|
|
213
|
+
|
|
214
|
+
# Use a specific Lucide version
|
|
215
|
+
lucide-db -t 0.350.0 -o lucide-v0.350.0.db
|
|
216
|
+
|
|
217
|
+
# Build from a file listing icon names
|
|
218
|
+
echo -e "home\nsettings\nuser" > my-icons.txt
|
|
219
|
+
lucide-db -f my-icons.txt -o my-icons.db
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Using a Custom Database
|
|
223
|
+
Set the `LUCIDE_DB_PATH` environment variable:
|
|
224
|
+
```bash
|
|
225
|
+
export LUCIDE_DB_PATH=/path/to/custom-icons.db
|
|
226
|
+
python your-app.py
|
|
227
|
+
```
|
|
228
|
+
Or configure it in your Python code:
|
|
229
|
+
```python
|
|
230
|
+
import os
|
|
231
|
+
os.environ['LUCIDE_DB_PATH'] = '/path/to/custom-icons.db'
|
|
232
|
+
|
|
233
|
+
from lucide import lucide_icon
|
|
234
|
+
# Will now use your custom database
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
This project uses `uv` for fast dependency management and `pre-commit` for code quality.
|
|
239
|
+
|
|
240
|
+
### Setup
|
|
241
|
+
```bash
|
|
242
|
+
# Clone the repository
|
|
243
|
+
git clone https://github.com/mmacpherson/python-lucide.git
|
|
244
|
+
cd python-lucide
|
|
245
|
+
|
|
246
|
+
# Create a virtual environment and install dependencies
|
|
247
|
+
make env
|
|
248
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
249
|
+
|
|
250
|
+
# Install pre-commit hooks
|
|
251
|
+
make install-hooks
|
|
252
|
+
|
|
253
|
+
# Run tests
|
|
254
|
+
make test
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Rebuilding the Icon Database
|
|
258
|
+
```bash
|
|
259
|
+
# Rebuild with latest Lucide icons
|
|
260
|
+
make lucide-db
|
|
261
|
+
|
|
262
|
+
# Rebuild with specific version
|
|
263
|
+
make lucide-db TAG=0.350.0
|
|
264
|
+
|
|
265
|
+
# Check if version updates are available
|
|
266
|
+
make check-lucide-version
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Version Checking and Automation
|
|
270
|
+
The project includes automated version checking and update capabilities:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Check for Lucide version updates and artifact status
|
|
274
|
+
make check-lucide-version
|
|
275
|
+
|
|
276
|
+
# Alternative: Use the CLI command directly
|
|
277
|
+
uv run check-lucide-version
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Weekly Automation**: The repository automatically checks for new Lucide releases every Monday and creates update PRs when new versions are available.
|
|
281
|
+
|
|
282
|
+
### Release Process
|
|
283
|
+
This project follows a manual release process:
|
|
284
|
+
|
|
285
|
+
1. **Update version** in `pyproject.toml`:
|
|
286
|
+
```bash
|
|
287
|
+
# Create release branch
|
|
288
|
+
git checkout -b release/v0.2.0
|
|
289
|
+
|
|
290
|
+
# Edit pyproject.toml to bump version
|
|
291
|
+
# version = "0.2.0"
|
|
292
|
+
|
|
293
|
+
# Commit and push
|
|
294
|
+
git add pyproject.toml
|
|
295
|
+
git commit -m "Bump version to 0.2.0"
|
|
296
|
+
git push -u origin release/v0.2.0
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
2. **Create and merge PR** for the version bump
|
|
300
|
+
|
|
301
|
+
3. **Trigger publishing workflow**:
|
|
302
|
+
- Go to [Actions](../../actions/workflows/publish.yml)
|
|
303
|
+
- Click "Run workflow"
|
|
304
|
+
- Select the main branch
|
|
305
|
+
- Click "Run workflow"
|
|
306
|
+
|
|
307
|
+
4. **Automatic publishing**: The `publish.yml` workflow builds and publishes the package to PyPI using trusted publishing.
|
|
308
|
+
|
|
309
|
+
## How It Works
|
|
310
|
+
The package comes with a pre-built SQLite database containing all Lucide icons. When you call `lucide_icon()`, it fetches the icon's SVG from the database and applies your customizations. This approach means:
|
|
311
|
+
- **Fast**: Icons are loaded from an efficient SQLite database
|
|
312
|
+
- **Offline**: No internet connection required at runtime
|
|
313
|
+
- **Customizable**: Build your own database with just the icons you need
|
|
314
|
+
- **Maintainable**: Update to newer Lucide versions by rebuilding the database
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
318
|
+
The Lucide icons themselves are also MIT licensed - see [Lucide's license](https://github.com/lucide-icons/lucide/blob/main/LICENSE).
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# python-lucide
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/python-lucide)
|
|
4
|
+
[](https://pypi.org/project/python-lucide/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/mmacpherson/python-lucide/actions/workflows/ci.yml)
|
|
7
|
+
[](https://github.com/lucide-icons/lucide/releases)
|
|
8
|
+
[](https://pypi.org/project/python-lucide/)
|
|
9
|
+
[](https://github.com/astral-sh/uv)
|
|
10
|
+
|
|
11
|
+
A Python package that provides easy access to all [Lucide
|
|
12
|
+
icons](https://lucide.dev/) as SVG strings. Just import and use any Lucide icon
|
|
13
|
+
in your Python projects, with no javascript in sight.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
- 🎨 **Access 1600+ Lucide icons** directly from Python
|
|
17
|
+
- 🛠**Customize icons** with classes, sizes, colors, and other SVG attributes
|
|
18
|
+
- 🚀 **Framework-friendly** with examples for FastHTML, Flask, Django, and more
|
|
19
|
+
- 📦 **Lightweight** with minimal dependencies
|
|
20
|
+
- 🔧 **Customizable icon sets** - include only the icons you need
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
```bash
|
|
24
|
+
pip install python-lucide
|
|
25
|
+
```
|
|
26
|
+
This installs the package with a pre-built database of all Lucide icons, ready to use immediately.
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
```python
|
|
30
|
+
from lucide import lucide_icon
|
|
31
|
+
|
|
32
|
+
# Get an icon
|
|
33
|
+
svg = lucide_icon("house")
|
|
34
|
+
|
|
35
|
+
# Add CSS classes
|
|
36
|
+
svg = lucide_icon("settings", cls="icon icon-settings")
|
|
37
|
+
|
|
38
|
+
# Customize size
|
|
39
|
+
svg = lucide_icon("arrow-up", width="32", height="32")
|
|
40
|
+
|
|
41
|
+
# Customize colors (stroke for outline, fill for interior)
|
|
42
|
+
svg = lucide_icon("heart", stroke="red", fill="pink")
|
|
43
|
+
|
|
44
|
+
# Customize stroke properties
|
|
45
|
+
svg = lucide_icon("chart-line", stroke_width="3", stroke_linecap="round")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Icon Customization
|
|
49
|
+
All Lucide icons use `stroke` for their outline color and `fill` for their interior color:
|
|
50
|
+
```python
|
|
51
|
+
# Looking for how to change colors? Use stroke and fill:
|
|
52
|
+
lucide_icon("user", stroke="blue") # Blue outline
|
|
53
|
+
lucide_icon("user", fill="currentColor") # Inherit color from CSS
|
|
54
|
+
lucide_icon("user", stroke="#ff6b6b") # Hex colors work too
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Framework Integration Examples
|
|
58
|
+
|
|
59
|
+
### FastHTML
|
|
60
|
+
```python
|
|
61
|
+
from fasthtml.common import *
|
|
62
|
+
from lucide import lucide_icon
|
|
63
|
+
|
|
64
|
+
app, rt = fast_app()
|
|
65
|
+
|
|
66
|
+
@rt('/')
|
|
67
|
+
def get():
|
|
68
|
+
return Titled("Hello Icons",
|
|
69
|
+
H1("Welcome"),
|
|
70
|
+
# Wrap icon output in NotStr to prevent HTML escaping
|
|
71
|
+
NotStr(lucide_icon("house", cls="icon")),
|
|
72
|
+
P("This is a simple FastHTML app with Lucide icons.")
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
serve()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Flask
|
|
79
|
+
```python
|
|
80
|
+
from flask import Flask
|
|
81
|
+
from lucide import lucide_icon
|
|
82
|
+
|
|
83
|
+
app = Flask(__name__)
|
|
84
|
+
|
|
85
|
+
@app.route('/icons/<icon_name>')
|
|
86
|
+
def serve_icon(icon_name):
|
|
87
|
+
svg = lucide_icon(icon_name, cls="icon", stroke="currentColor")
|
|
88
|
+
return svg, 200, {'Content-Type': 'image/svg+xml'}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Django
|
|
92
|
+
```python
|
|
93
|
+
# In your views.py
|
|
94
|
+
from django.http import HttpResponse
|
|
95
|
+
from lucide import lucide_icon
|
|
96
|
+
|
|
97
|
+
def icon_view(request, icon_name):
|
|
98
|
+
svg = lucide_icon(icon_name, cls="icon-lg", width="32", height="32")
|
|
99
|
+
return HttpResponse(svg, content_type='image/svg+xml')
|
|
100
|
+
|
|
101
|
+
# In your templates (as a template tag)
|
|
102
|
+
from django import template
|
|
103
|
+
from django.utils.safestring import mark_safe
|
|
104
|
+
from lucide import lucide_icon
|
|
105
|
+
|
|
106
|
+
register = template.Library()
|
|
107
|
+
|
|
108
|
+
@register.simple_tag
|
|
109
|
+
def icon(name, **kwargs):
|
|
110
|
+
return mark_safe(lucide_icon(name, **kwargs))
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### FastAPI
|
|
114
|
+
```python
|
|
115
|
+
from fastapi import FastAPI
|
|
116
|
+
from fastapi.responses import Response
|
|
117
|
+
from lucide import lucide_icon
|
|
118
|
+
|
|
119
|
+
app = FastAPI()
|
|
120
|
+
|
|
121
|
+
@app.get("/icons/{icon_name}")
|
|
122
|
+
def get_icon(icon_name: str, size: int = 24, color: str = "currentColor"):
|
|
123
|
+
svg = lucide_icon(icon_name, width=size, height=size, stroke=color)
|
|
124
|
+
return Response(content=svg, media_type="image/svg+xml")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## API Reference
|
|
128
|
+
|
|
129
|
+
### `lucide_icon()`
|
|
130
|
+
Retrieves and customizes a Lucide icon.
|
|
131
|
+
```python
|
|
132
|
+
lucide_icon(
|
|
133
|
+
icon_name: str,
|
|
134
|
+
cls: str = "",
|
|
135
|
+
fallback_text: str | None = None,
|
|
136
|
+
width: str | int | None = None,
|
|
137
|
+
height: str | int | None = None,
|
|
138
|
+
fill: str | None = None,
|
|
139
|
+
stroke: str | None = None,
|
|
140
|
+
stroke_width: str | int | None = None,
|
|
141
|
+
stroke_linecap: str | None = None,
|
|
142
|
+
stroke_linejoin: str | None = None,
|
|
143
|
+
) -> str
|
|
144
|
+
```
|
|
145
|
+
**Parameters:**
|
|
146
|
+
- `icon_name`: Name of the Lucide icon to retrieve
|
|
147
|
+
- `cls`: CSS classes to add to the SVG element (space-separated)
|
|
148
|
+
- `fallback_text`: Text to display if the icon is not found
|
|
149
|
+
- `width`: Width of the SVG element
|
|
150
|
+
- `height`: Height of the SVG element
|
|
151
|
+
- `fill`: Fill color for the icon
|
|
152
|
+
- `stroke`: Stroke color for the icon (outline color)
|
|
153
|
+
- `stroke_width`: Width of the stroke
|
|
154
|
+
- `stroke_linecap`: How the ends of strokes are rendered ("round", "butt", "square")
|
|
155
|
+
- `stroke_linejoin`: How corners are rendered ("round", "miter", "bevel")
|
|
156
|
+
|
|
157
|
+
**Returns:** SVG string
|
|
158
|
+
|
|
159
|
+
**Example:**
|
|
160
|
+
```python
|
|
161
|
+
# Full customization example
|
|
162
|
+
icon = lucide_icon(
|
|
163
|
+
"activity",
|
|
164
|
+
cls="icon icon-activity animated",
|
|
165
|
+
width=48,
|
|
166
|
+
height=48,
|
|
167
|
+
stroke="rgb(59, 130, 246)",
|
|
168
|
+
stroke_width=2.5,
|
|
169
|
+
stroke_linecap="round",
|
|
170
|
+
stroke_linejoin="round"
|
|
171
|
+
)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `get_icon_list()`
|
|
175
|
+
Returns a list of all available icon names.
|
|
176
|
+
```python
|
|
177
|
+
from lucide import get_icon_list
|
|
178
|
+
|
|
179
|
+
icons = get_icon_list()
|
|
180
|
+
print(f"Available icons: {len(icons)}")
|
|
181
|
+
print(icons[:5]) # ['activity', 'airplay', 'alarm-check', ...]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Advanced Usage
|
|
185
|
+
|
|
186
|
+
### Building a Custom Icon Set
|
|
187
|
+
If you want to include only specific icons or use a different version of Lucide:
|
|
188
|
+
```bash
|
|
189
|
+
# Build with specific icons only
|
|
190
|
+
lucide-db -i home,settings,user,heart,star -o custom-icons.db
|
|
191
|
+
|
|
192
|
+
# Use a specific Lucide version
|
|
193
|
+
lucide-db -t 0.350.0 -o lucide-v0.350.0.db
|
|
194
|
+
|
|
195
|
+
# Build from a file listing icon names
|
|
196
|
+
echo -e "home\nsettings\nuser" > my-icons.txt
|
|
197
|
+
lucide-db -f my-icons.txt -o my-icons.db
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Using a Custom Database
|
|
201
|
+
Set the `LUCIDE_DB_PATH` environment variable:
|
|
202
|
+
```bash
|
|
203
|
+
export LUCIDE_DB_PATH=/path/to/custom-icons.db
|
|
204
|
+
python your-app.py
|
|
205
|
+
```
|
|
206
|
+
Or configure it in your Python code:
|
|
207
|
+
```python
|
|
208
|
+
import os
|
|
209
|
+
os.environ['LUCIDE_DB_PATH'] = '/path/to/custom-icons.db'
|
|
210
|
+
|
|
211
|
+
from lucide import lucide_icon
|
|
212
|
+
# Will now use your custom database
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Development
|
|
216
|
+
This project uses `uv` for fast dependency management and `pre-commit` for code quality.
|
|
217
|
+
|
|
218
|
+
### Setup
|
|
219
|
+
```bash
|
|
220
|
+
# Clone the repository
|
|
221
|
+
git clone https://github.com/mmacpherson/python-lucide.git
|
|
222
|
+
cd python-lucide
|
|
223
|
+
|
|
224
|
+
# Create a virtual environment and install dependencies
|
|
225
|
+
make env
|
|
226
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
227
|
+
|
|
228
|
+
# Install pre-commit hooks
|
|
229
|
+
make install-hooks
|
|
230
|
+
|
|
231
|
+
# Run tests
|
|
232
|
+
make test
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Rebuilding the Icon Database
|
|
236
|
+
```bash
|
|
237
|
+
# Rebuild with latest Lucide icons
|
|
238
|
+
make lucide-db
|
|
239
|
+
|
|
240
|
+
# Rebuild with specific version
|
|
241
|
+
make lucide-db TAG=0.350.0
|
|
242
|
+
|
|
243
|
+
# Check if version updates are available
|
|
244
|
+
make check-lucide-version
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Version Checking and Automation
|
|
248
|
+
The project includes automated version checking and update capabilities:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Check for Lucide version updates and artifact status
|
|
252
|
+
make check-lucide-version
|
|
253
|
+
|
|
254
|
+
# Alternative: Use the CLI command directly
|
|
255
|
+
uv run check-lucide-version
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Weekly Automation**: The repository automatically checks for new Lucide releases every Monday and creates update PRs when new versions are available.
|
|
259
|
+
|
|
260
|
+
### Release Process
|
|
261
|
+
This project follows a manual release process:
|
|
262
|
+
|
|
263
|
+
1. **Update version** in `pyproject.toml`:
|
|
264
|
+
```bash
|
|
265
|
+
# Create release branch
|
|
266
|
+
git checkout -b release/v0.2.0
|
|
267
|
+
|
|
268
|
+
# Edit pyproject.toml to bump version
|
|
269
|
+
# version = "0.2.0"
|
|
270
|
+
|
|
271
|
+
# Commit and push
|
|
272
|
+
git add pyproject.toml
|
|
273
|
+
git commit -m "Bump version to 0.2.0"
|
|
274
|
+
git push -u origin release/v0.2.0
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
2. **Create and merge PR** for the version bump
|
|
278
|
+
|
|
279
|
+
3. **Trigger publishing workflow**:
|
|
280
|
+
- Go to [Actions](../../actions/workflows/publish.yml)
|
|
281
|
+
- Click "Run workflow"
|
|
282
|
+
- Select the main branch
|
|
283
|
+
- Click "Run workflow"
|
|
284
|
+
|
|
285
|
+
4. **Automatic publishing**: The `publish.yml` workflow builds and publishes the package to PyPI using trusted publishing.
|
|
286
|
+
|
|
287
|
+
## How It Works
|
|
288
|
+
The package comes with a pre-built SQLite database containing all Lucide icons. When you call `lucide_icon()`, it fetches the icon's SVG from the database and applies your customizations. This approach means:
|
|
289
|
+
- **Fast**: Icons are loaded from an efficient SQLite database
|
|
290
|
+
- **Offline**: No internet connection required at runtime
|
|
291
|
+
- **Customizable**: Build your own database with just the icons you need
|
|
292
|
+
- **Maintainable**: Update to newer Lucide versions by rebuilding the database
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
296
|
+
The Lucide icons themselves are also MIT licensed - see [Lucide's license](https://github.com/lucide-icons/lucide/blob/main/LICENSE).
|