Skip to content

Commit 2f47d51

Browse files
committed
Remove support for -dbackend argv.
Support for setting the backend with `-dbackend` was deprecated in 1.5.
1 parent 7220afd commit 2f47d51

File tree

4 files changed

+10
-46
lines changed

4 files changed

+10
-46
lines changed

doc/devel/contributing.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,24 +415,19 @@ Developing a new backend
415415

416416
If you are working on a custom backend, the *backend* setting in
417417
:file:`matplotlibrc` (:ref:`customizing-matplotlib`) supports an
418-
external backend via the ``module`` directive. if
418+
external backend via the ``module`` directive. If
419419
:file:`my_backend.py` is a Matplotlib backend in your
420420
:envvar:`PYTHONPATH`, you can set it on one of several ways
421421

422422
* in :file:`matplotlibrc`::
423423

424424
backend : module://my_backend
425425

426-
427426
* with the :envvar:`MPLBACKEND` environment variable::
428427

429428
> export MPLBACKEND="module://my_backend"
430429
> python simple_plot.py
431430

432-
* from the command shell with the `-d` flag::
433-
434-
> python simple_plot.py -dmodule://my_backend
435-
436431
* with the use directive in your script::
437432

438433
import matplotlib

doc/faq/environment_variables_faq.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ Environment Variables
3333

3434
.. envvar:: MPLBACKEND
3535

36-
This optional variable can be set to choose the matplotlib backend. Using the
37-
`-d` command line parameter or the :func:`~matplotlib.use` function will
38-
override this value. See :ref:`what-is-a-backend`.
36+
This optional variable can be set to choose the matplotlib backend. See
37+
:ref:`what-is-a-backend`.
3938

4039
.. _setting-linux-osx-environment-variables:
4140

doc/faq/usage_faq.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,6 @@ the method mentioned last in the following list will be used, e.g. calling
326326
globally, e.g. in your ``.bashrc`` or ``.profile``, is discouraged as it
327327
might lead to counter-intuitive behavior.
328328

329-
#. To set the backend for a single script, you can alternatively use the `-d`
330-
command line argument::
331-
332-
> python script.py -dbackend
333-
334-
This method is **deprecated** as the `-d` argument might conflict with
335-
scripts which parse command line arguments (see issue
336-
`#1986 <https://github.com/matplotlib/matplotlib/issues/1986>`_). You
337-
should use :envvar:`MPLBACKEND` instead.
338-
339329
#. If your script depends on a specific backend you can use the
340330
:func:`~matplotlib.use` function::
341331

lib/matplotlib/__init__.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ def rc_file_defaults():
13381338
"""
13391339
rcParams.update(rcParamsOrig)
13401340

1341+
13411342
_use_error_msg = """
13421343
This call to matplotlib.use() has no effect because the backend has already
13431344
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
@@ -1408,6 +1409,12 @@ def use(arg, warn=True, force=False):
14081409
reload(sys.modules['matplotlib.backends'])
14091410

14101411

1412+
try:
1413+
use(os.environ['MPLBACKEND'])
1414+
except KeyError:
1415+
pass
1416+
1417+
14111418
def get_backend():
14121419
"""Return the name of the current backend."""
14131420
return rcParams['backend']
@@ -1435,33 +1442,6 @@ def tk_window_focus():
14351442
return False
14361443
return rcParams['tk.window_focus']
14371444

1438-
# Now allow command line to override
1439-
1440-
# Allow command line access to the backend with -d (MATLAB compatible
1441-
# flag)
1442-
1443-
for s in sys.argv[1:]:
1444-
# cast to str because we are using unicode_literals,
1445-
# and argv is always str
1446-
if s.startswith(str('-d')) and len(s) > 2: # look for a -d flag
1447-
try:
1448-
use(s[2:])
1449-
warnings.warn("Using the -d command line argument to select a "
1450-
"matplotlib backend is deprecated. Please use the "
1451-
"MPLBACKEND environment variable instead.",
1452-
mplDeprecation)
1453-
break
1454-
except (KeyError, ValueError):
1455-
pass
1456-
# we don't want to assume all -d flags are backends, e.g., -debug
1457-
else:
1458-
# no backend selected from the command line, so we check the environment
1459-
# variable MPLBACKEND
1460-
try:
1461-
use(os.environ['MPLBACKEND'])
1462-
except KeyError:
1463-
pass
1464-
14651445

14661446
# Jupyter extension paths
14671447
def _jupyter_nbextension_paths():

0 commit comments

Comments
 (0)