Skip to content

Commit b63cb60

Browse files
authored
Pep 518 via uv (#405)
* Comply with PEP-518: update project structure with uv This aims to resolve #404, as well as #406, by updating the project structure and build process leveraging the `uv` tool (https://docs.astral.sh/uv/). It also drops support for Python 3.8 for a variety of reasons, including making the tests pass. Follow-up commits will fix the CI, improve documentation, etc. Note that per discussion with deeplook, this includes a "minor" version bump to 1.6.0. * Update README and CONTRIBUTORS README updated per new state of affairs; CONTRIBUTORS updated per my contribution per deeplook. * Break out CI to separate platforms, temporarily silence Windows This commit breaks out the CI runners into different platforms to make the `cairo` installation simpler, temporarily turning off the Windows runner, per discussion, until we can figure out how to install `cairo` on that platform with anything resembling efficiency. Also, per discussion, the CI steps have been simplified to target the oldest/newest targeted Python versions, making the (fair) assumption that things should work in-between.
1 parent 3fb492f commit b63cb60

File tree

18 files changed

+781
-113
lines changed

18 files changed

+781
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
name: CI
1+
name: Run Matrix Tests on MacOS
22
on: [push, pull_request, workflow_dispatch]
33
jobs:
44
tests:
5-
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
6-
runs-on: "${{ matrix.os }}"
5+
name: "Python ${{ matrix.python-version }} on MacOs"
6+
runs-on: "macos-latest"
77
strategy:
88
matrix:
9-
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.9"]
10-
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
9+
python-version: ["3.9", "3.13", "pypy-3.9"]
1110
steps:
12-
- uses: "actions/checkout@v3"
11+
- uses: "actions/checkout@v4"
12+
13+
- name: Set up Homebrew
14+
id: set-up-homebrew
15+
uses: Homebrew/actions/setup-homebrew@main
16+
17+
- name: Setup Cairo
18+
run: |
19+
brew install cairo pkg-config
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
1326
- name: "Cache for wikipedia flags"
1427
uses: actions/cache@v3
1528
env:
@@ -31,14 +44,5 @@ jobs:
3144
with:
3245
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
3346
key: "w3c-svg12-tinytestsuite-${{ matrix.python-version }}-${{ matrix.os }}"
34-
- uses: "actions/setup-python@v4"
35-
with:
36-
python-version: "${{ matrix.python-version }}"
37-
- name: "Install dependencies"
38-
run: |
39-
python -VV
40-
python -m site
41-
python -m pip install --upgrade pip setuptools wheel
42-
python -m pip install --upgrade virtualenv tox tox-gh-actions
43-
- name: "Run tox targets for ${{ matrix.python-version }}"
44-
run: "python -m tox"
47+
- name: "Run tests for ${{ matrix.python-version }}"
48+
run: uv run --python ${{ matrix.python-version }} pytest

.github/workflows/ci-ubuntu.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Run Matrix Tests on Ubuntu
2+
on: [push, pull_request, workflow_dispatch]
3+
jobs:
4+
tests:
5+
name: "Python ${{ matrix.python-version }} on Ubuntu"
6+
runs-on: "ubuntu-latest"
7+
strategy:
8+
matrix:
9+
python-version: ["3.9", "3.13", "pypy-3.9"]
10+
steps:
11+
- uses: "actions/checkout@v4"
12+
13+
- name: Setup Cairo
14+
run: |
15+
sudo apt-get update && \
16+
sudo apt-get install -y libcairo2-dev libffi-dev pkg-config
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v6
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: "Cache for wikipedia flags"
24+
uses: actions/cache@v3
25+
env:
26+
cache-name: "cache-wikipedia-flags"
27+
with:
28+
path: "tests/samples/wikipedia/flags"
29+
key: "wikipedia-flags-${{ matrix.python-version }}-${{ matrix.os }}"
30+
- name: "Cache for wikipedia symbols"
31+
uses: actions/cache@v3
32+
env:
33+
cache-name: "cache-wikipedia-symbols"
34+
with:
35+
path: "tests/samples/wikipedia/symbols"
36+
key: "wikipedia-symbols-${{ matrix.python-version }}-${{ matrix.os }}"
37+
- name: "Cache for w3c svg12 tinytestsuite"
38+
uses: actions/cache@v3
39+
env:
40+
cache-name: "cache-w3c-svg12-tinytestsuite"
41+
with:
42+
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
43+
key: "w3c-svg12-tinytestsuite-${{ matrix.python-version }}-${{ matrix.os }}"
44+
- name: "Run tests for ${{ matrix.python-version }}"
45+
run: uv run --python ${{ matrix.python-version }} pytest

.github/workflows/ci-windows.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Run Matrix Tests on Windows (Placeholder)
2+
# on: [push, pull_request, workflow_dispatch]
3+
jobs:
4+
tests:
5+
name: "Python Tests for Windows"
6+
runs-on: "windows-latest"
7+
# strategy:
8+
# matrix:
9+
# python-version: ["3.9", "3.10", "3.11", "pypy-3.9"]
10+
steps:
11+
- uses: "actions/checkout@v4"
12+
13+
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v6
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
19+
- name: Install gvsbuild
20+
run: uv tool install gvsbuild
21+
22+
- name: Install gtk3 (includes Cairo)
23+
run: gvsbuild build gtk3
24+
25+
- name: "Cache for wikipedia flags"
26+
uses: actions/cache@v3
27+
env:
28+
cache-name: "cache-wikipedia-flags"
29+
with:
30+
path: "tests/samples/wikipedia/flags"
31+
key: "wikipedia-flags-" # just use single cache for windows
32+
- name: "Cache for wikipedia symbols"
33+
uses: actions/cache@v3
34+
env:
35+
cache-name: "cache-wikipedia-symbols"
36+
with:
37+
path: "tests/samples/wikipedia/symbols"
38+
key: "wikipedia-symbols-"
39+
- name: "Cache for w3c svg12 tinytestsuite"
40+
uses: actions/cache@v3
41+
env:
42+
cache-name: "cache-w3c-svg12-tinytestsuite"
43+
with:
44+
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
45+
key: "w3c-svg12-tinytestsuite-"
46+
- name: "Run tests for 3.9"
47+
run: uv run --python 3.9 pytest
48+
- name: "Run tests for 3.10"
49+
run: uv run --python 3.10 pytest
50+
- name: "Run tests for 3.11"
51+
run: uv run --python 3.11 pytest
52+
- name: "Run tests for 3.13"
53+
run: uv run --python 3.13 pytest
54+
- name: "Run tests for pypy-3.9"
55+
run: uv run --python pypy-3.9 pytest

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
2828

2929
- name: After Prepare
3030
run: python3 -m pip install --upgrade --user flake8

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9

CONTRIBUTORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This is the (preliminary) list of contributors in no particular order:
1010
- Sebastian Wehrmann
1111
- Robin Becker
1212
- Tom Turner
13+
- Danny Elfanbaum
1314

1415
If you are not listed here, but feel like you should be, please contact
1516
the maintainers. If you create a pull request, feel free to add your

README.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ A pure-Python library for reading and converting SVG
4949
About
5050
-----
5151

52-
``Svglib`` is a pure-Python library for reading SVG_ files and converting
52+
``Svglib`` is a Python library for reading SVG_ files and converting
5353
them (to a reasonable degree) to other formats using the ReportLab_ Open
5454
Source toolkit.
5555

@@ -162,6 +162,12 @@ into different fileformats, including PDF, EPS, SVG and various bitmaps
162162
ones. Other dependancies are ``lxml`` which is used in the context of SVG
163163
CSS stylesheets.
164164

165+
Previous versions of this package included a way to run `cairo` without explicit
166+
installation by the user; the dependency that took care of that no longer does
167+
this installation, and as such, the user must install `cairo` themselves. For
168+
installation instructions, see the official website:
169+
https://www.cairographics.org/download/
170+
165171

166172
Installation
167173
------------
@@ -203,20 +209,25 @@ using these simple commands::
203209

204210
Alternatively, you can install a tarball like ``svglib-<version>.tar.gz``
205211
after downloading it from the `svglib page on PyPI`_ or the
206-
`svglib releases page on GitHub`_ and executing a sequence of commands
207-
like shown here::
212+
`svglib releases page on GitHub`_ and installing it via ``pip``:
208213

209-
$ tar xfz svglib-<version>.tar.gz
210-
$ cd svglib-<version>
211-
$ python setup.py install
214+
$ pip install svglib-<version>.tar.gz
212215

213216
This will install a Python package named ``svglib`` in the
214217
``site-packages`` subfolder of your Python installation and a script
215218
tool named ``svg2pdf`` in your ``bin`` directory, e.g. in
216219
``/usr/local/bin``.
217220

221+
Development and Testing
222+
-------
223+
224+
To develop ``svglib``, install `uv`_ and run ``uv sync`` to install the
225+
requirements and development dependencies. To run the test suite with
226+
``pytest``, run: ``uv run pytest``.
227+
228+
.. _uv: https://docs.astral.sh/uv/
218229

219-
Testing
230+
Distribution Testing
220231
-------
221232

222233
The ``svglib`` tarball distribution contains a PyTest_ test suite

pyproject.toml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[project]
2+
name = "svglib"
3+
version = "1.6.0"
4+
description = "A pure-Python library for reading and converting SVG"
5+
readme = "README.rst"
6+
authors = [
7+
{ name = "Dinu Gherman", email = "gherman@darwin.in-berlin.de" },
8+
]
9+
keywords = [
10+
"SVG",
11+
"PDF",
12+
"reportlab",
13+
"conversion",
14+
"graphics",
15+
]
16+
classifiers = [
17+
"Development Status :: 5 - Production/Stable",
18+
"Environment :: Console",
19+
"Intended Audience :: End Users/Desktop",
20+
"Intended Audience :: Developers",
21+
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
22+
"Operating System :: MacOS :: MacOS X",
23+
"Operating System :: Microsoft :: Windows",
24+
"Operating System :: POSIX",
25+
"Natural Language :: English",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3 :: Only",
31+
"Topic :: Documentation",
32+
"Topic :: Utilities",
33+
"Topic :: Printing",
34+
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
35+
"Topic :: Software Development :: Libraries :: Python Modules",
36+
"Topic :: Text Processing :: Markup :: XML",
37+
]
38+
license = "LGPL-3.0-or-later"
39+
license-files = [
40+
"LICENSE.txt",
41+
]
42+
requires-python = ">=3.8"
43+
dependencies = [
44+
"cssselect2>=0.2.0",
45+
"lxml>=6.0.0",
46+
"reportlab>=4.4.3",
47+
"rlpycairo>=0.4.0",
48+
"tinycss2>=0.6.0",
49+
]
50+
51+
[project.urls]
52+
Homepage = "https://github.com/deeplook/svglib"
53+
54+
[project.scripts]
55+
svg2pdf = "svglib:main"
56+
57+
[build-system]
58+
requires = ["hatchling"]
59+
build-backend = "hatchling.build"
60+
61+
[tool.uv]
62+
dev-dependencies = [
63+
"pytest>=8.3.5",
64+
"pytest-runner>=6.0.1",
65+
]
66+
67+
[tool.flake8]
68+
max-line-length = "99"

setup.cfg

Lines changed: 0 additions & 63 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)