python-lucide 0.1.0__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,174 @@
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
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mike Macpherson
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,315 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-lucide
3
+ Version: 0.1.0
4
+ Summary: A Python package for working with Lucide icons
5
+ Project-URL: Bug Tracker, https://github.com/mmacpherson/python-lucide/issues
6
+ Project-URL: Homepage, https://github.com/mmacpherson/python-lucide
7
+ Project-URL: Source Code, https://github.com/mmacpherson/python-lucide
8
+ Author: Lucide Contributors
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: icons,lucide,sqlite,svg
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Provides-Extra: dev
23
+ Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
24
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
25
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
26
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # python-lucide
30
+
31
+ A Python package for working with [Lucide icons](https://lucide.dev/). This package allows you to:
32
+
33
+ 1. Build a SQLite database of Lucide icons
34
+ 2. Serve Lucide SVG icons from a Python application
35
+ 3. Customize icons with classes and attributes
36
+
37
+ ## Installation
38
+
39
+ ### Basic Installation
40
+ ```bash
41
+ pip install lucide
42
+ ```
43
+
44
+ This installs the core package without the pre-built icons database. You'll need to build the database yourself using the `lucide-db` command.
45
+
46
+ ### Installation with Pre-built Database
47
+ ```bash
48
+ pip install "lucide"
49
+ ```
50
+
51
+ This installs the package with a pre-built Lucide icons database, so you can use it right away without building it yourself.
52
+
53
+ ### Development Installation
54
+ If you plan to contribute to `python-lucide`, see the "Development" section for setup instructions.
55
+
56
+ ## Usage
57
+
58
+ ### Getting an Icon
59
+
60
+ ```python
61
+ from lucide import lucide_icon
62
+
63
+ # Get a basic icon
64
+ svg_content = lucide_icon("home")
65
+
66
+ # Add a CSS class
67
+ svg_content = lucide_icon("settings", cls="my-icon-class")
68
+
69
+ # Add custom attributes
70
+ svg_content = lucide_icon("arrow-up", attrs={"width": "32", "height": "32"})
71
+
72
+ # Provide fallback text for when an icon is missing
73
+ svg_content = lucide_icon("some-icon", fallback_text="Icon")
74
+ ```
75
+
76
+ ### Building the Icon Database
77
+
78
+ #### Using the Command-Line Tool
79
+
80
+ The package installs a command-line tool called `lucide-db` that you can use to build the database:
81
+
82
+ ```bash
83
+ # Build a database with all icons
84
+ lucide-db
85
+
86
+ # Specify a custom output path
87
+ lucide-db -o /path/to/output.db
88
+
89
+ # Use a specific Lucide version
90
+ lucide-db -t 0.500.0
91
+
92
+ # Include only specific icons
93
+ lucide-db -i home,settings,user
94
+
95
+ # Include icons from a file (one name per line)
96
+ lucide-db -f my-icons.txt
97
+
98
+ # Enable verbose output
99
+ lucide-db -v
100
+ ```
101
+
102
+ #### Using the Python API
103
+
104
+ You can also build the database programmatically:
105
+
106
+ ```python
107
+ from lucide.cli import download_and_build_db
108
+
109
+ # Build a custom database
110
+ db_path = download_and_build_db(
111
+ output_path="custom-icons.db",
112
+ tag="0.511.0",
113
+ icon_list=["home", "settings", "user"]
114
+ )
115
+ ```
116
+
117
+ ### Getting a List of Available Icons
118
+
119
+ ```python
120
+ from lucide import get_icon_list
121
+
122
+ # Get all available icon names
123
+ icons = get_icon_list()
124
+ print(icons) # ['activity', 'airplay', 'alert-circle', ...]
125
+ ```
126
+
127
+ ## Configuration
128
+
129
+ The package will look for the icons database in the following locations (in order):
130
+
131
+ 1. The path specified in the `LUCIDE_DB_PATH` environment variable
132
+ 2. In the package data directory (if installed with the `db` extra)
133
+ 3. In the current working directory as `lucide-icons.db`
134
+
135
+ ## Example Web Framework Integration
136
+
137
+ ### Flask
138
+
139
+ ```python
140
+ from flask import Flask
141
+ from lucide import lucide_icon
142
+
143
+ app = Flask(__name__)
144
+
145
+ @app.route('/icons/<icon_name>')
146
+ def serve_icon(icon_name):
147
+ svg = lucide_icon(icon_name, cls="my-icon")
148
+ return svg, 200, {'Content-Type': 'image/svg+xml'}
149
+ ```
150
+
151
+ ### FastAPI
152
+
153
+ ```python
154
+ from fastapi import FastAPI
155
+ from fastapi.responses import Response
156
+ from lucide import lucide_icon
157
+
158
+ app = FastAPI()
159
+
160
+ @app.get("/icons/{icon_name}")
161
+ def serve_icon(icon_name: str):
162
+ svg = lucide_icon(icon_name, cls="my-icon")
163
+ return Response(content=svg, media_type="image/svg+xml")
164
+ ```
165
+
166
+ ## Development
167
+
168
+ This project uses `uv` for project and virtual environment management, and `pre-commit` for code quality checks. A `Makefile` is also provided for common development tasks.
169
+
170
+ ### Setup Development Environment
171
+
172
+ 1. **Clone the repository:**
173
+ ```bash
174
+ git clone https://github.com/mmacpherson/python-lucide.git
175
+ cd python-lucide
176
+ ```
177
+
178
+ 2. **Create a virtual environment and install dependencies:**
179
+ This project uses `uv` for fast environment management and dependency installation.
180
+ ```bash
181
+ # Create a virtual environment in .venv/
182
+ uv venv
183
+ # Activate the virtual environment
184
+ # On macOS/Linux:
185
+ source .venv/bin/activate
186
+ # On Windows (PowerShell):
187
+ # .venv\\Scripts\\Activate.ps1
188
+ # On Windows (CMD):
189
+ # .venv\\Scripts\\activate.bat
190
+
191
+ # Install the package in editable mode with development dependencies
192
+ uv pip install -e ".[dev]"
193
+ ```
194
+ This command installs `lucide` in "editable" mode (`-e`), meaning changes you make to the source code will be reflected immediately. It also installs all dependencies listed under the `[dev]` extra in your `pyproject.toml` (like `pytest`, `ruff`, and `pre-commit`).
195
+
196
+ Alternatively, you can use the `Makefile` target:
197
+ ```bash
198
+ make env
199
+ # Then activate the environment as shown above.
200
+ ```
201
+
202
+ 3. **Install pre-commit hooks:**
203
+ ```bash
204
+ uv run pre-commit install
205
+ ```
206
+ Or use the Makefile:
207
+ ```bash
208
+ make install-hooks
209
+ ```
210
+
211
+ <details>
212
+ <summary>Alternative: Using Python's venv and pip</summary>
213
+
214
+ If you prefer not to use `uv` or `make`, you can use Python's built-in `venv` module and `pip`:
215
+
216
+ 1. **Clone the repository (if not already done):**
217
+ ```bash
218
+ git clone https://github.com/mmacpherson/python-lucide.git
219
+ cd python-lucide
220
+ ```
221
+
222
+ 2. **Create and activate a virtual environment:**
223
+ ```bash
224
+ python -m venv .venv
225
+ # On macOS/Linux:
226
+ source .venv/bin/activate
227
+ # On Windows (PowerShell):
228
+ # .venv\\Scripts\\Activate.ps1
229
+ # On Windows (CMD):
230
+ # .venv\\Scripts\\activate.bat
231
+ ```
232
+
233
+ 3. **Install dependencies:**
234
+ ```bash
235
+ pip install -e ".[dev]"
236
+ ```
237
+
238
+ 4. **Install pre-commit hooks:**
239
+ ```bash
240
+ pre-commit install
241
+ ```
242
+
243
+ </details>
244
+
245
+ ### Running Tests
246
+
247
+ After setting up your development environment, run tests using `pytest`.
248
+ You can use the `Makefile`:
249
+ ```bash
250
+ make test
251
+ ```
252
+ Or run `pytest` directly via `uv`:
253
+ ```bash
254
+ uv run pytest
255
+ ```
256
+
257
+ ### Linting and Formatting
258
+
259
+ This project uses `ruff` for linting and formatting, managed via `pre-commit`. The hooks will run automatically on commit.
260
+ To run all hooks manually across all files, use the `Makefile`:
261
+ ```bash
262
+ make run-hooks-all-files
263
+ ```
264
+ Or run `pre-commit` directly via `uv`:
265
+ ```bash
266
+ uv run pre-commit run --all-files
267
+ ```
268
+
269
+ You can also run `ruff` commands directly:
270
+ ```bash
271
+ uv run ruff check .
272
+ uv run ruff format .
273
+ ```
274
+
275
+ ### Building the Icon Database
276
+
277
+ The packaged database can be rebuilt using the `lucide-db` command-line tool. To update the database bundled with the `[db]` extra (typically stored at `src/lucide/data/lucide-icons.db`):
278
+
279
+ Using the `Makefile` (recommended for consistency):
280
+ ```bash
281
+ # Replace <version> with the desired Lucide tag, e.g., 0.511.0
282
+ make db TAG=<version>
283
+ ```
284
+ Or directly using `lucide-db` (ensure your virtual environment is active):
285
+ ```bash
286
+ # Replace <version> with the desired Lucide tag
287
+ uv run lucide-db -o src/lucide/data/lucide-icons.db -t <version> -v
288
+ ```
289
+ The default tag used by `make db` is specified in the `Makefile`.
290
+
291
+ ### Building the Package
292
+
293
+ To build the sdist and wheel for distribution:
294
+ ```bash
295
+ python -m build
296
+ ```
297
+ Or, if you have `hatch` installed (it's part of `[dev]` dependencies):
298
+ ```bash
299
+ hatch build
300
+ ```
301
+
302
+ ### Makefile Targets
303
+ A `Makefile` is provided with common development tasks. Run `make help` to see available targets, including:
304
+ * `env`: Sets up the development environment (creates `.venv` and installs dependencies).
305
+ * `db`: Rebuilds the Lucide icon database.
306
+ * `test`: Runs tests.
307
+ * `install-hooks`: Installs pre-commit hooks.
308
+ * `run-hooks-all-files`: Runs all pre-commit hooks on all files.
309
+ * `clean`: Removes build artifacts, `__pycache__`, etc.
310
+ * `nuke`: A more thorough clean, including the `uv` cache if present and the `.venv` directory.
311
+
312
+
313
+ ## License
314
+
315
+ This project is licensed under the MIT License - see the LICENSE file for details.