Skip to content

Commit 02dd113

Browse files
committed
Be more opinionated for setting up a dev env.
Tell users to always use a venv and always install in editable mode. If they know better, great. But let's not offer too many confusing options to newcomers.
1 parent 03b255d commit 02dd113

File tree

2 files changed

+22
-48
lines changed

2 files changed

+22
-48
lines changed

INSTALL.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ FreeType and Qhull
159159
Matplotlib depends on `FreeType <https://www.freetype.org/>`_ (>= 2.3), a
160160
font rendering library, and on `Qhull <http://www.qhull.org/>`_ (>= 2015.2),
161161
a library for computing triangulations. By default, Matplotlib downloads and
162-
builds its own copy of FreeType, and uses its own copy of Qhull.
162+
builds its own copy of FreeType (this is necessary to run the test suite,
163+
because different versions of FreeType rasterize characters differently), and
164+
uses its own copy of Qhull.
163165

164166
To force Matplotlib to use a copy of FreeType or Qhull already installed in
165167
your system, create a :file:`setup.cfg` file with the following contents:

doc/devel/contributing.rst

+19-47
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,8 @@ Thank you for your help in keeping bug reports complete, targeted and descriptiv
5353
Retrieving and installing the latest version of the code
5454
========================================================
5555

56-
When developing Matplotlib, sources must be downloaded, built, and installed into
57-
a local environment on your machine.
58-
59-
Follow the instructions detailed :ref:`here <install_from_source>` to set up your
60-
environment to build Matplotlib from source.
61-
62-
.. warning::
63-
64-
When working on Matplotlib sources, having multiple versions installed by
65-
different methods into the same environment may not always work as expected.
66-
67-
To work on Matplotlib sources, it is strongly recommended to set up an alternative
68-
development environment, using the something like `virtual environments in python
69-
<http://docs.python-guide.org/en/latest/dev/virtualenvs/>`_, or a
70-
`conda environment <https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`_.
71-
72-
If you choose to use an already existing environment, and not a clean virtual or
73-
conda environment, uninstall the current version of Matplotlib in that environment
74-
using the same method used to install it.
75-
76-
If working on Matplotlib documentation only, the above steps are *not* absolutely
77-
necessary.
56+
When developing Matplotlib, sources must be downloaded, built, and installed
57+
into a local environment on your machine.
7858

7959
We use `Git <https://git-scm.com/>`_ for version control and
8060
`GitHub <https://github.com/>`_ for hosting our main repository.
@@ -88,19 +68,24 @@ and navigate to the :file:`matplotlib` directory. If you have the proper privile
8868
you can use ``git@`` instead of ``https://``, which works through the ssh protocol
8969
and might be easier to use if you are using 2-factor authentication.
9070

71+
Installing Matplotlib in developer mode
72+
---------------------------------------
73+
74+
It is strongly recommended to set up a clean `virtual environment`_. Do not
75+
use on a preexisting environment!
9176

92-
Building Matplotlib for image comparison tests
93-
----------------------------------------------
77+
A new environment can be set up with ::
9478

95-
Matplotlib's test suite makes heavy use of image comparison tests, meaning
96-
the result of a plot is compared against a known good result. Unfortunately,
97-
different versions of FreeType produce differently formed characters, causing
98-
these image comparisons to fail. To make them reproducible, Matplotlib is, by
99-
default, built with a special local copy of FreeType.
79+
python3 -mvenv /path/to/devel/env
10080

81+
and activated with one of the following::
10182

102-
Installing Matplotlib in developer mode
103-
---------------------------------------
83+
source /path/to/devel/env/bin/activate # Linux/macOS
84+
/path/to/devel/env/Scripts/activate.bat # Windows cmd.exe
85+
/path/to/devel/env/Scripts/Activate.ps1 # Windows PowerShell
86+
87+
Whenever you plan to work on Matplotlib, remember to activate the development
88+
environment in your shell!
10489

10590
To install Matplotlib (and compile the C-extensions) run the following
10691
command from the top-level directory ::
@@ -115,28 +100,15 @@ reflected the next time you import the library. If you change the
115100
C-extension source (which might happen if you change branches) you
116101
will need to run ::
117102

118-
python setup.py build
103+
python setup.py build_ext --inplace
119104

120105
or re-run ``python -mpip install -ve .``.
121106

122-
Alternatively, if you do ::
123-
124-
python -mpip install -v .
125-
126-
all of the files will be copied to the installation directory however,
127-
you will have to rerun this command every time the source is changed.
128-
Additionally you will need to copy :file:`setup.cfg.template` to
129-
:file:`setup.cfg` and edit it to contain ::
130-
131-
[test]
132-
local_freetype = True
133-
tests = True
134-
135-
In either case you can then run the tests to check your work
136-
environment is set up properly::
107+
You can then run the tests to check your work environment is set up properly::
137108

138109
pytest
139110

111+
.. _virtual environment: https://docs.python.org/3/library/venv.html
140112
.. _pytest: http://doc.pytest.org/en/latest/
141113
.. _pep8: https://pep8.readthedocs.io/en/latest/
142114
.. _Ghostscript: https://www.ghostscript.com/

0 commit comments

Comments
 (0)