Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #70

Closed
v-python opened this issue Jan 25, 2017 · 15 comments
Closed

Windows support #70

v-python opened this issue Jan 25, 2017 · 15 comments

Comments

@v-python
Copy link

v-python commented Jan 25, 2017

I noted the "pure python" and "no windows support" and wondered why.

On Windows, I did pip install svglib and it wasn't blocked, and also installed lxml.

Didn't find any tests after the install, which the readme had sort of hinted might be installed that way, but wouldn't be the second way...

Downloaded the whole shebang as a ZIP from github, which doesn't include the wikipedia samples, I guess, but there were some in "misc". Firefox complained about some of them having syntax errors, and some not having style, so just displayed the XML tree. GNU Emacs on Windows actually showed the graphic form of the .svg which surprised me, I hadn't discovered that feature of Emacs before, but it worked well enough, except didn't scale the images to fit the window, so had to maximize the window to see some of them in full.

Didn't find pyTest, so did a loop over *.svg to run svg2pdf.py (copy of svg2pdf so Windows Python launcher would be happy with it) and while there were some messages on the screen, it seems that .pdf files were generated, and they displayed fine (within the limits of my understanding of what "fine" should look like, based on what I could see in emacs, and cursory visual inspection) except for the airbus.pdf showed up with the fuselage all filled with black. The log of messages appears at the end.

It seems Firefox might not like the ones that don't start with <svg> with full DTD specified, which might be reasonable, but there were a couple, one of which was airbus, that gave a syntax error (pasted below). Not sure if the error is for the or the prior , or the combination.

So I never heard of svglib until the recent "revival" messages on reportlab-users mailing list, so I clearly don't know what I am doing, or how to interpret the errors, and I'm pretty much a novice with SVG, but trying to learn for a project, so I can't presently say much more about all this. But svg2pdf looks like it could be useful for my Windows-based project, if it goes in certain directions... and it seems that a fair bit of the code works fairly well on Windows...

So why isn't there Windows support? :)

==== syntax error from Firefox for airbus.svg ====
XML Parsing Error: undefined entity
Location: file:///D:/downloads/svglib/tests/samples/misc/airbus.svg
Line Number 889, Column 3: <g id="0" name="0" style="&st0;" onclick="displayAttributes(evt)">

==== messages from conversion loop ====
`
D:\downloads\svglib\tests\samples\misc>for %v in (*.svg) do py "C:\program files\Python36\Scripts\svg2pdf.py" %v

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" airbus.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" arcs01.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" arcs02.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" car.svg
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px
Ignoring unit: px

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" logo_a3.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" newlion.svg
Ignoring unit: px
Ignoring unit: px

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" python221imap.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" Python_logo_and_wordmark.svg
Can't handle color: url(#linearGradient1478)
Can't handle color: url(#linearGradient1475)
Ignoring unit: px
Can't handle color: url(#radialGradient1480)

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" rllogo.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" tiger.svg

D:\downloads\svglib\tests\samples\misc>py "C:\program files\Python36\Scripts\svg2pdf.py" timezones.svg

D:\downloads\svglib\tests\samples\misc>`

@deeplook
Copy link
Owner

Thanks for your detailed report! You are right that the test suite is part of a an archived release, but will not be "installed" in the main package, which is kind of standard, I believe. You can run the test suite when following the instructions in tests/README.rst. Pip-installing pytest is kind of mandatory and seems to support Windows as expressed here: https://pypi.python.org/pypi/pytest.

About the airbus example: I'll have a look, again. It was among the first examples I used for no particular reasons, and it's likely not the best one for any good reason, anymore. svglib does render it though without errors on my OS X box.

Apart from that, Windows is "not supported" in the sense that I as the original author and maintainer have no Windows machines around to test svglib on. As this is unlikely to change and in the absence of anybody else jumping in to run such tests regularly before releases, I felt like being on the safer side when claiming there is "no Windows support".

Given your report and vague memories of others by @replabrobin saying it does run on Windows I'm happy to add a comment to the README if some of you can investigate a bit more about the results of running the entire test suite.

@replabrobin
Copy link
Contributor

Hi, I can run all the tests on windows in the standard way using a virtual environment. However, I do see errors.

(py27) C:\code\hg-repos\svglib\tests>py.test -v -s test_basic.py
============================= test session starts =============================
platform win32 -- Python 2.7.8, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 -- c:\code\hg-repos\py27\scripts\python.exe
cachedir: ..\.cache
rootdir: C:\code\hg-repos\svglib, inifile:
collected 26 items

