-
Notifications
You must be signed in to change notification settings - Fork 32
Modernize packaging config #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ resulting visualizations and use the editor tool `on this website | |
<https://bids.github.io/colormap/>`_. | ||
|
||
Downloads: | ||
https://pypi.python.org/pypi/viscm/ | ||
* https://pypi.python.org/pypi/viscm/ | ||
* https://anaconda.org/conda-forge/viscm/ | ||
|
||
Code and bug tracker: | ||
https://github.com/matplotlib/viscm | ||
|
@@ -23,10 +24,10 @@ Contact: | |
Nathaniel J. Smith <[email protected]> and Stéfan van der Walt <[email protected]> | ||
|
||
Dependencies: | ||
* Python 2.6+, or 3.3+ | ||
* Python 3.7+ | ||
* `colorspacious <https://pypi.python.org/pypi/colorspacious>`_ | ||
* Matplotlib | ||
* NumPy | ||
|
||
License: | ||
MIT, see LICENSE.txt for details. | ||
MIT, see `LICENSE <LICENSE>`__ for details. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Contributing | ||
|
||
Install development dependencies: | ||
|
||
``` | ||
conda env create # or `mamba env create` | ||
``` | ||
|
||
|
||
## Development install | ||
|
||
``` | ||
pip install -e . | ||
``` | ||
|
||
|
||
## Testing the build | ||
|
||
``` | ||
rm -rf dist | ||
python -m build | ||
pip install dist/*.whl # or `dist/*.tar.gz` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a comment to point out the two different distributions that could be installed and tested locally. If the wheel works, the source dist should definitely work, so maybe not worth calling this out. |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: "viscm" | ||
channels: | ||
- "conda-forge" | ||
- "nodefaults" | ||
dependencies: | ||
- "python ~=3.11" | ||
- "numpy ~=1.24" | ||
- "matplotlib ~=3.7" | ||
- "colorspacious ~=1.1" | ||
- "scipy ~=1.10" | ||
- pip: | ||
- "build ~=0.10" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[project] | ||
name = "viscm" | ||
dynamic = ["version"] | ||
description = "A colormap tool" | ||
readme = "README.rst" | ||
authors = [ | ||
{name = "Nathaniel J. Smith", email = "[email protected]"}, | ||
{name = "Stefan van der Walt", email = "[email protected]"}, | ||
] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
] | ||
|
||
requires-python = "~=3.7" | ||
dependencies = [ | ||
"numpy", | ||
"matplotlib", | ||
"colorspacious", | ||
"scipy", | ||
] | ||
|
||
[project.urls] | ||
repository = "https://github.com/matplotlib/viscm" | ||
# documentation = "https://viscm.readthedocs.io" | ||
|
||
[project.license] | ||
text = "MIT" | ||
files = ["LICENSE"] | ||
|
||
[project.scripts] | ||
viscm = "viscm.cli:cli" | ||
|
||
|
||
[build-system] | ||
requires = ["setuptools", "setuptools_scm"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
zip-safe = false | ||
packages = {find = {}} | ||
package-data = {viscm = ["examples/*"]} | ||
|
||
|
||
# [tool.black] | ||
mfisher87 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,3 @@ | ||
from setuptools import setup, find_packages | ||
import sys | ||
import os.path | ||
from setuptools import setup | ||
|
||
import numpy as np | ||
|
||
# Must be one line or PyPI will cut it off | ||
DESC = ("A colormap tool") | ||
|
||
LONG_DESC = open("README.rst").read() | ||
|
||
setup( | ||
name="viscm", | ||
version="0.9", | ||
description=DESC, | ||
long_description=LONG_DESC, | ||
author="Nathaniel J. Smith, Stefan van der Walt", | ||
author_email="[email protected], [email protected]", | ||
url="https://github.com/bids/viscm", | ||
license="MIT", | ||
classifiers = | ||
[ "Development Status :: 3 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 2", | ||
"Programming Language :: Python :: 3", | ||
], | ||
packages=find_packages(), | ||
install_requires=["numpy", "matplotlib", "colorspacious", "scipy"], | ||
package_data={'viscm': ['examples/*']}, | ||
) | ||
setup(use_scm_version=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# This file is part of pycam02ucs | ||
# Copyright (C) 2014 Nathaniel Smith <[email protected]> | ||
# See file LICENSE.txt for license information. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,5 @@ | |
# Copyright (C) 2015 Stefan van der Walt <[email protected]> | ||
# See file LICENSE.txt for license information. | ||
|
||
import sys | ||
from .gui import main | ||
main(sys.argv[1:]) | ||
from .cli import cli | ||
cli() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
from viscm import gui | ||
|
||
|
||
def cli(): | ||
mfisher87 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import argparse | ||
argv = sys.argv[1:] | ||
|
||
parser = argparse.ArgumentParser( | ||
prog="python -m viscm", | ||
description="A colormap tool.", | ||
) | ||
parser.add_argument("action", metavar="ACTION", | ||
help="'edit' or 'view' (or 'show', same as 'view')", | ||
choices=["edit", "view", "show"], | ||
default="edit", | ||
nargs="?") | ||
parser.add_argument("colormap", metavar="COLORMAP", | ||
default=None, | ||
help="A .json file saved from the editor, a .py file containing" | ||
" a global named `test_cm`, or the name of a matplotlib" | ||
" builtin colormap", | ||
nargs="?") | ||
parser.add_argument("--uniform-space", metavar="SPACE", | ||
default="CAM02-UCS", | ||
dest="uniform_space", | ||
help="The perceptually uniform space to use. Usually " | ||
"you should leave this alone. You can pass 'CIELab' " | ||
"if you're curious how uniform some colormap is in " | ||
"CIELab space. You can pass 'buggy-CAM02-UCS' if " | ||
"you're trying to reproduce the matplotlib colormaps " | ||
"(which turn out to have had a small bug in the " | ||
"assumed sRGB viewing conditions) from their bezier " | ||
"curves.") | ||
parser.add_argument("-t", "--type", type=str, | ||
default="linear", choices=["linear", "diverging", "diverging-continuous"], | ||
help="Choose a colormap type. Supported options are 'linear', 'diverging', and 'diverging-continuous") | ||
parser.add_argument("-m", "--method", type=str, | ||
default="CatmulClark", choices=["Bezier", "CatmulClark"], | ||
help="Choose a spline construction method. 'CatmulClark' is the default, but you may choose the legacy option 'Bezier'") | ||
parser.add_argument("--save", metavar="FILE", | ||
default=None, | ||
help="Immediately save visualization to a file " | ||
"(view-mode only).") | ||
parser.add_argument("--quit", default=False, action="store_true", | ||
help="Quit immediately after starting " | ||
"(useful with --save).") | ||
args = parser.parse_args(argv) | ||
|
||
cm = gui.Colormap(args.type, args.method, args.uniform_space) | ||
app = gui.QtWidgets.QApplication([]) | ||
|
||
if args.colormap: | ||
cm.load(args.colormap) | ||
|
||
|
||
# Easter egg! I keep typing 'show' instead of 'view' so accept both | ||
if args.action in ("view", "show"): | ||
if cm is None: | ||
sys.exit("Please specify a colormap") | ||
fig = plt.figure() | ||
figureCanvas = gui.FigureCanvas(fig) | ||
v = gui.viscm(cm.cmap, name=cm.name, figure=fig, uniform_space=cm.uniform_space) | ||
mainwindow = gui.ViewerWindow(figureCanvas, v, cm.name) | ||
if args.save is not None: | ||
v.figure.set_size_inches(20, 12) | ||
v.figure.savefig(args.save) | ||
elif args.action == "edit": | ||
if not cm.can_edit: | ||
sys.exit("Sorry, I don't know how to edit the specified colormap") | ||
# Hold a reference so it doesn't get GC'ed | ||
fig = plt.figure() | ||
figureCanvas = gui.FigureCanvas(fig) | ||
v = gui.viscm_editor(figure=fig, uniform_space=cm.uniform_space, cmtype=cm.cmtype, method=cm.method, **cm.params) | ||
mainwindow = gui.EditorWindow(figureCanvas, v) | ||
else: | ||
raise RuntimeError("can't happen") | ||
|
||
if args.quit: | ||
sys.exit() | ||
|
||
figureCanvas.setSizePolicy(gui.QtWidgets.QSizePolicy.Expanding, | ||
gui.QtWidgets.QSizePolicy.Expanding) | ||
figureCanvas.updateGeometry() | ||
|
||
mainwindow.resize(800, 600) | ||
mainwindow.show() | ||
|
||
# PyQt messes up signal handling by default. Python signal handlers (e.g., | ||
# the default handler for SIGINT that raises KeyboardInterrupt) can only | ||
# run when we enter the Python interpreter, which doesn't happen while | ||
# idling in the Qt mainloop. (Unless we register a timer to poll | ||
# explicitly.) So here we unregister Python's default signal handler and | ||
# replace it with... the *operating system's* default signal handler, so | ||
# instead of a KeyboardInterrupt our process just exits. | ||
import signal | ||
signal.signal(signal.SIGINT, signal.SIG_DFL) | ||
|
||
app.exec_() | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
Uh oh!
There was an error while loading. Please reload this page.