Skip to content
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

Allow setting MATPLOTLIBRC by process substitution. #9570

Merged
merged 1 commit into from Jan 16, 2018

Conversation

Projects
None yet
4 participants
@anntzer
Copy link
Contributor

commented Oct 25, 2017

This makes (e.g.)

$ MATPLOTLIBRC=<(echo 'savefig.transparent: true') python foo.py

use savefig.transparent: true as contents of matplotlibrc for the
given process (on POSIX).

This generalizes the MPLBACKEND mechanism to all rcParams (although the
lack of "cascading" rc-files means that the "normal" rc-file is
completely hidden -- but that's a separate issue).

Closes #6884.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
@tacaswell

This comment has been minimized.

Copy link
Member

commented Oct 31, 2017

👍 but needs some documentation

@tacaswell tacaswell added this to the v2.2 milestone Oct 31, 2017

@anntzer

This comment has been minimized.

Copy link
Contributor Author

commented Oct 31, 2017

This basically follows normal rules of shell process substitution (on shells that support them). I can add a whatsnew saying that that's supported but I don't really want to explain what process substitution is...

Also, note that this very technically breaks code that assumes that you can read from matplotlib_fname() again (because it's a pipe). In particular, this means that matplotlib.rc_params() will return the internal defaults rather than the one loaded from matplotlib_fname(). In practice this is not a problem because you can just use rc_file_defaults() (which caches a copy of the dict) instead.

Probably all these rc_* functions should also be cleaned up too...

@anntzer anntzer force-pushed the anntzer:mplrc branch from 9d6259f to dff2db6 Dec 3, 2017

Allow setting MATPLOTLIBRC by process substitution.
This makes (e.g.)
```
$ MATPLOTLIBRC=<(echo 'savefig.transparent: true') python foo.py
```
use `savefig.transparent: true` as contents of matplotlibrc for the
given process (on POSIX).

This generalizes the MPLBACKEND mechanism to all rcParams (although the
lack of "cascading" rc-files means that the "normal" rc-file is
completely hidden).

@anntzer anntzer force-pushed the anntzer:mplrc branch from dff2db6 to 6447ff6 Jan 15, 2018

@anntzer

This comment has been minimized.

Copy link
Contributor Author

commented Jan 15, 2018

Added some (minimal) docs (as stated above it seems pointless to explain what process substitution is in the mpl docs).
Not release critical by any means but seems trivial enough to keep for 2.2...

@efiring

This comment has been minimized.

Copy link
Member

commented Jan 16, 2018

Looks harmless.

@efiring efiring merged commit b67098b into matplotlib:master Jan 16, 2018

4 of 5 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
ci/circleci: docs-python27 Your tests passed on CircleCI!
Details
ci/circleci: docs-python35 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
lgtm analysis: Python No alert changes
Details

@anntzer anntzer deleted the anntzer:mplrc branch Jan 16, 2018

@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.