test_basic.py::TestPaths::test_path_normalisation PASSED
test_basic.py::TestPaths::test_relative_move_after_closepath PASSED
test_basic.py::TestPaths::test_cubic_bezier_shorthand PASSED
test_basic.py::TestPaths::test_unclosed_paths PASSED
test_basic.py::TestPaths::test_empty_path PASSED
test_basic.py::TestColorAttrConverter::test_0 PASSED
test_basic.py::TestLengthAttrConverter::test_0 PASSED
test_basic.py::TestLengthAttrConverter::test_1 PASSED
test_basic.py::TestLengthListAttrConverter::test_0 PASSED
test_basic.py::TestTransformAttrConverter::test_0 No handlers could be found for logger "svglib.svglib"
PASSED
test_basic.py::TestAttrConverter::test_0 PASSED
test_basic.py::TestAttrConverter::test_findAttr PASSED
test_basic.py::TestAttrConverter::test_no_fill_on_shape PASSED
test_basic.py::TestAttrConverter::test_fillopacity PASSED
test_basic.py::TestAttrConverter::test_fillrule PASSED
test_basic.py::TestAttrConverter::test_stroke PASSED
test_basic.py::TestApplyTransformOnGroup::test_translate_only_x PASSED
test_basic.py::TestTextNode::test_space_preservation PASSED
test_basic.py::TestTextNode::test_tspan_position PASSED
test_basic.py::TestPolylineNode::test_filling PASSED
test_basic.py::TestUseNode::test_use PASSED
test_basic.py::TestUseNode::test_transform_inherited_by_use PASSED
test_basic.py::TestUseNode::test_use_forward_reference PASSED
test_basic.py::TestUseNode::test_use_node_properties PASSED
test_basic.py::TestUseNode::test_use_node_with_unclosed_path PASSED
test_basic.py::TestViewBox::test_nonzero_origin PASSED

========================== 26 passed in 0.28 seconds ==========================

(py27) C:\code\hg-repos\svglib\tests>py.test -v -s test_samples.py
============================= test session starts =============================
platform win32 -- Python 2.7.8, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 -- c:\code\hg-repos\py27\scripts\python.exe
cachedir: ..\.cache
rootdir: C:\code\hg-repos\svglib, inifile:
collected 8 items

test_samples.py::TestSVGSamples::test_convert_pdf working on [0] C:\code\hg-repos\svglib\tests/samples/misc\airbus.svg
FAILED
test_samples.py::TestSVGSamples::test_create_pdf_uniconv SKIPPED
test_samples.py::TestWikipediaSymbols::test_convert_pdf downloading https://upload.wikimedia.org/wikipedia/commons/f/f7/
Biohazard.svg
downloading https://upload.wikimedia.org/wikipedia/commons/1/11/No_smoking_symbol.svg
downloading https://upload.wikimedia.org/wikipedia/commons/b/b0/Dharma_wheel.svg
downloading https://upload.wikimedia.org/wikipedia/commons/a/a7/Eye_of_Horus_bw.svg
downloading https://upload.wikimedia.org/wikipedia/commons/1/17/Yin_yang.svg
downloading https://upload.wikimedia.org/wikipedia/commons/a/a7/Olympic_flag.svg
downloading https://upload.wikimedia.org/wikipedia/commons/4/46/Ankh.svg
downloading https://upload.wikimedia.org/wikipedia/commons/5/5b/Star_of_life2.svg
downloading https://upload.wikimedia.org/wikipedia/commons/9/97/Tudor_rose.svg
downloading https://upload.wikimedia.org/wikipedia/commons/0/08/Flower-of-Life-small.svg
downloading https://upload.wikimedia.org/wikipedia/commons/d/d0/Countries_by_Population_Density_in_2015.svg
downloading https://upload.wikimedia.org/wikipedia/commons/8/84/CO2_responsibility_1950-2000.svg
working on [0] C:\code\hg-repos\svglib\tests/samples/wikipedia/symbols\Ankh.svg
FAILED
test_samples.py::TestWikipediaSymbols::test_convert_pdf_uniconv SKIPPED
test_samples.py::TestWikipediaFlags::test_convert_pdf ERROR
test_samples.py::TestWikipediaFlags::test_convert_pdf_uniconv SKIPPED
test_samples.py::TestW3CSVG::test_convert_pdf_png downloading http://www.w3.org/Graphics/SVG/Test/20070907/W3C_SVG_12_Ti
nyTestSuite.tar.gz
unpacking W3C_SVG_12_TinyTestSuite.tar.gz
extracting into C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite
ERROR
test_samples.py::TestW3CSVG::test_convert_pdf_uniconv SKIPPED

