setup.py 3.61 KB
Newer Older
spmohanty's avatar
spmohanty committed
1
2
3
4
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""The setup script."""
5
import os
6
import platform
7
import sys
8

9
from setuptools import setup, find_packages
spmohanty's avatar
spmohanty committed
10
11
12
13
14
15
16

with open('README.rst') as readme_file:
    readme = readme_file.read()

with open('HISTORY.rst') as history_file:
    history = history_file.read()

u214892's avatar
u214892 committed
17
# install pycairo on Windows
18
19
20
21
22
if os.name == 'nt':
    p = platform.architecture()
    is64bit = p[0] == '64bit'
    if sys.version[0:3] == '3.5':
        if is64bit:
23
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp35-cp35m-win_amd64.whl'
24
        else:
25
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp35-cp35m-win32.whl'
26
27
28

    if sys.version[0:3] == '3.6':
        if is64bit:
29
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp36-cp36m-win_amd64.whl'
30
        else:
31
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp36-cp36m-win32.whl'
32
33
34

    if sys.version[0:3] == '3.7':
        if is64bit:
35
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp37-cp37m-win_amd64.whl'
36
        else:
37
            url = 'https://download.lfd.uci.edu/pythonlibs/t4jqbe6o/pycairo-1.18.1-cp37-cp37m-win32.whl'
38
39
40
41

    try:
        import pycairo
    except:
u214892's avatar
u214892 committed
42
        call_cmd = "pip install " + url
43
44
45
46
        os.system(call_cmd)

        import site
        import ctypes.util
47

48
49
50
        default_os_path = os.environ['PATH']
        os.environ['PATH'] = ''
        for s in site.getsitepackages():
51
52
            os.environ['PATH'] = os.environ['PATH'] + ';' + s + '\\cairo'
        os.environ['PATH'] = os.environ['PATH'] + ';' + default_os_path
53
        print(os.environ['PATH'])
54
        if ctypes.util.find_library('cairo') is not None:
55
56
57
58
59
60
61
            print("cairo installed: OK")
else:
    try:
        import pycairo
    except:
        os.system("pip install pycairo==1.18.1")

62
63
64
65

def get_all_svg_files(directory='./svg/'):
    ret = []
    for f in os.listdir(directory):
66
        if os.path.isfile(os.path.join(directory, f)):
u214892's avatar
u214892 committed
67
            ret.append(directory + f)
68
69
70
    return ret


71
72
73
74
75
76
77
78
def get_all_images_files(directory='./images/'):
    ret = []
    for f in os.listdir(directory):
        if os.path.isfile(os.path.join(directory, f)):
            ret.append(directory + f)
    return ret


79
80
81
82
83
84
85
86
87
88
89
90
# Gather requirements from requirements_dev.txt
install_reqs = []
requirements_path = 'requirements_dev.txt'
with open(requirements_path, 'r') as f:
    install_reqs += [
        s for s in [
            line.strip(' \n') for line in f
        ] if not s.startswith('#') and s != ''
    ]
requirements = install_reqs
setup_requirements = install_reqs
test_requirements = install_reqs
spmohanty's avatar
spmohanty committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

setup(
    author="S.P. Mohanty",
    author_email='mohanty@aicrowd.com',
    classifiers=[
        'Development Status :: 2 - Pre-Alpha',
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
    ],
    description="Multi Agent Reinforcement Learning on Trains",
    entry_points={
        'console_scripts': [
            'flatland=flatland.cli:main',
        ],
    },
    install_requires=requirements,
    long_description=readme + '\n\n' + history,
    include_package_data=True,
    keywords='flatland',
112
    name='flatland-rl',
spiglerg's avatar
spiglerg committed
113
    packages=find_packages('.'),
114
    data_files=[('svg', get_all_svg_files()), ('images', get_all_images_files())],
spmohanty's avatar
spmohanty committed
115
116
117
    setup_requires=setup_requirements,
    test_suite='tests',
    tests_require=test_requirements,
118
    url='https://gitlab.aicrowd.com/flatland/flatland',
spmohanty's avatar
spmohanty committed
119
    version='0.1.1',
spmohanty's avatar
spmohanty committed
120
121
    zip_safe=False,
)