Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
killiansheriff committed Mar 5, 2024
1 parent 88a81a5 commit 63fa710
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 56 deletions.
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
global-include *.mplstyle
global-include *.md
global-include *.mplstyle
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
![PyPI Version](https://img.shields.io/pypi/v/LovelyPlots.svg) ![PyPI Downloads](https://static.pepy.tech/badge/LovelyPlots) [![doi](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.6903937-blue)](
http://doi.org/10.5281/zenodo.6903937)

> **Warning**
> : As of version 1.0.0, you need to add ``import LovelyPlots`` before setting the style (``plt.style.use('ipynb')``).
LovelyPlots is a repository containing ``matplotlib`` style sheets to nicely format figures for scientific papers, thesis and presentations while keeping them fully editable in ``Adobe Illustrator``. Additonaly, ``.svg`` exports options allows figures to automatically adapt their font to your document's font. For example, ``.svg`` figures imported in a ``.tex`` file will automatically be generated with the text font used in your ``.tex`` file.

<p align="center" width="50%">
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[build-system]
requires = ["setuptools", "matplotlib"]

requires = ["setuptools", "matplotlib"]
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

73 changes: 25 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,44 @@

# to setup on Pypi: https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3

"""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
"""Install LovelyPlots.
This script (setup.py) will install the LovelyPlots package.
In order to expose .mplstyle files to matplotlib, "import lovelyplots"
must be called before plt.style.use(...).
"""

import atexit
import glob
import os
import shutil

import matplotlib
from setuptools import setup, find_packages
from setuptools.command.install import install


def install_styles():
# Find all style files
stylefiles = glob.glob("LovelyPlots/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))
print(mpl_stylelib_dir)
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)

from setuptools import setup

# 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:
with open(os.path.join(root, 'README.md'), 'r', encoding='utf-8') as f:
long_description = f.read()

setup(
name="LovelyPlots",
version="0.0.27",
packages=find_packages(exclude=["tests.*", "tests", "figs", "examples"]),
name='LovelyPlots',
version='1.0.0',
author="Killian Sheriff",
author_email="[email protected]",
author_email="[email protected]",
description="Format Matplotlib Plots for thesis, scientific papers and reports.",
long_description=long_description,
long_description_content_type="text/markdown",
long_description_content_type='text/markdown',
license="MIT",
url="https://github.com/killiansheriff/LovelyPlots",

install_requires=['matplotlib'],
packages=["LovelyPlots"],
package_data={
'scienceplots': ['styles/**/*.mplstyle'],
},

classifiers=[
'Framework :: Matplotlib',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3'
],
keywords=[
"matplotlib-style-sheets",
"matplotlib-figures",
Expand All @@ -66,12 +51,4 @@ def __init__(self, *args, **kwargs):
"Latex",
"latex-figures",
],
url="https://github.com/killiansheriff/LovelyPlots",
install_requires=[
"matplotlib",
],
cmdclass={
"install": PostInstallMoveFile,
},
include_package_data=True,
)
)

0 comments on commit 63fa710

Please sign in to comment.