@@ -207,13 +207,47 @@ for :ref:`building pandas with GitPod <contributing-gitpod>`.
207
207
Step 3: build and install pandas
208
208
--------------------------------
209
209
210
- You can now run::
210
+ There are currently two supported ways of building pandas, pip/meson and setuptools(setup.py).
211
+ Historically, pandas has only supported using setuptools to build pandas. However, this method
212
+ requires a lot of convoluted code in setup.py and also has many issues in compiling pandas in parallel
213
+ due to limitations in setuptools.
214
+
215
+ The newer build system, invokes the meson backend through pip (via a `PEP 517 <https://peps.python.org/pep-0517/ >`_ build).
216
+ It automatically uses all available cores on your CPU, and also avoids the need for manual rebuilds by
217
+ rebuilding automatically whenever pandas is imported(with an editable install).
218
+
219
+ For these reasons, you should compile pandas with meson.
220
+ Because the meson build system is newer, you may find bugs/minor issues as it matures. You can report these bugs
221
+ `here <https://github.com/pandas-dev/pandas/issues/49683 >`_.
222
+
223
+ To compile pandas with meson, run::
211
224
212
225
# Build and install pandas
213
- # The number after -j is the number of compiling jobs run in parallel
214
- # Change it according to your machine's hardware spec
215
- python setup.py build_ext -j 4
216
- python -m pip install -e . --no-build-isolation --no-use-pep517
226
+ python -m pip install -ve . --no-build-isolation
227
+
228
+ ** Build options **
229
+
230
+ It is possible to pass options from the pip frontend to the meson backend if you would like to configure your
231
+ install. Occasionally, you'll want to use this to adjust the build directory, and/or toggle debug/optimization levels.
232
+
233
+ You can pass a build directory to pandas by appending ``--config-settings builddir="your builddir here" `` to your pip command.
234
+ This option allows you to configure where meson stores your built C extensions, and allows for fast rebuilds.
235
+
236
+ Sometimes, it might be useful to compile pandas with debugging symbols, when debugging C extensions.
237
+ Appending ``--config-settings setup-args="-Ddebug=true" `` will do the trick.
238
+
239
+ With pip, it is possible to chain together multiple config settings (for example specifying both a build directory
240
+ and building with debug symbols would look like
241
+ ``--config-settings builddir="your builddir here" --config-settings=setup-args="-Dbuildtype=debug" ``.
242
+
243
+ **Compiling pandas with setup.py **
244
+
245
+ .. note ::
246
+ This method of compiling pandas will be deprecated and removed very soon, as the meson backend matures.
247
+
248
+ To compile pandas with setuptools, run::
249
+
250
+ python setup.py develop
217
251
218
252
.. note ::
219
253
You will need to repeat this step each time the C extensions change, for example
@@ -226,5 +260,22 @@ At this point you should be able to import pandas from your locally built versio
226
260
>>> print(pandas.__version__) # note: the exact output may differ
227
261
2.0.0.dev0+880.g2b9e661fbb.dirty
228
262
229
- This will create the new environment, and not touch any of your existing environments,
230
- nor any existing Python installation.
263
+ When building pandas with meson, importing pandas will automatically trigger a rebuild, even when C/Cython files are modified.
264
+ By default, no output will be produced by this rebuild (the import will just take longer). If you would like to see meson's
265
+ output when importing pandas, you can set the environment variable ``MESONPY_EDTIABLE_VERBOSE ``. For example, this would be::
266
+
267
+ # On Linux/macOS
268
+ MESONPY_EDITABLE_VERBOSE=1 python
269
+
270
+ # Windows
271
+ set MESONPY_EDITABLE_VERBOSE=1 # Only need to set this once per session
272
+ python
273
+
274
+ If you would like to see this verbose output every time, you can set the ``editable-verbose `` config setting to ``true `` like so::
275
+
276
+ python -m pip install -ve . --config-settings editable-verbose=true
277
+
278
+ .. tip ::
279
+ If you ever find yourself wondering whether setuptools or meson was used to build your pandas,
280
+ you can check the value of ``pandas._built_with_meson ``, which will be true if meson was used
281
+ to compile pandas.
0 commit comments