3
.gitignore
vendored
@ -19,5 +19,4 @@
|
||||
|
||||
# Tests
|
||||
/.pytest_cache
|
||||
/weasyprint/tests/.cache
|
||||
/weasyprint/tests/test_draw/results
|
||||
/tests/test_draw/results
|
||||
|
74
pyproject.toml
Normal file
@ -0,0 +1,74 @@
|
||||
[build-system]
|
||||
requires = ['flit']
|
||||
build-backend = 'flit.buildapi'
|
||||
|
||||
[tool.flit.metadata]
|
||||
module = 'weasyprint'
|
||||
dist-name = 'WeasyPrint'
|
||||
author = 'Simon Sapin'
|
||||
author-email = 'simon.sapin@exyr.org'
|
||||
maintainer = 'CourtBouillon'
|
||||
maintainer-email = 'contact@courtbouillon.org'
|
||||
home-page = 'https://www.courtbouillon.org/weasyprint'
|
||||
requires = [
|
||||
'cffi >=0.6',
|
||||
'html5lib >=0.999999999',
|
||||
'tinycss2 >=1.0.0',
|
||||
'cssselect2 >=0.1',
|
||||
'Pyphen >=0.9.1',
|
||||
'fonttools[woff] >=4.0',
|
||||
'Pillow >=4.0.0',
|
||||
]
|
||||
requires-python = '>=3.6'
|
||||
keywords = 'html css pdf converter'
|
||||
description-file = 'README.rst'
|
||||
classifiers = [
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3 :: Only',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Programming Language :: Python :: Implementation :: CPython',
|
||||
'Programming Language :: Python :: Implementation :: PyPy',
|
||||
'Topic :: Internet :: WWW/HTTP',
|
||||
'Topic :: Text Processing :: Markup :: HTML',
|
||||
'Topic :: Multimedia :: Graphics :: Graphics Conversion',
|
||||
'Topic :: Printing',
|
||||
]
|
||||
|
||||
[tool.flit.metadata.requires-extra]
|
||||
doc = ['sphinx', 'sphinx_rtd_theme']
|
||||
test = ['pytest', 'pytest-cov', 'pytest-flake8', 'pytest-isort', 'coverage[toml]']
|
||||
|
||||
[tool.flit.scripts]
|
||||
weasyprint = 'weasyprint.__main__:main'
|
||||
|
||||
[tool.flit.metadata.urls]
|
||||
Documentation = 'https://doc.courtbouillon.org/weasyprint/'
|
||||
Code = 'https://github.com/Kozea/WeasyPrint'
|
||||
Issues = 'https://github.com/Kozea/WeasyPrint/issues'
|
||||
Donation = 'https://opencollective.com/courtbouillon'
|
||||
|
||||
[tool.flit.sdist]
|
||||
exclude = ['.*', 'tests/results']
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = '--isort --flake8 --cov'
|
||||
|
||||
[tool.coverage.run]
|
||||
branch = true
|
||||
include = ['tests/*', 'weasyprint/*']
|
||||
|
||||
[tool.coverage.report]
|
||||
exclude_lines = ['pragma: no cover', 'def __repr__', 'raise NotImplementedError']
|
||||
omit = ['.*']
|
||||
|
||||
[tool.isort]
|
||||
default_section = 'FIRSTPARTY'
|
||||
multi_line_output = 4
|
116
setup.cfg
@ -1,116 +0,0 @@
|
||||
[metadata]
|
||||
name = WeasyPrint
|
||||
url = https://courtbouillon.org/weasyprint
|
||||
version = file: weasyprint/VERSION
|
||||
license = BSD
|
||||
license_file = LICENSE
|
||||
description = The Awesome Document Factory
|
||||
long_description = file: README.rst
|
||||
long_description_content_type = text/x-rst
|
||||
author = Simon Sapin
|
||||
author_email = contact@courtbouillon.org
|
||||
platforms =
|
||||
Linux
|
||||
macOS
|
||||
Windows
|
||||
keywords =
|
||||
html
|
||||
css
|
||||
pdf
|
||||
converter
|
||||
classifiers =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: BSD License
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Topic :: Internet :: WWW/HTTP
|
||||
Topic :: Text Processing :: Markup :: HTML
|
||||
Topic :: Multimedia :: Graphics :: Graphics Conversion
|
||||
Topic :: Printing
|
||||
project_urls =
|
||||
Documentation = https://weasyprint.readthedocs.io/
|
||||
Code = https://github.com/Kozea/WeasyPrint/
|
||||
Issue tracker = https://github.com/Kozea/WeasyPrint/issues
|
||||
Donation = https://opencollective.com/courtbouillon
|
||||
|
||||
[options]
|
||||
packages =
|
||||
weasyprint
|
||||
weasyprint.css
|
||||
weasyprint.css.validation
|
||||
weasyprint.formatting_structure
|
||||
weasyprint.layout
|
||||
weasyprint.tests
|
||||
weasyprint.tests.test_draw
|
||||
weasyprint.tests.test_layout
|
||||
zip_safe = false
|
||||
setup_requires = pytest-runner
|
||||
install_requires =
|
||||
setuptools>=39.2.0
|
||||
cffi>=0.6
|
||||
html5lib>=0.999999999
|
||||
cairocffi>=0.9.0
|
||||
tinycss2>=1.0.0
|
||||
cssselect2>=0.1
|
||||
CairoSVG>=2.4.0
|
||||
Pyphen>=0.9.1
|
||||
fonttools[woff]>=4.0
|
||||
Pillow>=4.0.0
|
||||
tests_require =
|
||||
pytest-runner
|
||||
pytest-cov
|
||||
pytest-flake8
|
||||
pytest-isort
|
||||
python_requires = >= 3.6
|
||||
|
||||
[options.entry_points]
|
||||
console-scripts = weasyprint = weasyprint.__main__:main
|
||||
|
||||
[options.package_data]
|
||||
weasyprint = VERSION
|
||||
weasyprint.tests = resources/*.*, resources/*/*
|
||||
weasyprint.css = *.css
|
||||
|
||||
[options.extras_require]
|
||||
doc =
|
||||
sphinx
|
||||
sphinx_rtd_theme
|
||||
test =
|
||||
pytest-runner
|
||||
pytest-cov
|
||||
pytest-flake8
|
||||
pytest-isort
|
||||
|
||||
[bdist_wheel]
|
||||
python-tag = py3
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = docs
|
||||
build-dir = docs/_build
|
||||
|
||||
[aliases]
|
||||
test = pytest
|
||||
|
||||
[tool:pytest]
|
||||
addopts = --flake8 --isort
|
||||
norecursedirs = build dist .cache .eggs .git
|
||||
|
||||
[coverage:run]
|
||||
branch = True
|
||||
include = weasyprint/*
|
||||
|
||||
[coverage:report]
|
||||
exclude_lines =
|
||||
pragma: no cover
|
||||
def __repr__
|
||||
raise NotImplementedError
|
||||
omit =
|
||||
.*
|
||||
|
||||
[isort]
|
||||
default_section = FIRSTPARTY
|
||||
multi_line_output = 4
|
13
setup.py
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
WeasyPrint
|
||||
==========
|
||||
|
||||
WeasyPrint converts web documents to PDF.
|
||||
|
||||
"""
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup()
|
@ -16,9 +16,8 @@ from subprocess import PIPE, run
|
||||
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from .. import HTML
|
||||
from ..document import Document
|
||||
from weasyprint import HTML
|
||||
from weasyprint.document import Document
|
||||
|
||||
MAGIC_NUMBER = b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a'
|
||||
|
Before Width: | Height: | Size: 289 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 814 B After Width: | Height: | Size: 814 B |
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 45 B After Width: | Height: | Size: 45 B |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 76 B |
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 76 B After Width: | Height: | Size: 76 B |
Before Width: | Height: | Size: 203 B After Width: | Height: | Size: 203 B |
@ -9,8 +9,8 @@
|
||||
import io
|
||||
|
||||
from PIL import Image
|
||||
from weasyprint import HTML
|
||||
|
||||
from .. import HTML
|
||||
from .test_draw import assert_pixels_equal
|
||||
from .testing_utils import assert_no_logs, capture_logs, resource_filename
|
||||
|
@ -18,10 +18,10 @@ from urllib.parse import urljoin, uses_relative
|
||||
import py
|
||||
import pytest
|
||||
from PIL import Image
|
||||
from weasyprint import CSS, HTML, __main__, default_url_fetcher
|
||||
from weasyprint.document import resolve_links
|
||||
from weasyprint.urls import path2url
|
||||
|
||||
from .. import CSS, HTML, __main__, default_url_fetcher
|
||||
from ..document import resolve_links
|
||||
from ..urls import path2url
|
||||
from .test_draw import assert_pixels_equal, parse_pixels
|
||||
from .testing_utils import (
|
||||
FakeHTML, assert_no_logs, capture_logs, http_server, resource_filename)
|
@ -9,13 +9,13 @@
|
||||
import functools
|
||||
|
||||
import pytest
|
||||
from weasyprint import images
|
||||
from weasyprint.css import PageType, get_all_computed_styles
|
||||
from weasyprint.css.counters import CounterStyle
|
||||
from weasyprint.css.targets import TargetCollector
|
||||
from weasyprint.formatting_structure import boxes, build
|
||||
from weasyprint.layout.pages import set_page_type_computed_styles
|
||||
|
||||
from .. import images
|
||||
from ..css import PageType, get_all_computed_styles
|
||||
from ..css.counters import CounterStyle
|
||||
from ..css.targets import TargetCollector
|
||||
from ..formatting_structure import boxes, build
|
||||
from ..layout.pages import set_page_type_computed_styles
|
||||
from .testing_utils import BASE_URL, FakeHTML, assert_no_logs, capture_logs
|
||||
|
||||
PROPER_CHILDREN = dict((key, tuple(map(tuple, value))) for key, value in {
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint import HTML
|
||||
|
||||
from .. import HTML
|
||||
from .test_boxes import assert_tree, parse_all, render_pages
|
||||
from .testing_utils import assert_no_logs
|
||||
|
@ -9,12 +9,13 @@ from math import isclose
|
||||
|
||||
import pytest
|
||||
import tinycss2
|
||||
from weasyprint import CSS, css, default_url_fetcher
|
||||
from weasyprint.css import (
|
||||
PageType, get_all_computed_styles, parse_page_selectors)
|
||||
from weasyprint.css.computed_values import strut_layout
|
||||
from weasyprint.layout.pages import set_page_type_computed_styles
|
||||
from weasyprint.urls import path2url
|
||||
|
||||
from .. import CSS, css, default_url_fetcher
|
||||
from ..css import PageType, get_all_computed_styles, parse_page_selectors
|
||||
from ..css.computed_values import strut_layout
|
||||
from ..layout.pages import set_page_type_computed_styles
|
||||
from ..urls import path2url
|
||||
from .testing_utils import (
|
||||
BASE_URL, FakeHTML, assert_no_logs, capture_logs, resource_filename)
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
import pytest
|
||||
import tinycss2
|
||||
from weasyprint.css import preprocess_stylesheet
|
||||
from weasyprint.css.validation.descriptors import preprocess_descriptors
|
||||
|
||||
from ..css import preprocess_stylesheet
|
||||
from ..css.validation.descriptors import preprocess_descriptors
|
||||
from .testing_utils import assert_no_logs, capture_logs
|
||||
|
||||
|
@ -10,11 +10,11 @@ import math
|
||||
|
||||
import pytest
|
||||
import tinycss2
|
||||
from weasyprint.css import preprocess_declarations
|
||||
from weasyprint.css.computed_values import ZERO_PIXELS
|
||||
from weasyprint.css.properties import INITIAL_VALUES
|
||||
from weasyprint.images import LinearGradient, RadialGradient
|
||||
|
||||
from ..css import preprocess_declarations
|
||||
from ..css.computed_values import ZERO_PIXELS
|
||||
from ..css.properties import INITIAL_VALUES
|
||||
from ..images import LinearGradient, RadialGradient
|
||||
from .testing_utils import assert_no_logs, capture_logs
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
import itertools
|
||||
|
||||
from ... import HTML
|
||||
from weasyprint import HTML
|
||||
|
||||
from ..testing_utils import assert_no_logs
|
||||
from . import PIXELS_BY_CHAR, assert_different_renderings, assert_pixels
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.html import HTML_HANDLERS
|
||||
|
||||
from ...html import HTML_HANDLERS
|
||||
from ..testing_utils import assert_no_logs
|
||||
from . import assert_pixels, parse_pixels
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.formatting_structure import boxes
|
||||
|
||||
from ..formatting_structure import boxes
|
||||
from .test_boxes import render_pages
|
||||
from .testing_utils import assert_no_logs
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.formatting_structure import boxes
|
||||
|
||||
from ...formatting_structure import boxes
|
||||
from ..test_boxes import render_pages as parse
|
||||
from ..testing_utils import assert_no_logs
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.formatting_structure import boxes
|
||||
|
||||
from ...formatting_structure import boxes
|
||||
from ..test_boxes import render_pages as parse
|
||||
from ..testing_utils import assert_no_logs, capture_logs
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.formatting_structure import boxes
|
||||
|
||||
from ...formatting_structure import boxes
|
||||
from ..test_boxes import render_pages as parse
|
||||
from ..testing_utils import SANS_FONTS, assert_no_logs
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.formatting_structure import boxes
|
||||
|
||||
from ...formatting_structure import boxes
|
||||
from ..test_boxes import render_pages
|
||||
from ..testing_utils import assert_no_logs
|
||||
|
@ -13,9 +13,9 @@ import re
|
||||
from codecs import BOM_UTF16_BE
|
||||
|
||||
import pytest
|
||||
from weasyprint import Attachment
|
||||
from weasyprint.urls import path2url
|
||||
|
||||
from .. import Attachment
|
||||
from ..urls import path2url
|
||||
from .testing_utils import (
|
||||
FakeHTML, assert_no_logs, capture_logs, resource_filename)
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
"""
|
||||
|
||||
from .. import CSS, HTML
|
||||
from weasyprint import CSS, HTML
|
||||
|
||||
from .testing_utils import BASE_URL, assert_no_logs
|
||||
|
||||
PH_TESTING_CSS = CSS(string='''
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.stacking import StackingContext
|
||||
|
||||
from ..stacking import StackingContext
|
||||
from .test_boxes import render_pages, serialize
|
||||
from .test_draw import assert_pixels
|
||||
from .testing_utils import assert_no_logs
|
@ -7,9 +7,9 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.css.properties import INITIAL_VALUES
|
||||
from weasyprint.text import split_first_line
|
||||
|
||||
from ..css.properties import INITIAL_VALUES
|
||||
from ..text import split_first_line
|
||||
from .test_boxes import render_pages
|
||||
from .testing_utils import MONO_FONTS, SANS_FONTS, assert_no_logs
|
||||
|
@ -10,7 +10,8 @@ import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from ..urls import ensure_url
|
||||
from weasyprint.urls import ensure_url
|
||||
|
||||
from .test_draw import assert_pixels_equal, document_to_pixels, html_to_pixels
|
||||
from .testing_utils import FakeHTML, assert_no_logs, resource_filename
|
||||
|
@ -7,8 +7,8 @@
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from weasyprint.css.properties import KNOWN_PROPERTIES
|
||||
|
||||
from ..css.properties import KNOWN_PROPERTIES
|
||||
from .test_boxes import render_pages as parse
|
||||
|
||||
SIDES = ('top', 'right', 'bottom', 'left')
|
@ -14,9 +14,9 @@ import sys
|
||||
import threading
|
||||
import wsgiref.simple_server
|
||||
|
||||
from .. import CSS, HTML
|
||||
from ..logger import LOGGER
|
||||
from ..urls import path2url
|
||||
from weasyprint import CSS, HTML
|
||||
from weasyprint.logger import LOGGER
|
||||
from weasyprint.urls import path2url
|
||||
|
||||
# Lists of fonts with many variants (including condensed)
|
||||
if sys.platform.startswith('win'): # pragma: no cover
|
||||
@ -27,7 +27,7 @@ else: # pragma: no cover
|
||||
MONO_FONTS = 'DejaVu Sans Mono, monospace'
|
||||
|
||||
TEST_UA_STYLESHEET = CSS(filename=os.path.join(
|
||||
os.path.dirname(__file__), '..', 'css', 'tests_ua.css'
|
||||
os.path.dirname(__file__), '..', 'weasyprint', 'css', 'tests_ua.css'
|
||||
))
|
||||
|
||||
|