=================================== ERRORS ====================================
____________ ERROR at setup of TestWikipediaFlags.test_convert_pdf ____________

self = <test_samples.TestWikipediaFlags object at 0x0000000003D624E0>

    def setup_method(self):
        "Check if files exists, else download."

        self.folder_path = "%s/samples/wikipedia/flags" % TEST_ROOT

        # create directory if not already present
        if not exists(self.folder_path):
            os.mkdir(self.folder_path)

        # fetch flags.html, if not already present
        path = join(self.folder_path, "flags.html")
        if not exists(path):
            u = "https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags"
            data = self.fetch_file(u)
            if data:
>               open(path, "w").write(data)
E               UnicodeEncodeError: 'ascii' codec can't encode character u'\xe3' in position 168889: ordinal not in rang
e(128)

test_samples.py:253: UnicodeEncodeError
______________ ERROR at setup of TestW3CSVG.test_convert_pdf_png ______________

self = <test_samples.TestW3CSVG object at 0x0000000003A53C88>

    def setup_method(self):
        "Check if testsuite archive exists, else download and unpack it."

        server = "http://www.w3.org"
        path = "/Graphics/SVG/Test/20070907/W3C_SVG_12_TinyTestSuite.tar.gz"
        url = server + path

        archive_path = basename(url)
        tar_path = splitext(archive_path)[0]
        self.folder_path = join(TEST_ROOT, "samples", splitext(tar_path)[0])
        if not exists(self.folder_path):
            if not exists(join(TEST_ROOT, "samples", tar_path)):
                if not exists(join(TEST_ROOT, "samples", archive_path)):
                    print("downloading %s" % url)
                    try:
                        data = urlopen(url).read()
                    except IOError as details:
                        print(details)
                        print("Check your internet connection and try again!")
                        return
                    archive_path = basename(url)
                    open(join(TEST_ROOT, "samples", archive_path), "wb").write(data)
                print("unpacking %s" % archive_path)
                tar_data = gzip.open(join(TEST_ROOT, "samples", archive_path), "rb").read()
                open(join(TEST_ROOT, "samples", tar_path), "wb").write(tar_data)
            print("extracting into %s" % self.folder_path)
            os.mkdir(self.folder_path)
            tar_file = tarfile.TarFile(join(TEST_ROOT, "samples", tar_path))
            tar_file.extractall(self.folder_path)
            if exists(join(TEST_ROOT, "samples", tar_path)):
>               os.remove(join(TEST_ROOT, "samples", tar_path))
E               WindowsError: [Error 32] The process cannot access the file because it is being used by another process:
 'C:\\code\\hg-repos\\svglib\\tests\\samples\\W3C_SVG_12_TinyTestSuite.tar'

test_samples.py:371: WindowsError
================================== FAILURES ===================================
_______________________ TestSVGSamples.test_convert_pdf _______________________

self = <test_samples.TestSVGSamples object at 0x00000000039FF630>

    def test_convert_pdf(self):
        "Test convert sample SVG files to PDF using svglib."

        paths = glob.glob("%s/samples/misc/*" % TEST_ROOT)
        paths = [p for p in paths
            if splitext(p.lower())[1] in [".svg", ".svgz"]]
        for i, path in enumerate(paths):
            print("working on [%d] %s" % (i, path))

            # convert
            drawing = svglib.svg2rlg(path)

            # save as PDF
            base = splitext(path)[0] + '-svglib.pdf'
>           renderPDF.drawToFile(drawing, base, showBoundary=0)

