forked from garrettj403/SciencePlots
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
68 lines (56 loc) · 1.99 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
"""Install SciencePlots.
This script (setup.py) will copy the matplotlib styles (*.mplstyle) into the
appropriate directory on your computer (OS dependent).
This code is based on a StackOverflow answer:
https://stackoverflow.com/questions/31559225/how-to-ship-or-distribute-a-matplotlib-stylesheet
"""
import atexit
import glob
import os
import shutil
import matplotlib
from setuptools import setup
from setuptools.command.install import install
def install_styles():
# Find all style files
stylefiles = glob.glob('styles/**/*.mplstyle', recursive=True)
# 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:
print(os.path.basename(stylefile))
shutil.copy(
stylefile,
os.path.join(mpl_stylelib_dir, os.path.basename(stylefile)))
class PostInstallMoveFile(install):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
atexit.register(install_styles)
# Get description from README
root = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(root, 'README.md'), 'r', encoding='utf-8') as f:
long_description = f.read()
setup(
name='SciencePlots',
version='1.0.9',
author="John Garrett",
author_email="[email protected]",
description="Format Matplotlib for scientific plotting",
long_description=long_description,
long_description_content_type='text/markdown',
license="MIT",
keywords=[
"matplotlib-style-sheets",
"matplotlib-figures",
"scientific-papers",
"thesis-template",
"matplotlib-styles",
"python"
],
url="https://github.com/garrettj403/SciencePlots/",
install_requires=['matplotlib', ],
cmdclass={'install': PostInstallMoveFile, },
)