forked from garrettj403/SciencePlots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f76726
commit c2bf367
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
"""Install SciencePlots. | ||
This will copy the *.mplstyle files into the appropriate directory. | ||
This code is based on a StackOverflow answer: | ||
https://stackoverflow.com/questions/31559225/how-to-ship-or-distribute-a-matplotlib-stylesheet | ||
""" | ||
|
||
from setuptools import setup | ||
from setuptools.command.install import install | ||
import os | ||
import shutil | ||
import atexit | ||
# import fnmatch | ||
import glob | ||
|
||
import matplotlib | ||
|
||
def install_styles(): | ||
|
||
# Find all style files | ||
# stylefiles = [] | ||
# for root, dirnames, filenames in os.walk('styles'): | ||
# for filename in fnmatch.filter(filenames, '*.mplstyle'): | ||
# stylefiles.append(os.path.join(root, filename)) | ||
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( | ||
os.path.join(os.path.dirname(__file__), stylefile), | ||
os.path.join(mpl_stylelib_dir, stylefile)) | ||
|
||
class PostInstallMoveFile(install): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
atexit.register(install_styles) | ||
|
||
setup( | ||
name='SciencePlots', | ||
version='1.0.0', | ||
author="John Garrett", | ||
author_email="[email protected]", | ||
description="Format Matplotlib for scientific plotting", | ||
license="MIT", | ||
keywords=[ | ||
"matplotlib-style-sheets", | ||
"matplotlib-figures", | ||
"scientific-papers", | ||
"thesis-template", | ||
"matplotlib-styles", | ||
"python" | ||
], | ||
url="https://github.com/garrettj403/SciencePlots/", | ||
# py_modules=['styles'], | ||
package_data = { | ||
'styles': [ | ||
"misc/no-latex.mplstyle", | ||
"misc/pgf.mplstyle", | ||
"science.mplstyle", | ||
"color/muted.mplstyle", | ||
"color/vibrant.mplstyle", | ||
"color/high-vis.mplstyle", | ||
"color/bright.mplstyle", | ||
"color/retro.mplstyle", | ||
"scatter.mplstyle", | ||
"journals/ieee.mplstyle", | ||
"notebook.mplstyle" | ||
] | ||
}, | ||
install_requires=[ | ||
'matplotlib', | ||
], | ||
cmdclass={ | ||
'install': PostInstallMoveFile, | ||
} | ||
) |