test_samples.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:299: in drawToFile
    draw(d, c, 0, 0, showBoundary=showBoundary)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:29: in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:201: in draw
    self.drawNode(drawing)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:278: in drawNodeDispatcher
    self.drawPath(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <reportlab.graphics.renderPDF._PDFRenderer instance at 0x0000000003D3B088>
path = <reportlab.graphics.shapes.Path instance at 0x0000000003989688>

    def drawPath(self, path):
        from reportlab.graphics.shapes import _renderPath
        pdfPath = self._canvas.beginPath()
        drawFuncs = (pdfPath.moveTo, pdfPath.lineTo, pdfPath.curveTo, pdfPath.close)
        autoclose = getattr(path,'autoclose','')
        fill = self._fill
        stroke = self._stroke
>       isClosed = _renderPath(path, drawFuncs, forceClose=fill and autoclose=='pdf')
E       TypeError: patchedRenderPath() got an unexpected keyword argument 'forceClose'

..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:182: TypeError
____________________ TestWikipediaSymbols.test_convert_pdf ____________________

self = <test_samples.TestWikipediaSymbols object at 0x0000000003EDE9B0>

    def test_convert_pdf(self):
        "Test converting symbol SVG files to PDF using svglib."

        paths = glob.glob("%s/*" % self.folder_path)
        paths = [p for p in paths
            if splitext(p.lower())[1] in [".svg", ".svgz"]]
        for i, path in enumerate(paths):
            print("working on [%d] %s" % (i, path))

            # convert
            drawing = svglib.svg2rlg(path)

            # save as PDF
            base = splitext(path)[0] + '-svglib.pdf'
>           renderPDF.drawToFile(drawing, base, showBoundary=0)

test_samples.py:178:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:299: in drawToFile
    draw(d, c, 0, 0, showBoundary=showBoundary)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:29: in draw
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:201: in draw
    self.drawNode(drawing)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:282: in drawNodeDispatcher
    self.drawGroup(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:311: in drawGroup
    self.drawNode(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:54: in drawNode
    self.drawNodeDispatcher(node)
..\..\py27\lib\site-packages\reportlab\graphics\renderbase.py:278: in drawNodeDispatcher
    self.drawPath(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <reportlab.graphics.renderPDF._PDFRenderer instance at 0x0000000003D24348>
path = <reportlab.graphics.shapes.Path instance at 0x0000000003DE1688>

    def drawPath(self, path):
        from reportlab.graphics.shapes import _renderPath
        pdfPath = self._canvas.beginPath()
        drawFuncs = (pdfPath.moveTo, pdfPath.lineTo, pdfPath.curveTo, pdfPath.close)
        autoclose = getattr(path,'autoclose','')
        fill = self._fill
        stroke = self._stroke
>       isClosed = _renderPath(path, drawFuncs, forceClose=fill and autoclose=='pdf')
E       TypeError: patchedRenderPath() got an unexpected keyword argument 'forceClose'

..\..\py27\lib\site-packages\reportlab\graphics\renderPDF.py:182: TypeError
================ 2 failed, 4 skipped, 2 error in 27.98 seconds ================

(py27) C:\code\hg-repos\svglib\tests>

@deeplook
Copy link
Owner

If nobody volunteers within a week to provide something like regular windows support I'll just cloae this issue, soon.

@claudep
Copy link
Collaborator

claudep commented Mar 26, 2017

I'm not able to debug Windows issues. However I think the issue should still stay open in the case someone will step up. That way, people encountering issues with Windows can come here and see "Oh, Windows issues are already reported".

@deeplook
Copy link
Owner

Ok, agreed.

@replabrobin
Copy link
Contributor

replabrobin commented Mar 27, 2017

Hi, I tried again with an installation test; I see errors related to using px; unfortunately px is not supported by reportlab and it's unlikely it should be. Traditionally 1px==1pt, but the conversion ratio is screen dependent ie dots per inch comes into the definition somewhere, but that cannot be known to the PDF unless we start some serious laziness ie get javascript to look at the screen (I'm not even sure that's possible in PDF) and then render the SVG dynamically.

  1. hg clone git+https://github.com/deeplook/svglib.git
  2. \python27\python -mvirtualenv svglib
  3. cd svglib
  4. scripts\activate
  5. python setup.py install #installs from source
  6. rm -rf Lib\site-packages svglib-0.8.0-py2.7.egg #pip uninstall svglib would not work
  7. pip install pytests
  8. cd tests
  9. set PYTHONPATH=.
  10. py.test
(svglib) C:\code\hg-repos\svglib\tests>py.test
============================= test session starts =============================
platform win32 -- Python 2.7.13, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: C:\code\hg-repos\svglib, inifile:
collected 36 items

test_basic.py ............................
test_samples.py FsFs.sFs

================================== FAILURES ===================================
_______________________ TestSVGSamples.test_convert_pdf _______________________

self = <test_samples.TestSVGSamples object at 0x00000000040B6550>

    def test_convert_pdf(self):
        "Test convert sample SVG files to PDF using svglib."

        paths = glob.glob("%s/samples/misc/*" % TEST_ROOT)
        paths = [p for p in paths
            if splitext(p.lower())[1] in [".svg", ".svgz"]]
        for i, path in enumerate(paths):
            print("working on [%d] %s" % (i, path))

            # convert
>           drawing = svglib.svg2rlg(path)

test_samples.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\svglib\svglib.py:1034: in svg2rlg
    drawing = svgRenderer.render(svg)
..\svglib\svglib.py:369: in render
    main_group = self.renderNode(svg_node)
..\svglib\svglib.py:390: in renderNode
    item = self.renderSvg(n)
..\svglib\svglib.py:471: in renderSvg
    width, height = map(self.attrConverter.convertLength, (width, height))
..\svglib\svglib.py:234: in convertLength
    length = toLength(text)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

s = '242px'

    def toLength(s):
        '''convert a string to  a length'''
        try:
            if s[-2:]=='cm': return float(s[:-2])*cm
            if s[-2:]=='in': return float(s[:-2])*inch
            if s[-2:]=='pt': return float(s[:-2])
            if s[-1:]=='i': return float(s[:-1])*inch
            if s[-2:]=='mm': return float(s[:-2])*mm
            if s[-4:]=='pica': return float(s[:-4])*pica
            return float(s)
        except:
>           raise ValueError("Can't convert '%s' to length" % s)
E           ValueError: Can't convert '242px' to length

..\lib\site-packages\reportlab-3.4.0-py2.7-win-amd64.egg\reportlab\lib\units.py:30: ValueError
---------------------------- Captured stdout call -----------------------------
working on [0] C:\code\hg-repos\svglib\tests/samples/misc\airbus.svg
working on [1] C:\code\hg-repos\svglib\tests/samples/misc\arcs01.svg
working on [2] C:\code\hg-repos\svglib\tests/samples/misc\arcs02.svg
working on [3] C:\code\hg-repos\svglib\tests/samples/misc\car.svg
working on [4] C:\code\hg-repos\svglib\tests/samples/misc\logo_a3.svg
working on [5] C:\code\hg-repos\svglib\tests/samples/misc\newlion.svg
____________________ TestWikipediaSymbols.test_convert_pdf ____________________

self = <test_samples.TestWikipediaSymbols object at 0x00000000043CEF60>

    def test_convert_pdf(self):
        "Test converting symbol SVG files to PDF using svglib."

        paths = glob.glob("%s/*" % self.folder_path)
        paths = [p for p in paths
            if splitext(p.lower())[1] in [".svg", ".svgz"]]
        for i, path in enumerate(paths):
            print("working on [%d] %s" % (i, path))

            # convert
>           drawing = svglib.svg2rlg(path)

test_samples.py:174:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\svglib\svglib.py:1034: in svg2rlg
    drawing = svgRenderer.render(svg)
..\svglib\svglib.py:369: in render
    main_group = self.renderNode(svg_node)
..\svglib\svglib.py:390: in renderNode
    item = self.renderSvg(n)
..\svglib\svglib.py:480: in renderSvg
    self.renderNode(child, group)
..\svglib\svglib.py:399: in renderNode
    item = self.renderG(n, clipping=clipping)
..\svglib\svglib.py:490: in renderG
    item = self.renderNode(child, parent=gr)
..\svglib\svglib.py:412: in renderNode
    item = self.shape_converter.convertShape(name, n, clipping)
..\svglib\svglib.py:563: in convertShape
    shape = getattr(self, method_name)(node)
..\svglib\svglib.py:690: in convertText
    fs = attrConv.convertLength(fs)
..\svglib\svglib.py:234: in convertLength
    length = toLength(text)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

s = '40px'

    def toLength(s):
        '''convert a string to  a length'''
        try:
            if s[-2:]=='cm': return float(s[:-2])*cm
            if s[-2:]=='in': return float(s[:-2])*inch
            if s[-2:]=='pt': return float(s[:-2])
            if s[-1:]=='i': return float(s[:-1])*inch
            if s[-2:]=='mm': return float(s[:-2])*mm
            if s[-4:]=='pica': return float(s[:-4])*pica
            return float(s)
        except:
>           raise ValueError("Can't convert '%s' to length" % s)
E           ValueError: Can't convert '40px' to length

..\lib\site-packages\reportlab-3.4.0-py2.7-win-amd64.egg\reportlab\lib\units.py:30: ValueError
---------------------------- Captured stdout call -----------------------------
working on [0] C:\code\hg-repos\svglib\tests/samples/wikipedia/symbols\Ankh.svg
working on [1] C:\code\hg-repos\svglib\tests/samples/wikipedia/symbols\Biohazard.svg
working on [2] C:\code\hg-repos\svglib\tests/samples/wikipedia/symbols\CO2_responsibility_1950-2000.svg
_______________________ TestW3CSVG.test_convert_pdf_png _______________________

self = <test_samples.TestW3CSVG object at 0x0000000002C24588>

    def test_convert_pdf_png(self):
        """
            Test converting W3C SVG files to PDF and PNG using svglib.

            ``renderPM.drawToFile()`` used in this test is known to trigger an
            error sometimes in reportlab which was fixed in reportlab 3.3.26.
            See https://github.com/deeplook/svglib/issues/47
            """

        exclude_list = [
            "paint-stroke-06-t.svg",
            "coords-trans-09-t.svg",  # renderPDF issue (div by 0)
            # Unsupported 'transform="ref(svg, ...)"' expression
            "coords-constr-201-t.svg",
            "coords-constr-202-t.svg",
            "coords-constr-203-t.svg",
            "coords-constr-204-t.svg",
        ]

        paths = glob.glob("%s/svg/*.svg" % self.folder_path)
        msg = "Destination folder '%s/svg' not found." % self.folder_path
        assert len(paths) > 0, msg

        for i, path in enumerate(paths):
            print("working on [%d] %s" % (i, path))

            if basename(path) in exclude_list:
                print("excluded (to be tested later)")
                continue

            # convert
>           drawing = svglib.svg2rlg(path)

test_samples.py:416:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\svglib\svglib.py:1034: in svg2rlg
    drawing = svgRenderer.render(svg)
..\svglib\svglib.py:369: in render
    main_group = self.renderNode(svg_node)
..\svglib\svglib.py:390: in renderNode
    item = self.renderSvg(n)
..\svglib\svglib.py:480: in renderSvg
    self.renderNode(child, group)
..\svglib\svglib.py:399: in renderNode
    item = self.renderG(n, clipping=clipping)
..\svglib\svglib.py:490: in renderG
    item = self.renderNode(child, parent=gr)
..\svglib\svglib.py:399: in renderNode
    item = self.renderG(n, clipping=clipping)
..\svglib\svglib.py:490: in renderG
    item = self.renderNode(child, parent=gr)
..\svglib\svglib.py:412: in renderNode
    item = self.shape_converter.convertShape(name, n, clipping)
..\svglib\svglib.py:563: in convertShape
    shape = getattr(self, method_name)(node)
..\svglib\svglib.py:584: in convertLine
    x1, y1, x2, y2 = map(self.attrConverter.convertLength, (x1, y1, x2, y2))
..\svglib\svglib.py:234: in convertLength
    length = toLength(text)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

s = '0px'

    def toLength(s):
        '''convert a string to  a length'''
        try:
            if s[-2:]=='cm': return float(s[:-2])*cm
            if s[-2:]=='in': return float(s[:-2])*inch
            if s[-2:]=='pt': return float(s[:-2])
            if s[-1:]=='i': return float(s[:-1])*inch
            if s[-2:]=='mm': return float(s[:-2])*mm
            if s[-4:]=='pica': return float(s[:-4])*pica
            return float(s)
        except:
>           raise ValueError("Can't convert '%s' to length" % s)
E           ValueError: Can't convert '0px' to length

..\lib\site-packages\reportlab-3.4.0-py2.7-win-amd64.egg\reportlab\lib\units.py:30: ValueError
---------------------------- Captured stdout call -----------------------------
working on [0] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-02-t.svg
working on [1] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-03-t.svg
working on [2] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-04-t.svg
working on [3] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-05-t.svg
working on [4] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-06-t.svg
working on [5] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-07-t.svg
working on [6] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-08-t.svg
working on [7] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-09-t.svg
working on [8] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-10-t.svg
working on [9] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-11-t.svg
working on [10] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-12-t.svg
working on [11] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-13-t.svg
working on [12] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-14-t.svg
working on [13] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-15-t.svg
working on [14] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-17-t.svg
working on [15] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-19-t.svg
working on [16] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-20-t.svg
working on [17] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-201-t.svg
working on [18] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-202-t.svg
working on [19] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-203-t.svg
working on [20] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-206-t.svg
working on [21] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-207-t.svg
working on [22] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-209-t.svg
working on [23] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-21-t.svg
working on [24] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-210-t.svg
working on [25] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-211-t.svg
working on [26] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-212-t.svg
working on [27] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-213-t.svg
working on [28] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-214-t.svg
working on [29] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-215-t.svg
working on [30] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-216-t.svg
working on [31] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-217-t.svg
working on [32] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-218-t.svg
working on [33] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-22-t.svg
working on [34] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-23-t.svg
working on [35] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-24-t.svg
working on [36] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-25-t.svg
working on [37] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-26-t.svg
working on [38] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-27-t.svg
working on [39] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-28-t.svg
working on [40] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-29-t.svg
working on [41] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-30-t.svg
working on [42] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-31-t.svg
working on [43] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-32-t.svg
working on [44] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-33-t.svg
working on [45] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-34-t.svg
working on [46] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-35-t.svg
working on [47] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-36-t.svg
working on [48] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-37-t.svg
working on [49] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-38-t.svg
working on [50] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-39-t.svg
working on [51] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-40-t.svg
working on [52] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-41-t.svg
working on [53] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-44-t.svg
working on [54] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-46-t.svg
working on [55] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-52-t.svg
working on [56] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-53-t.svg
working on [57] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-64-t.svg
working on [58] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-65-t.svg
working on [59] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-66-t.svg
working on [60] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-67-t.svg
working on [61] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-68-t.svg
working on [62] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-69-t.svg
working on [63] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-70-t.svg
working on [64] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-77-t.svg
working on [65] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-78-t.svg
working on [66] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-80-t.svg
working on [67] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-81-t.svg
working on [68] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-82-t.svg
working on [69] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-83-t.svg
working on [70] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-84-t.svg
working on [71] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\animate-elem-85-t.svg
working on [72] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-constr-201-t.svg
excluded (to be tested later)
working on [73] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-constr-202-t.svg
excluded (to be tested later)
working on [74] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-constr-203-t.svg
excluded (to be tested later)
working on [75] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-constr-204-t.svg
excluded (to be tested later)
working on [76] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-coord-01-t.svg
working on [77] C:\code\hg-repos\svglib\tests\samples\W3C_SVG_12_TinyTestSuite/svg\coords-coord-02-t.svg
=============== 3 failed, 29 passed, 4 skipped in 7.16 seconds ================```

@claudep
Copy link
Collaborator

claudep commented Mar 28, 2017

I'm sorry for the px regression. Should be fixed by #80

@nicoddemus
Copy link
Contributor

Hi,

First for all thanks for all your work on this package!

I'm building a conda version of this package for conda-forge and it seems to work fine except for two failing tests:

pytest tests -k "not TestWikipediaFlags.test_convert_pdf"
============================= test session starts =============================
platform win32 -- Python 3.5.3, pytest-3.1.0, py-1.4.33, pluggy-0.4.0
rootdir: e:\Miniconda3\conda-bld\svglib_1495798629498\test_tmp, inifile:
collected 36 items

tests\test_basic.py ............................
tests\test_samples.py .s.sEsEs

=================================== ERRORS ====================================
____________ ERROR at setup of TestWikipediaFlags.test_convert_pdf ____________

self = <test_samples.TestWikipediaFlags object at 0x0000015977C3F588>

    def setup_method(self):
        "Check if files exists, else download."

        self.folder_path = "%s/samples/wikipedia/flags" % TEST_ROOT

        # create directory if not already present
        if not exists(self.folder_path):
            os.mkdir(self.folder_path)

        # fetch flags.html, if not already present
        path = join(self.folder_path, "flags.html")
        if not exists(path):
            u = "https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags"
            data = self.fetch_file(u)
            if data:
>               open(path, "w").write(data)

tests\test_samples.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <encodings.cp1252.IncrementalEncoder object at 0x0000015977C3F438>
input = '<!DOCTYPE html>\r\n<html class="client-nojs" lang="en" dir="ltr">\r\n<head>\r\n<meta charset="UTF-8"/>\r\n<title>Gall...unction(){mw.config.set({"wgBackendResponseTime":2026,"wgHostname":"mw1216"});});</script>\r\n\t</body>\r\n</html>\r\n'
final = False

    def encode(self, input, final=False):
>       return codecs.charmap_encode(input,self.errors,encoding_table)[0]
E       UnicodeEncodeError: 'charmap' codec can't encode character '\u2010' in position 250325: character maps to <undefined>

..\_t_env\lib\encodings\cp1252.py:19: UnicodeEncodeError
______________ ERROR at setup of TestW3CSVG.test_convert_pdf_png ______________

self = <test_samples.TestW3CSVG object at 0x00000159753C7B00>

    def setup_method(self):
        "Check if testsuite archive exists, else download and unpack it."

        server = "http://www.w3.org"
        path = "/Graphics/SVG/Test/20070907/W3C_SVG_12_TinyTestSuite.tar.gz"
        url = server + path

        archive_path = basename(url)
        tar_path = splitext(archive_path)[0]
        self.folder_path = join(TEST_ROOT, "samples", splitext(tar_path)[0])
        if not exists(self.folder_path):
            if not exists(join(TEST_ROOT, "samples", tar_path)):
                if not exists(join(TEST_ROOT, "samples", archive_path)):
                    print("downloading %s" % url)
                    try:
                        data = urlopen(url).read()
                    except IOError as details:
                        print(details)
                        print("Check your internet connection and try again!")
                        return
                    archive_path = basename(url)
                    open(join(TEST_ROOT, "samples", archive_path), "wb").write(data)
                print("unpacking %s" % archive_path)
                tar_data = gzip.open(join(TEST_ROOT, "samples", archive_path), "rb").read()
                open(join(TEST_ROOT, "samples", tar_path), "wb").write(tar_data)
            print("extracting into %s" % self.folder_path)
            os.mkdir(self.folder_path)
            tar_file = tarfile.TarFile(join(TEST_ROOT, "samples", tar_path))
            tar_file.extractall(self.folder_path)
            if exists(join(TEST_ROOT, "samples", tar_path)):
>               os.remove(join(TEST_ROOT, "samples", tar_path))
E               PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'e:\\Miniconda3\\conda-bld\\svglib_1495798629498\\test_tmp\\tests\\samples\\W3C_SVG_12_TinyTestSuite.tar'

tests\test_samples.py:371: PermissionError
---------------------------- Captured stdout setup ----------------------------
downloading http://www.w3.org/Graphics/SVG/Test/20070907/W3C_SVG_12_TinyTestSuite.tar.gz
unpacking W3C_SVG_12_TinyTestSuite.tar.gz
extracting into e:\Miniconda3\conda-bld\svglib_1495798629498\test_tmp\tests\samples\W3C_SVG_12_TinyTestSuite
============================== warnings summary ===============================
tests/test_basic.py::TestTransformAttrConverter::()::test_0
  e:\Miniconda3\conda-bld\svglib_1495798629498\_t_env\lib\site-packages\svglib\svglib.py:191: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    logger.warn("Unable to parse transform expression '%s'" % svgAttr)

tests/test_samples.py::TestSVGSamples::()::test_convert_pdf
  e:\Miniconda3\conda-bld\svglib_1495798629498\_t_env\lib\site-packages\svglib\svglib.py:294: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
    logger.warn("Can't handle color: %s" % text)

tests/test_samples.py::TestWikipediaFlags::()::test_convert_pdf
  e:\Miniconda3\conda-bld\svglib_1495798629498\test_tmp\tests\test_samples.py:253: ResourceWarning: unclosed file <_io.TextIOWrapper name='e:\\Miniconda3\\conda-bld\\svglib_1495798629498\\test_tmp\\tests/samples/wikipedia/flags\\flags.html' mode='w' encoding='cp1252'>
    open(path, "w").write(data)

tests/test_samples.py::TestW3CSVG::()::test_convert_pdf_png
  e:\Miniconda3\conda-bld\svglib_1495798629498\test_tmp\tests\test_samples.py:362: ResourceWarning: unclosed file <_io.BufferedWriter name='e:\\Miniconda3\\conda-bld\\svglib_1495798629498\\test_tmp\\tests\\samples\\W3C_SVG_12_TinyTestSuite.tar.gz'>
    open(join(TEST_ROOT, "samples", archive_path), "wb").write(data)
  e:\Miniconda3\conda-bld\svglib_1495798629498\test_tmp\tests\test_samples.py:365: ResourceWarning: unclosed file <_io.BufferedWriter name='e:\\Miniconda3\\conda-bld\\svglib_1495798629498\\test_tmp\\tests\\samples\\W3C_SVG_12_TinyTestSuite.tar'>
    open(join(TEST_ROOT, "samples", tar_path), "wb").write(tar_data)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
========= 30 passed, 4 skipped, 5 warnings, 2 error in 56.93 seconds ==========

This happens for both py27 and py35.

The tests seem simple to solve, but I notice there's no continuous integration for Windows and Travis actually on the repository. @deeplook is this something you would be interested to add to this project?

@nicoddemus
Copy link
Contributor

Recipe submitted: conda-forge/staged-recipes#3033

@claudep
Copy link
Collaborator

claudep commented May 26, 2017

Please, open a separate ticket for CI setup.

@nicoddemus
Copy link
Contributor

I started working on the ticket with the mentality of "tests on Windows failed", but that changed midway when I noticed the failed tests were simple to solve, and ended up changing the subject to "CI setup" in the end. My apologies.

Done: #86.

@claudep
Copy link
Collaborator

claudep commented Mar 8, 2018

Now I think only the README needs updating.

@claudep claudep closed this as completed in 62cccc3 Mar 8, 2018
@deeplook
Copy link
Owner

deeplook commented Mar 8, 2018

@claudep If you want see if you can give it an update! But just don't let people expect Windows support will be anytime anywhere at par with Unix. 😸

@claudep
Copy link
Collaborator

claudep commented Mar 8, 2018

Sure, but as far as the test suite passes, I think we can claim Windows support, even if I don't have access to Windows machines either.

@nicoddemus
Copy link
Contributor

nicoddemus commented Mar 9, 2018

@claudep indeed, we use svglib in production on Windows for some time now without any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants