Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions .github/workflows/ci.yml → .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
name: CI
name: Run Matrix Tests on MacOS
on: [push, pull_request, workflow_dispatch]
jobs:
tests:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
name: "Python ${{ matrix.python-version }} on MacOs"
runs-on: "macos-latest"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.9"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.13", "pypy-3.9"]
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main

- name: Setup Cairo
run: |
brew install cairo pkg-config

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: "Cache for wikipedia flags"
uses: actions/cache@v3
env:
Expand All @@ -31,14 +44,5 @@ jobs:
with:
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
key: "w3c-svg12-tinytestsuite-${{ matrix.python-version }}-${{ matrix.os }}"
- uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade virtualenv tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
- name: "Run tests for ${{ matrix.python-version }}"
run: uv run --python ${{ matrix.python-version }} pytest
45 changes: 45 additions & 0 deletions .github/workflows/ci-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run Matrix Tests on Ubuntu
on: [push, pull_request, workflow_dispatch]
jobs:
tests:
name: "Python ${{ matrix.python-version }} on Ubuntu"
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.13", "pypy-3.9"]
steps:
- uses: "actions/checkout@v4"

- name: Setup Cairo
run: |
sudo apt-get update && \
sudo apt-get install -y libcairo2-dev libffi-dev pkg-config

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: "Cache for wikipedia flags"
uses: actions/cache@v3
env:
cache-name: "cache-wikipedia-flags"
with:
path: "tests/samples/wikipedia/flags"
key: "wikipedia-flags-${{ matrix.python-version }}-${{ matrix.os }}"
- name: "Cache for wikipedia symbols"
uses: actions/cache@v3
env:
cache-name: "cache-wikipedia-symbols"
with:
path: "tests/samples/wikipedia/symbols"
key: "wikipedia-symbols-${{ matrix.python-version }}-${{ matrix.os }}"
- name: "Cache for w3c svg12 tinytestsuite"
uses: actions/cache@v3
env:
cache-name: "cache-w3c-svg12-tinytestsuite"
with:
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
key: "w3c-svg12-tinytestsuite-${{ matrix.python-version }}-${{ matrix.os }}"
- name: "Run tests for ${{ matrix.python-version }}"
run: uv run --python ${{ matrix.python-version }} pytest
55 changes: 55 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Matrix Tests on Windows (Placeholder)
# on: [push, pull_request, workflow_dispatch]
jobs:
tests:
name: "Python Tests for Windows"
runs-on: "windows-latest"
# strategy:
# matrix:
# python-version: ["3.9", "3.10", "3.11", "pypy-3.9"]
steps:
- uses: "actions/checkout@v4"


- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install gvsbuild
run: uv tool install gvsbuild

- name: Install gtk3 (includes Cairo)
run: gvsbuild build gtk3

- name: "Cache for wikipedia flags"
uses: actions/cache@v3
env:
cache-name: "cache-wikipedia-flags"
with:
path: "tests/samples/wikipedia/flags"
key: "wikipedia-flags-" # just use single cache for windows
- name: "Cache for wikipedia symbols"
uses: actions/cache@v3
env:
cache-name: "cache-wikipedia-symbols"
with:
path: "tests/samples/wikipedia/symbols"
key: "wikipedia-symbols-"
- name: "Cache for w3c svg12 tinytestsuite"
uses: actions/cache@v3
env:
cache-name: "cache-w3c-svg12-tinytestsuite"
with:
path: "tests/samples/W3C_SVG_12_TinyTestSuite"
key: "w3c-svg12-tinytestsuite-"
- name: "Run tests for 3.9"
run: uv run --python 3.9 pytest
- name: "Run tests for 3.10"
run: uv run --python 3.10 pytest
- name: "Run tests for 3.11"
run: uv run --python 3.11 pytest
- name: "Run tests for 3.13"
run: uv run --python 3.13 pytest
- name: "Run tests for pypy-3.9"
run: uv run --python pypy-3.9 pytest
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: After Prepare
run: python3 -m pip install --upgrade --user flake8
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is the (preliminary) list of contributors in no particular order:
- Sebastian Wehrmann
- Robin Becker
- Tom Turner
- Danny Elfanbaum

If you are not listed here, but feel like you should be, please contact
the maintainers. If you create a pull request, feel free to add your
Expand Down
25 changes: 18 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ A pure-Python library for reading and converting SVG
About
-----

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

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

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


Installation
------------
Expand Down Expand Up @@ -203,20 +209,25 @@ using these simple commands::

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

$ tar xfz svglib-<version>.tar.gz
$ cd svglib-<version>
$ python setup.py install
$ pip install svglib-<version>.tar.gz

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

Development and Testing
-------

To develop ``svglib``, install `uv`_ and run ``uv sync`` to install the
requirements and development dependencies. To run the test suite with
``pytest``, run: ``uv run pytest``.

.. _uv: https://docs.astral.sh/uv/

Testing
Distribution Testing
-------

The ``svglib`` tarball distribution contains a PyTest_ test suite
Expand Down
68 changes: 68 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[project]
name = "svglib"
version = "1.6.0"
description = "A pure-Python library for reading and converting SVG"
readme = "README.rst"
authors = [
{ name = "Dinu Gherman", email = "[email protected]" },
]
keywords = [
"SVG",
"PDF",
"reportlab",
"conversion",
"graphics",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Documentation",
"Topic :: Utilities",
"Topic :: Printing",
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup :: XML",
]
license = "LGPL-3.0-or-later"
license-files = [
"LICENSE.txt",
]
requires-python = ">=3.8"
dependencies = [
"cssselect2>=0.2.0",
"lxml>=6.0.0",
"reportlab>=4.4.3",
"rlpycairo>=0.4.0",
"tinycss2>=0.6.0",
]

[project.urls]
Homepage = "https://github.com/deeplook/svglib"

[project.scripts]
svg2pdf = "svglib:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"pytest>=8.3.5",
"pytest-runner>=6.0.1",
]

[tool.flake8]
max-line-length = "99"
63 changes: 0 additions & 63 deletions setup.cfg

This file was deleted.

13 changes: 0 additions & 13 deletions setup.py

This file was deleted.

Loading
Loading