svgflow 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.
- svgflow-0.1.0/PKG-INFO +143 -0
- svgflow-0.1.0/README.md +129 -0
- svgflow-0.1.0/pyproject.toml +24 -0
- svgflow-0.1.0/setup.cfg +4 -0
- svgflow-0.1.0/svgflow/__init__.py +15 -0
- svgflow-0.1.0/svgflow/canvas.py +1024 -0
- svgflow-0.1.0/svgflow/external_figures.py +133 -0
- svgflow-0.1.0/svgflow.egg-info/PKG-INFO +143 -0
- svgflow-0.1.0/svgflow.egg-info/SOURCES.txt +10 -0
- svgflow-0.1.0/svgflow.egg-info/dependency_links.txt +1 -0
- svgflow-0.1.0/svgflow.egg-info/requires.txt +1 -0
- svgflow-0.1.0/svgflow.egg-info/top_level.txt +1 -0
svgflow-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: svgflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A small SVG generation library for drawings, plots, and flow diagrams
|
|
5
|
+
Author-email: Shobhit Bhatnagar <shb.bhatnagar.96@gmail.com>
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: numpy>=1.23
|
|
14
|
+
|
|
15
|
+
# SvgFlow
|
|
16
|
+
|
|
17
|
+
SvgFlow is a lightweight Python library for creating SVG drawings, plots, and
|
|
18
|
+
flow diagrams. Drawings are assembled with Python and saved as editable SVG;
|
|
19
|
+
optional integrations add LaTeX labels and PNG/PDF export.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Basic SVG shapes, text, paths, curves, arrows, and gradients
|
|
24
|
+
- `Plot` helpers for axes, ticks, lines, scatter plots, bars, and legends
|
|
25
|
+
- `Flow` helpers for connected nodes, directed edges, and self-edges
|
|
26
|
+
- SVG subfigure imports
|
|
27
|
+
- LaTeX labels through Inkscape, `dvisvgm`, or `pdf2svg`
|
|
28
|
+
- PNG and PDF export through Inkscape
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- Python 3.10 or newer
|
|
33
|
+
- NumPy 1.23 or newer
|
|
34
|
+
|
|
35
|
+
The following external programs are optional:
|
|
36
|
+
|
|
37
|
+
- [Inkscape](https://inkscape.org/) for PNG/PDF export and the default
|
|
38
|
+
LaTeX-to-SVG backend
|
|
39
|
+
- `pdflatex` for LaTeX rendering
|
|
40
|
+
- `dvisvgm` or `pdf2svg` when using the corresponding LaTeX backend
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Install the published package from PyPI:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install svgflow
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For local development, clone the repository and install it in editable mode:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/YOUR_USERNAME/SvgFlow.git
|
|
54
|
+
cd SvgFlow
|
|
55
|
+
python -m pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Replace `YOUR_USERNAME` with the GitHub account that hosts the repository.
|
|
59
|
+
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from svgflow import Flow
|
|
64
|
+
|
|
65
|
+
diagram = Flow(height=240, width=480)
|
|
66
|
+
|
|
67
|
+
diagram.addNode(
|
|
68
|
+
"source", 100, 120,
|
|
69
|
+
shape=("circle", 45),
|
|
70
|
+
label="Source",
|
|
71
|
+
color="lightblue",
|
|
72
|
+
)
|
|
73
|
+
diagram.addNode(
|
|
74
|
+
"result", 380, 120,
|
|
75
|
+
shape=("rectangle", 80, 120),
|
|
76
|
+
label="Result",
|
|
77
|
+
color="lightgreen",
|
|
78
|
+
)
|
|
79
|
+
diagram.addEdge("source", "result", label="transform", directed=True)
|
|
80
|
+
diagram.save("flow.svg")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The first `Canvas`, `Plot`, and `Flow` constructor argument is the height; the
|
|
84
|
+
second is the width. SVG coordinates start at the top-left corner.
|
|
85
|
+
|
|
86
|
+
## Configuring external programs
|
|
87
|
+
|
|
88
|
+
SvgFlow looks for optional commands on the system `PATH` by default. You can
|
|
89
|
+
instead supply explicit paths:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from svgflow import Canvas, ExecutablePaths
|
|
93
|
+
|
|
94
|
+
tools = ExecutablePaths(
|
|
95
|
+
inkscape=r"C:\Program Files\Inkscape\bin\inkscape.exe",
|
|
96
|
+
pdflatex=r"C:\texlive\bin\windows\pdflatex.exe",
|
|
97
|
+
dvisvgm=r"C:\texlive\bin\windows\dvisvgm.exe",
|
|
98
|
+
pdf2svg=r"C:\tools\pdf2svg.exe",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
canvas = Canvas(400, 600, executables=tools)
|
|
102
|
+
canvas.addText("Hello, SvgFlow!", 300, 200)
|
|
103
|
+
canvas.save("drawing.svg")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`Plot` and `Flow` accept the same `executables` keyword argument. The
|
|
107
|
+
lower-level `tex2svg` function accepts `executables=tools` as well.
|
|
108
|
+
|
|
109
|
+
## Building the package
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python -m pip install --upgrade build twine
|
|
113
|
+
python -m build
|
|
114
|
+
python -m twine check dist/*
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The source distribution and wheel are written to `dist/`.
|
|
118
|
+
|
|
119
|
+
## Publishing
|
|
120
|
+
|
|
121
|
+
Test the release on TestPyPI before uploading it to the production index:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
python -m twine upload --repository testpypi dist/*
|
|
125
|
+
python -m pip install --index-url https://test.pypi.org/simple/ \
|
|
126
|
+
--extra-index-url https://pypi.org/simple svgflow
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
When the test package is correct, publish it to PyPI:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python -m twine upload dist/*
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Use a PyPI API token when Twine asks for credentials: enter `__token__` as the
|
|
136
|
+
username and the complete token (including its `pypi-` prefix) as the password.
|
|
137
|
+
Every release must use a version that has not already been uploaded; update the
|
|
138
|
+
version in `pyproject.toml` and `svgflow/__init__.py` before rebuilding.
|
|
139
|
+
|
|
140
|
+
## Contributing
|
|
141
|
+
|
|
142
|
+
Issues and pull requests are welcome. When reporting a problem, include your
|
|
143
|
+
Python version, operating system, and a minimal example that reproduces it.
|
svgflow-0.1.0/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# SvgFlow
|
|
2
|
+
|
|
3
|
+
SvgFlow is a lightweight Python library for creating SVG drawings, plots, and
|
|
4
|
+
flow diagrams. Drawings are assembled with Python and saved as editable SVG;
|
|
5
|
+
optional integrations add LaTeX labels and PNG/PDF export.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Basic SVG shapes, text, paths, curves, arrows, and gradients
|
|
10
|
+
- `Plot` helpers for axes, ticks, lines, scatter plots, bars, and legends
|
|
11
|
+
- `Flow` helpers for connected nodes, directed edges, and self-edges
|
|
12
|
+
- SVG subfigure imports
|
|
13
|
+
- LaTeX labels through Inkscape, `dvisvgm`, or `pdf2svg`
|
|
14
|
+
- PNG and PDF export through Inkscape
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Python 3.10 or newer
|
|
19
|
+
- NumPy 1.23 or newer
|
|
20
|
+
|
|
21
|
+
The following external programs are optional:
|
|
22
|
+
|
|
23
|
+
- [Inkscape](https://inkscape.org/) for PNG/PDF export and the default
|
|
24
|
+
LaTeX-to-SVG backend
|
|
25
|
+
- `pdflatex` for LaTeX rendering
|
|
26
|
+
- `dvisvgm` or `pdf2svg` when using the corresponding LaTeX backend
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Install the published package from PyPI:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m pip install svgflow
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For local development, clone the repository and install it in editable mode:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/YOUR_USERNAME/SvgFlow.git
|
|
40
|
+
cd SvgFlow
|
|
41
|
+
python -m pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Replace `YOUR_USERNAME` with the GitHub account that hosts the repository.
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from svgflow import Flow
|
|
50
|
+
|
|
51
|
+
diagram = Flow(height=240, width=480)
|
|
52
|
+
|
|
53
|
+
diagram.addNode(
|
|
54
|
+
"source", 100, 120,
|
|
55
|
+
shape=("circle", 45),
|
|
56
|
+
label="Source",
|
|
57
|
+
color="lightblue",
|
|
58
|
+
)
|
|
59
|
+
diagram.addNode(
|
|
60
|
+
"result", 380, 120,
|
|
61
|
+
shape=("rectangle", 80, 120),
|
|
62
|
+
label="Result",
|
|
63
|
+
color="lightgreen",
|
|
64
|
+
)
|
|
65
|
+
diagram.addEdge("source", "result", label="transform", directed=True)
|
|
66
|
+
diagram.save("flow.svg")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The first `Canvas`, `Plot`, and `Flow` constructor argument is the height; the
|
|
70
|
+
second is the width. SVG coordinates start at the top-left corner.
|
|
71
|
+
|
|
72
|
+
## Configuring external programs
|
|
73
|
+
|
|
74
|
+
SvgFlow looks for optional commands on the system `PATH` by default. You can
|
|
75
|
+
instead supply explicit paths:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from svgflow import Canvas, ExecutablePaths
|
|
79
|
+
|
|
80
|
+
tools = ExecutablePaths(
|
|
81
|
+
inkscape=r"C:\Program Files\Inkscape\bin\inkscape.exe",
|
|
82
|
+
pdflatex=r"C:\texlive\bin\windows\pdflatex.exe",
|
|
83
|
+
dvisvgm=r"C:\texlive\bin\windows\dvisvgm.exe",
|
|
84
|
+
pdf2svg=r"C:\tools\pdf2svg.exe",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
canvas = Canvas(400, 600, executables=tools)
|
|
88
|
+
canvas.addText("Hello, SvgFlow!", 300, 200)
|
|
89
|
+
canvas.save("drawing.svg")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`Plot` and `Flow` accept the same `executables` keyword argument. The
|
|
93
|
+
lower-level `tex2svg` function accepts `executables=tools` as well.
|
|
94
|
+
|
|
95
|
+
## Building the package
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m pip install --upgrade build twine
|
|
99
|
+
python -m build
|
|
100
|
+
python -m twine check dist/*
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The source distribution and wheel are written to `dist/`.
|
|
104
|
+
|
|
105
|
+
## Publishing
|
|
106
|
+
|
|
107
|
+
Test the release on TestPyPI before uploading it to the production index:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python -m twine upload --repository testpypi dist/*
|
|
111
|
+
python -m pip install --index-url https://test.pypi.org/simple/ \
|
|
112
|
+
--extra-index-url https://pypi.org/simple svgflow
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
When the test package is correct, publish it to PyPI:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
python -m twine upload dist/*
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Use a PyPI API token when Twine asks for credentials: enter `__token__` as the
|
|
122
|
+
username and the complete token (including its `pypi-` prefix) as the password.
|
|
123
|
+
Every release must use a version that has not already been uploaded; update the
|
|
124
|
+
version in `pyproject.toml` and `svgflow/__init__.py` before rebuilding.
|
|
125
|
+
|
|
126
|
+
## Contributing
|
|
127
|
+
|
|
128
|
+
Issues and pull requests are welcome. When reporting a problem, include your
|
|
129
|
+
Python version, operating system, and a minimal example that reproduces it.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "svgflow"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A small SVG generation library for drawings, plots, and flow diagrams"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Shobhit Bhatnagar", email = "shb.bhatnagar.96@gmail.com" },
|
|
13
|
+
]
|
|
14
|
+
dependencies = ["numpy>=1.23"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Topic :: Multimedia :: Graphics",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
include = ["svgflow*"]
|
svgflow-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Create SVG drawings, plots, and flow diagrams with Python."""
|
|
2
|
+
|
|
3
|
+
from .canvas import Canvas, Flow, Plot
|
|
4
|
+
from .external_figures import ExecutablePaths, import_svg_from_file, tex2svg
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"Canvas",
|
|
8
|
+
"ExecutablePaths",
|
|
9
|
+
"Flow",
|
|
10
|
+
"Plot",
|
|
11
|
+
"import_svg_from_file",
|
|
12
|
+
"tex2svg",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|