-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
68 lines (53 loc) · 1.81 KB
/
setup.py
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
import atexit
import glob
import os
import shutil
from setuptools import find_packages, setup
from setuptools.command.install import install
import pkg_resources
# --- Install style files for shart
"""
This code is based on a StackOverflow answer, then improved by ChatGPT:
https://stackoverflow.com/questions/31559225/how-to-ship-or-distribute-a-matplotlib-stylesheet
"""
def install_styles():
import matplotlib
# Find all style files
stylefiles = pkg_resources.resource_listdir('bbq', 'styles')
# Find stylelib directory (where the *.mplstyle files go)
mpl_stylelib_dir = os.path.join(matplotlib.get_configdir(), "stylelib")
if not os.path.exists(mpl_stylelib_dir):
os.makedirs(mpl_stylelib_dir)
# Copy files over
print("Installing styles into", mpl_stylelib_dir)
for stylefile in stylefiles:
style_content = pkg_resources.resource_string('bbq', f'styles/{stylefile}')
with open(os.path.join(mpl_stylelib_dir, stylefile), 'wb') as f:
f.write(style_content)
class PostInstallMoveFile(install):
def run(self):
super().run()
install_styles()
# ---
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name="bbq",
description="Tasty front end for PyRibs.",
author="Adam Gaier",
packages=find_packages(exclude=['data', 'figures', 'output', 'notebooks',
'experiment', 'tests']),
long_description=read('README.md'),
version="0.1.1",
url="https://github.com/agaier/bbq",
install_requires=[
'ribs==0.4.0',
'dask>=2.0.0',
"distributed>=2.0.0",
'fire>=0.4.0',
'humanfriendly>=10.0',
'numpy>=1.17.0',
'matplotlib>=3.0.0',
],
cmdclass={'install': PostInstallMoveFile, },
)