-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathsetup.py
More file actions
186 lines (156 loc) · 5.67 KB
/
setup.py
File metadata and controls
186 lines (156 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/python
import os
import platform
from setuptools import Extension
from setuptools import setup, find_packages
kn_platform_build_dir = {
('Linux', 'x86_64'): 'linuxX64',
('Linux', 'aarch64'): 'linuxArm64',
('Darwin', 'x86_64'): 'macosX64',
('Darwin', 'arm64'): 'macosArm64',
('Windows', 'AMD64'): 'mingwX64',
}
this_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(this_dir)
this_system = platform.system()
kotlin_bridge_src = os.path.join(this_dir, 'kotlin-bridge', 'lets_plot_kotlin_bridge.c')
binaries_build_path = os.path.join(root_dir, 'python-extension', 'build', 'bin',
kn_platform_build_dir[(platform.system(), platform.machine())], 'releaseStatic')
imagemagick_lib_path = os.environ.get('IMAGICK_LIB_PATH')
python_package = 'lets_plot'
def update_js():
js_relative_path = ['js-package', 'build', 'kotlin-webpack', 'js', 'productionExecutable']
js_libs = [
'lets-plot',
]
from shutil import copy
for lib in js_libs:
js_path = os.path.join(root_dir, *js_relative_path, lib + '.js')
dst_dir = os.path.join(this_dir, python_package, 'package_data')
if not os.path.isdir(dst_dir):
os.mkdir(dst_dir)
dst_path = os.path.join(dst_dir, lib + '.min.js')
copy(js_path, dst_path)
version_locals = {}
with open(os.path.join(this_dir, python_package, '_version.py')) as f:
exec(f.read(), {}, version_locals)
with open(os.path.join(root_dir, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
static_link_libraries_list = ['lets_plot_python_extension']
extra_link = []
if this_system == 'Darwin':
static_link_libraries_list += ['c++']
extra_link += [
'-Wl,-rpath,/usr/lib',
'-framework', 'Foundation',
'-lz'
]
if imagemagick_lib_path is not None:
extra_link += [
'-Wl,-rpath,@loader_path/../lib',
f'-L{imagemagick_lib_path}/lib',
'-lMagickWand-7.Q16HDRI',
'-lMagickCore-7.Q16HDRI',
'-lfontconfig',
'-lfreetype',
'-lexpat'
]
elif this_system == 'Windows':
static_link_libraries_list += ['stdc++']
# fix python package build with Kotlin v1.7.20 (and later) on Windows.
extra_link += [
'-static-libgcc',
'-static',
'-lbcrypt',
'-lpthread',
'-lz'
]
if imagemagick_lib_path is not None:
extra_link += [
f'-L{imagemagick_lib_path}/lib',
'-lMagickWand-7.Q16HDRI',
'-lMagickCore-7.Q16HDRI',
'-lfontconfig',
'-lfreetype',
'-lexpat',
'-lurlmon',
'-lgdi32',
'-lz'
]
# fix for "cannot find -lmsvcr140: No such file or directory" compiler error on Windows.
import distutils.cygwinccompiler
distutils.cygwinccompiler.get_msvcr = lambda: []
elif this_system == 'Linux':
static_link_libraries_list += ['stdc++']
extra_link += ['-lz']
if imagemagick_lib_path is not None:
extra_link += [
f'-L{imagemagick_lib_path}/lib',
'-lMagickWand-7.Q16HDRI',
'-lMagickCore-7.Q16HDRI',
'-lfontconfig',
'-lfreetype',
'-lexpat'
]
else:
raise ValueError("Unsupported platform.")
# Adds JS package to Python wheel:
update_js()
setup(name='lets-plot',
license="MIT",
license_files=('LICENSE', 'licenses/*'),
version=version_locals['__version__'],
maintainer='JetBrains',
maintainer_email='lets-plot@jetbrains.com',
author='JetBrains',
author_email='lets-plot@jetbrains.com',
project_urls={
"Github": "https://github.com/JetBrains/lets-plot",
"Documentation": 'https://lets-plot.org',
},
url='https://lets-plot.org',
description='An open source library for statistical plotting',
long_description=long_description,
long_description_content_type='text/markdown',
keywords=["ggplot", "ggplot2", "geospatial", "geopandas", "geocoding"],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading",
"Framework :: IPython",
"Framework :: Jupyter",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Visualization",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
],
packages=find_packages(exclude=('test',)),
package_data={
python_package: [
"package_data/*",
],
},
ext_modules=[
Extension('lets_plot_kotlin_bridge',
include_dirs=[binaries_build_path],
libraries=static_link_libraries_list,
library_dirs=[binaries_build_path],
depends=['liblets_plot_python_extension_api.h'],
sources=[kotlin_bridge_src],
extra_link_args=extra_link
)
],
install_requires=[
'pypng', # for geom_imshow
'palettable', # for geom_imshow
'pillow' # for ggsave() to PDF
],
)