Commit 851b52b0 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

Windows support cairo solved: workaround: auto install (see setup.py)

parent f79e81a9
Pipeline #823 failed with stages
in 4 minutes and 42 seconds
# -*- coding: utf-8 -*-
"""Main module."""
......@@ -2,6 +2,17 @@
import matplotlib.pyplot as plt
from numpy import array
import os
if os.name=='nt':
import site
import ctypes.util
default_os_path = os.environ['PATH']
os.environ['PATH'] = ''
for s in site.getsitepackages():
os.environ['PATH'] = os.environ['PATH'] + ';' + s + '\\cairo'
os.environ['PATH'] = os.environ['PATH'] + ';' + default_os_path
if ctypes.util.find_library('cairo') is not None:
print("cairo installed: OK")
class GraphicsLayer(object):
def __init__(self):
......
......@@ -6,7 +6,12 @@ import numpy as np
# from flatland.utils.svg import Track, Zug
import time
import io
from cairosvg import svg2png
from IPython.display import SVG
from flatland.core.transitions import RailEnvTransitions
# from copy import copy
......@@ -234,6 +239,8 @@ class PILSVG(PILGL):
def pilFromSvgFile(self, sfPath):
with open(sfPath, "r") as fIn:
bytesPNG = svg2png(file_obj=fIn, output_height=self.nPixCell, output_width=self.nPixCell)
image = SVG(url=sfPath)
with io.BytesIO(bytesPNG) as fIn:
pil_img = Image.open(fIn)
......
......@@ -20,10 +20,10 @@ xarray==0.11.3
matplotlib==3.0.2
PyQt5==5.12
Pillow==5.4.1
# CairoSVG==2.3.1
# pycairo==1.18.1
# see setup.py pycairo==1.18.1
CairoSVG==2.3.1
msgpack==0.6.1
svgutils==0.3.1
screeninfo==0.3.1
\ No newline at end of file
screeninfo==0.3.1
......@@ -4,6 +4,12 @@
"""The setup script."""
import os
from setuptools import setup, find_packages
import sys
import os
import platform
with open('README.rst') as readme_file:
readme = readme_file.read()
......@@ -11,6 +17,54 @@ with open('README.rst') as readme_file:
with open('HISTORY.rst') as history_file:
history = history_file.read()
# install pycairo
if os.name == 'nt':
p = platform.architecture()
is64bit = p[0] == '64bit'
if sys.version[0:3] == '3.5':
if is64bit:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp35-cp35m-win_amd64.whl'
else:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp35-cp35m-win32.whl'
if sys.version[0:3] == '3.6':
if is64bit:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp36-cp36m-win_amd64.whl'
else:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp36-cp36m-win32.whl'
if sys.version[0:3] == '3.7':
if is64bit:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp37-cp37m-win_amd64.whl'
else:
url = 'https://download.lfd.uci.edu/pythonlibs/q5gtlas7/pycairo-1.18.0-cp37-cp37m-win32.whl'
try:
import pycairo
except:
call_cmd = "pip install " + url
os.system(call_cmd)
import site
import ctypes.util
default_os_path = os.environ['PATH']
os.environ['PATH'] = ''
for s in site.getsitepackages():
os.environ['PATH'] = os.environ['PATH']+';' + s+'\\cairo'
os.environ['PATH'] = os.environ['PATH']+';' + default_os_path
print(os.environ['PATH'])
if ctypes.util.find_library('cairo')is not None:
print("cairo installed: OK")
else:
try:
import pycairo
except:
os.system("pip install pycairo==1.18.1")
# Gather requirements from requirements_dev.txt
# TODO : We could potentially split up the test/dev dependencies later
install_reqs = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment