Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit acffc34

Browse files
committed
Use setuptools_scm, no more hardcoded version / MANIFEST
1 parent 0d5127e commit acffc34

File tree

6 files changed

+69
-67
lines changed

6 files changed

+69
-67
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# PyPi stuff
77
build
88
dist
9+
.eggs
910
*.egg-info
1011

1112
# Local docs builds

‎HOWTOCONTRIBUTE.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ and offer suggestions.
165165
Release procedure
166166
=================
167167

168-
ProPlot follows semantic versioning, e.g., v1.0.0. A major version causes incompatible
168+
ProPlot will follow semantic versioning, e.g. v1.0.0. A major version causes incompatible
169169
API changes, a minor version adds functionality, and a patch covers bug fixes.
170170

171171
#. Create a new branch ``release-vX.x.x`` with the version for the release.
@@ -176,6 +176,13 @@ API changes, a minor version adds functionality, and a patch covers bug fixes.
176176

177177
#. After all tests pass and the PR has been approved, merge the PR into ``master``.
178178

179+
#. Pull down the new version of master:
180+
181+
.. code-block:: bash
182+
183+
git checkout master
184+
git pull
185+
179186
#. Tag a release and push to github:
180187

181188
.. code-block:: bash
@@ -187,7 +194,7 @@ API changes, a minor version adds functionality, and a patch covers bug fixes.
187194

188195
.. code-block:: bash
189196
190-
git clean -xfd # remove any files not checked into git
197+
git clean -xfd # remove files not checked into git
191198
python setup.py sdist bdist_wheel --universal # build package
192199
twine upload dist/* # register and push to pypi
193200

‎MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎proplot/__init__.py

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# Have sepearate files for various categories, so we don't end up with a
55
# single enormous 12,000-line file
66
#------------------------------------------------------------------------------#
7-
# Constants
8-
name = 'ProPlot'
9-
__version__ = '0.1'
10-
117
# Monkey patch warnings format for warnings issued by ProPlot, make sure to
128
# detect if this is just a matplotlib warning traced back to ProPlot code
139
# See: https://stackoverflow.com/a/2187390/4970632
@@ -55,46 +51,31 @@ def _warning_proplot(message, category, filename, lineno, line=None):
5551
+ '# See https://proplot.readthedocs.io/en/latest/rctools.html\n'
5652
+ lines)
5753

58-
# Initialize customization folders and files
59-
import os
60-
_rc_folder = os.path.join(os.path.expanduser('~'), '.proplot')
61-
if not os.path.isdir(_rc_folder):
62-
os.mkdir(_rc_folder)
63-
for _rc_sub in ('cmaps', 'cycles', 'colors', 'fonts'):
64-
_rc_sub = os.path.join(_rc_folder, _rc_sub)
65-
if not os.path.isdir(_rc_sub):
66-
os.mkdir(_rc_sub)
67-
_rc_file = os.path.join(os.path.expanduser('~'), '.proplotrc')
68-
_rc_file_default = os.path.join(os.path.dirname(__file__), '.proplotrc')
69-
if not os.path.isfile(_rc_file):
70-
with open(_rc_file_default) as f:
71-
lines = ''.join(
72-
'# ' + line if line.strip() and line[0] != '#' else line
73-
for line in f.readlines()
74-
)
75-
with open(_rc_file, 'x') as f:
76-
f.write('# User default settings\n'
77-
+ '# See https://proplot.readthedocs.io/en/latest/rctools.html\n'
78-
+ lines)
79-
80-
# Import stuff
81-
# WARNING: Import order is meaningful! Loads modules that are dependencies
82-
# of other modules last, and loads styletools early so we can try to update
83-
# TTFPATH before the fontManager is loaded by other matplotlib modules
54+
# Import stuff in reverse dependency order
55+
# Make sure to load styletools early so we can try to update TTFPATH before
56+
# the fontManager is loaded by other modules (requiring a rebuild)
8457
from .utils import _benchmark
8558
with _benchmark('total time'):
8659
from .utils import *
87-
with _benchmark('styletools'): # colors and fonts
60+
with _benchmark('styletools'):
8861
from .styletools import *
89-
with _benchmark('rctools'): # custom configuration implementation
62+
with _benchmark('rctools'):
9063
from .rctools import *
91-
with _benchmark('axistools'): # locators, normalizers, and formatters
64+
with _benchmark('axistools'):
9265
from .axistools import *
93-
with _benchmark('wrappers'): # wrappers
66+
with _benchmark('wrappers'):
9467
from .wrappers import *
95-
with _benchmark('projs'): # map projections and tools
68+
with _benchmark('projs'):
9669
from .projs import *
97-
with _benchmark('axes'): # axes classes
70+
with _benchmark('axes'):
9871
from .axes import *
99-
with _benchmark('subplots'): # subplots and figure class
72+
with _benchmark('subplots'):
10073
from .subplots import *
74+
75+
# SCM versioning
76+
import pkg_resources as _pkg
77+
name = 'ProPlot'
78+
try:
79+
version = __version__ = _pkg.get_distribution(__name__).version
80+
except _pkg.DistributionNotFound:
81+
version = __version__ = 'unknown'

‎proplot/styletools.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,12 +2644,14 @@ def _load_cmap_cycle(filename, cmap=False):
26442644
@_timer
26452645
def register_cmaps():
26462646
"""
2647-
Adds colormaps packaged with ProPlot or saved to the ``~/.proplot/cmaps``
2647+
Add colormaps packaged with ProPlot or saved to the ``~/.proplot/cmaps``
26482648
folder. This is called on import. Maps are registered according to their
26492649
filenames -- for example, ``name.xyz`` will be registered as ``'name'``.
2650-
Use `show_cmaps` to generate a table of the registered colormaps
26512650
2652-
Valid extensions are described in the below table.
2651+
This is called on import. Use `show_cmaps` to generate a table of the
2652+
registered colormaps
2653+
2654+
Valid extensions are listed in the below table.
26532655
26542656
===================== =============================================================================================================================================================================================================
26552657
Extension Description
@@ -2704,13 +2706,14 @@ def register_cmaps():
27042706
@_timer
27052707
def register_cycles():
27062708
"""
2707-
Adds color cycles packaged with ProPlot or saved to the ``~/.proplot/cycles``
2709+
Add color cycles packaged with ProPlot or saved to the ``~/.proplot/cycles``
27082710
folder. This is called on import. Cycles are registered according to their
27092711
filenames -- for example, ``name.hex`` will be registered under the name
27102712
``'name'`` as a `~matplotlib.colors.ListedColormap` map (see `Cycle` for
2711-
details). Use `show_cycles` to generate a table of the registered cycles.
2713+
details).
27122714
2713-
For valid file formats, see `register_cmaps`.
2715+
This is called on import. Use `show_cycles` to generate a table of the
2716+
registered cycles. For valid file formats, see `register_cmaps`.
27142717
"""
27152718
# Empty out user-accessible cycle list
27162719
cycles.clear()
@@ -2746,10 +2749,15 @@ def register_cycles():
27462749
@_timer
27472750
def register_colors(nmax=np.inf):
27482751
"""
2749-
Reads full database of crowd-sourced XKCD color names and official
2750-
Crayola color names, then filters them to be sufficiently "perceptually
2751-
distinct" in the HCL colorspace. This is called on import. Use `show_colors`
2752-
to generate a table of the resulting filtered colors.
2752+
Add color names packaged with ProPlot or saved to the ``~/.proplot/colors``
2753+
folder. ProPlot loads the crowd-sourced XKCD color
2754+
name database, Crayola crayon color database, and any user input
2755+
files, then filters them to be "perceptually distinct" in the HCL
2756+
colorspace. Files must just have one line per color in the format
2757+
``name : hex``. Whitespace is ignored.
2758+
2759+
This is called on import. Use `show_colors` to generate a table of the
2760+
resulting colors.
27532761
"""
27542762
# Reset native colors dictionary and add some default groups
27552763
# Add in CSS4 so no surprises for user, but we will not encourage this
@@ -2781,7 +2789,7 @@ def register_colors(nmax=np.inf):
27812789
dict_ = {name:color for name,color in data}
27822790
colordict.update({'open': dict_})
27832791
continue
2784-
# Other color dictionaries are filtered, and their names are sanitized
2792+
# Remaining dicts are filtered and their names are sanitized
27852793
i = 0
27862794
dict_ = {}
27872795
ihcls = []
@@ -2803,16 +2811,21 @@ def register_colors(nmax=np.inf):
28032811

28042812
# Remove colors that are 'too similar' by rounding to the nearest n units
28052813
# WARNING: Unique axis argument requires numpy version >=1.13
2806-
deleted = 0
2807-
hcls = hcls/np.array(scale)
2808-
hcls = np.round(hcls/FILTER_THRESH).astype(np.int64)
2809-
_, idxs, _ = np.unique(hcls, return_index=True, return_counts=True, axis=0) # get unique rows
2810-
for idx,(cat,name) in enumerate(pairs):
2811-
if name not in FILTER_ADD and idx not in idxs:
2812-
deleted += 1
2813-
else:
2814-
colordict[cat][name] = _colordict_unfiltered[cat][name]
2815-
# Add to colors mapping
2814+
if hcls.size > 0:
2815+
hcls = hcls/np.array(scale)
2816+
hcls = np.round(hcls/FILTER_THRESH).astype(np.int64)
2817+
deleted = 0
2818+
_, idxs, _ = np.unique(hcls,
2819+
return_index=True,
2820+
return_counts=True,
2821+
axis=0) # get unique rows
2822+
for idx,(cat,name) in enumerate(pairs):
2823+
if name not in FILTER_ADD and idx not in idxs:
2824+
deleted += 1
2825+
else:
2826+
colordict[cat][name] = _colordict_unfiltered[cat][name]
2827+
2828+
# Update the color converter
28162829
for _,kw in colordict.items():
28172830
mcolors.colorConverter.colors.update(kw)
28182831

‎setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
setup(
3131
url = 'https://lukelbd.github.io/proplot',
3232
name = 'proplot',
33-
version = '1.0',
3433
author = 'Luke Davis',
3534
author_email = '[email protected]',
3635
maintainer = 'Luke Davis',
@@ -42,11 +41,16 @@
4241
'Source Code': 'https://github.com/lukelbd/proplot'
4342
},
4443
packages = ['proplot'],
45-
package_data = {'': ['cmaps/*', 'fonts/*', 'colors/*', '.proplotrc']},
46-
include_package_data = True, # use MANIFEST.in
4744
classifiers = classifiers,
45+
include_package_data = True, # normally uses MANIFEST.in but setuptools_scm auto-detects tracked files
4846
install_requires = install_req,
4947
license = license_text,
5048
description = 'A comprehensive wrapper for making beautiful, publication-quality graphics.',
5149
long_description = long_description,
50+
use_scm_version={'version_scheme': 'post-release', 'local_scheme': 'dirty-tag'},
51+
setup_requires=[
52+
'setuptools_scm',
53+
'setuptools>=30.3.0',
54+
'setuptools_scm_git_archive',
55+
],
5256
)

0 commit comments

Comments
 (0)