11Build from source
22=================
33
4+ .. note ::
5+ The instructions here are for building ``python-flint `` from source. For
6+ most users it is recommended to install prebuilt binaries from ``PyPI `` or
7+ ``conda-forge `` instead. The instructions here are only needed if a binary
8+ is not available for the platform. See :ref: `install_pip_conda `.
9+
10+
11+ Simple build instructions
12+ -------------------------
13+
14+ The simple explanation of how to build ``python-flint `` from source is that
15+ there are two steps:
16+
17+ - Install ``FLINT >= 3.0 `` (see :ref: `install_dependencies ` below).
18+ - Run ``pip install --no-binary python-flint python-flint ``.
19+
20+ For example on Ubuntu 24.04 (but not older versions of Ubuntu) and when installing
21+ ``python-flint >= 0.7.0 `` these two steps are::
22+
23+ sudo apt-get install libflint-dev
24+ pip install --no-binary python-flint python-flint
25+
26+ The first command installs ``FLINT 3.0.1 `` system-wide. With the second command
27+ ``pip `` will download the source code for the latest release of
28+ ``python-flint `` from PyPI, build it and install it into the active Python
29+ environment. When building, ``pip `` will create a temporary isolated build
30+ environment and will install the Python build dependencies (``Cython ``,
31+ ``meson ``, ...) into this environment so it is not necessary to install them
32+ manually before running ``pip install ``.
33+
34+ If you have the source code locally then you can build and install with::
35+
36+ pip install path/to/python-flint-directory-or-archive
37+
38+ After installing from source it is recommended to run the tests to check that
39+ everything is working correctly as described in :ref: `test_installation `.
40+
41+ The remainder of this page provides more detailed instructions for building
42+ ``python-flint `` from source including how to install the dependencies, how to
43+ build older versions of ``python-flint `` (``< 0.7.0 ``), how to install from
44+ git, and other more advanced topics.
45+
46+ .. note ::
47+ If you have more than one Python environment in your system then you need to
48+ ensure that you are installing ``python-flint `` into the correct one. This
49+ may require using the full path to ``pip `` or something like ``python3 -m
50+ pip `` or you may need to activate the environment first.
51+
52+
453.. _supported_versions :
554
655Compatibility and supported versions
@@ -36,33 +85,40 @@ Compatible versions (note that 0.7.0 is not yet released):
3685 * - 0.6.0
3786 - 1st Feb 2024
3887 - 3.9-3.12
39- - 3.0 only
40- - 3.0 only
88+ - 3.0
89+ - 3.0
4190 * - 0.5.0
4291 - 22nd Oct 2023
4392 - 3.9-3.12
44- - 3.0 only
45- - 3.0 only
46-
47- If installing binaries from PyPI or conda-forge then the Python (CPython)
48- version is the only column in this table that matters. The minimum and maximum
49- versions of Python represent the versions that are tested in CI and for which
50- binaries are provided on PyPI. It is likely that ``python-flint `` will work
51- with other versions of Python (particularly older Python versions) but this is
52- not tested and requires building from source. It is possible that
53- ``conda-forge `` may provide binaries for other versions of Python.
93+ - 3.0
94+ - 3.0
95+ * - 0.4.0
96+ - 8th Aug 2023
97+ - 3.9-3.11
98+ - ``2.9.0 `` (``Arb 2.23.0 ``)
99+ - 3.0
100+ * - 0.3.0
101+ - 7th Dec 2018
102+ - older Python versions
103+ - ``< 3.0 ``
104+ - ``< 3.0 ``
105+
106+ The minimum and maximum versions of Python represent the versions that are
107+ tested in CI and for which binaries are provided on PyPI. It is likely that
108+ ``python-flint `` will work with other versions of Python (particularly older
109+ Python versions) but this is not tested. It is possible that ``conda-forge ``
110+ may provide binaries for other versions of Python.
54111
55112The minimum versions of Cython and FLINT are needed because it is known that
56113python-flint will not even build with older versions of these libraries. The
57114maximum versions of all dependencies are speculative and are based on the
58115versions that are known to work at the time of release. It is possible that
59- newer versions of Cython and FLINT will work but from ``python-flint 0.4.0 ``
60- through to the time of writing (``python-flint 0.7.0 ``) minor releases of
61- Cython, FLINT, or CPython have frequently required changes to the
62- ``python-flint `` source code to be able to build at all. In particular the
63- following releases of Cython, FLINT and CPython have had changes that would
64- prevent building all versions of ``python-flint `` existing at the time of the
65- release:
116+ newer versions of Cython and FLINT will work but unlikely. During the year
117+ following the release of ``python-flint 0.4.0 `` every non-patch release of
118+ Cython, FLINT, or CPython has required changes to the ``python-flint `` source
119+ code to be able to build at all. In particular the following releases of
120+ Cython, FLINT and CPython had changes that would prevent building all versions
121+ of ``python-flint `` existing at the time:
66122
67123- Flint 3.0 (Arb and Flint merged, lots of changes)
68124- Flint 3.1 (Function signature for ``fmpz_mod_mat `` changed)
@@ -71,12 +127,10 @@ release:
71127- Cython 3.1 (Removal of ``PyInt_* `` functions)
72128- CPython 3.12 (Removal of distutils)
73129
74- In fact out of python-flint's three core dependencies (CPython, Cython, FLINT),
75- the only minor release that has not required changes to the python-flint source
76- code during this time has been CPython ``3.13 ``. It is expected then that any
77- future untested ``3.x `` version of Cython, FLINT, or CPython will not be
78- compatible with past versions of ``python-flint `` which is why the table above
79- only lists the versions that are known to work.
130+ It is expected then that any future untested ``3.x `` version of Cython, FLINT,
131+ or CPython will not be compatible with past versions of ``python-flint `` which
132+ is why the table above lists the versions that were known to work at the time
133+ of release.
80134
81135As of python-flint 0.7.0, CPython ``3.13t `` free-threaded builds are tested in
82136CI but wheels are not provided on PyPI. There are no known issues related to
@@ -90,21 +144,19 @@ implementations may work but are not tested.
90144
91145.. _build_from_source :
92146
93- Building from source
94- --------------------
147+ Building python-flint from source
148+ ---------------------------------
95149
96150.. note ::
97- Building from source is not the recommended way for most users to install
98- `` python-flint ``. For most users it is recommended to use the binaries from
99- ``PyPI `` or `` conda-forge `` except in cases where a binary is not available
100- for the platform. See :ref: `install_pip_conda `.
151+ The instructions here are for building `` python-flint `` from source. For
152+ most users it is recommended to install prebuilt binaries from `` PyPI `` or
153+ ``conda-forge `` instead. The instructions here are only needed if a binary
154+ is not available for the platform. See :ref: `install_pip_conda `.
101155
102- .. note ::
103- The instructions here assume that you want to build and install ``python-flint ``
104- on a platform for which a binary is not available on PyPI or conda-forge. If
105- you are interested in contributing to ``python-flint `` then see the
156+ Also if you are working on ``python-flint `` itself then it is not
157+ recommended to install the package
106158
107- - XXX: Add link to separate development page...
159+ - XXX: Add link to separate development page...
108160
109161The source code for ``python-flint `` is available on `GitHub
110162<https://github.com/flintlib/python-flint/tags> `_ and source distributions can
@@ -117,20 +169,17 @@ from PyPI, then build and install it into the active Python environment::
117169
118170 pip install python-flint
119171
120- This will download, build and install the latest release of ``python-flint ``
121- from PyPI.
172+ This will try to install a binary first but will otherwise download, build and
173+ install the latest release of ``python-flint `` from PyPI. If you definitely
174+ want to build from source then you can use the ``--no-binary `` option::
122175
123- .. note ::
124- If you have more than one Python environment on your system then you need to
125- ensure that you are installing ``python-flint `` into the correct one. This
126- may require using the full path to ``pip `` or something like ``python3 -m
127- pip `` or by activating the correct environment first.
176+ pip install --no-binary python-flint python-flint
128177
129- To install a specific version of ``python-flint `` from PyPI use::
178+ To install a specific version of ``python-flint `` from PyPI use e.g. ::
130179
131- pip install python-flint==0.6.0
180+ pip install python-flint==0.7.0a4
132181
133- To download and install the latest ``python-flint `` from git master you can
182+ To build and install the latest ``python-flint `` from git master you can
134183use::
135184
136185 pip install git+https://github.com/flintlib/python-flint.git@master
@@ -148,33 +197,23 @@ Alternatively if you would like to build a wheel you can use
148197Note that wheels built in this way will not include the dependencies (unlike
149198those distributed on PyPI) and cannot generally be installed on other systems.
150199
151- For ``python-flint < 0.6.0 `` the source distribution did not include
152- ``pyproject.toml `` and did not list the build requirements. Also for
153- ``python-flint < 0.7.0 `` there were no version constraints on the build
154- requirements. If you are building an older version of ``python-flint `` then you
155- may need to install the build requirements manually and disable build isolation
156- with ``--no-build-isolation ``::
157-
158- pip install Cython==3.0 setuptools numpy
159- pip install --no-build-isolation .
160-
161- To build without build isolation with ``python-flint >= 0.7.0 `` the needed
162- dependencies are different::
163-
164- pip install Cython==3.0 meson meson-python ninja
165- pip install --no-build-isolation .
166-
167200Since ``python-flint 0.7.0 `` the build system is ``meson `` and the build
168201requirements and version constraints are listed in ``pyproject.toml ``. When
169202using build isolation the build requirements are installed in a temporary
170203virtual environment and so it should not be necessary to install them in the
171204active Python environment before running ``pip install ``.
172205
173- The ``meson `` build system will also detect the version of ``FLINT `` installed
174- in the system and will fail if it is not a version that was known to be
175- compatible at time of the release of ``python-flint ``. To build against new,
176- untested versions of ``FLINT `` you can pass the ``-Dflint_version_check=false ``
177- option to the ``meson `` build system::
206+ To build without build isolation with ``python-flint >= 0.7.0 `` the
207+ dependencies should first be installed in the active Python environment::
208+
209+ pip install Cython==3.0 meson meson-python ninja
210+ pip install --no-build-isolation .
211+
212+ The ``meson `` build system will detect the versions of ``FLINT `` and Cython
213+ installed in the system and will fail if they are not versions that were known
214+ to be compatible at the time of the release of ``python-flint ``. To build
215+ against new, untested versions of ``FLINT `` or Cython you can pass the
216+ ``-Dflint_version_check=false `` option to the ``meson `` build system::
178217
179218 pip install --config-settings=setup-args="-Dflint_version_check=false" .
180219
@@ -184,6 +223,27 @@ example if you want to build ``python-flint`` against the latest git version of
184223and Cython that are supported by each version of ``python-flint ``.
185224
186225
226+ Building older versions of python-flint
227+ ---------------------------------------
228+
229+ For ``python-flint < 0.6.0 `` the source distribution did not include
230+ ``pyproject.toml `` and did not list the build requirements. Also for
231+ ``python-flint < 0.7.0 `` the build requirements were different and there were
232+ no version constraints listed on the dependencies. An list of the build
233+ requirements for older versions of ``python-flint `` is given above in
234+ :ref: `supported_versions `.
235+
236+ For ``python-flint < 0.7.0 `` you will need to install the build requirements
237+ manually, pin the version of Cython, and disable build isolation::
238+
239+ pip install Cython==3.0 setuptools numpy
240+ pip install --no-build-isolation .
241+
242+ For ``python-flint < 0.4.0 `` older versions of Cython are needed (``<= 0.29 ``).
243+ If the build fails during the Cython step then it is likely that a different
244+ version of Cython is needed.
245+
246+
187247.. _install_dependencies :
188248
189249Installing the dependencies
@@ -290,9 +350,9 @@ Building on Windows
290350
291351The instructions in :ref: `install_dependencies ` above are for Unix-like systems
292352(e.g. Linux or MacOS). On Windows the dependencies can be built in a similar
293- way using MSYS2 or WSL. It is also possible to build ``python-flint `` and its
294- dependencies using MSVC but we do not currently provide instructions for this.
295- The `conda-forge recipe
353+ way using MSYS2 or under WSL. It is also possible to build ``python-flint `` and
354+ its dependencies using MSVC but we do not currently provide instructions for
355+ this. The `conda-forge recipe
296356<https://github.com/conda-forge/python-flint-feedstock> `_ for ``python-flint ``
297357builds on Windows using MSVC.
298358
@@ -331,7 +391,7 @@ Using ``FLINT`` from a non-standard location
331391 For most users it is recommended to use the binaries from ``PyPI `` or
332392 ``conda-forge ``. See :ref: `install_pip_conda `. The instructions here are
333393 also not needed if you have installed ``FLINT `` and its dependencies
334- system-wide.
394+ system-wide (e.g. using a package manager like `` apt-get `` or `` brew ``) .
335395
336396If you have installed ``FLINT `` in a non-standard location then you will need
337397to instruct the ``python-flint `` build system where to find it and ensure that
@@ -353,8 +413,9 @@ location e.g. ``lib64/pkgconfig``. It is also possible to pass the path to the
353413``pkg-config `` files to the ``meson-python `` build backend. For example if
354414building with ``pip ``::
355415
356- pip install --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
357- python-flint
416+ pip install \
417+ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
418+ python-flint
358419
359420Setting the path to the ``pkg-config `` files in this way will allow the
360421``python-flint `` build system to find the ``FLINT `` library at build time. At
@@ -376,9 +437,10 @@ platforms this is done automatically by the ``meson`` build system but on
376437others it needs to be enabled explicitly. This can be done by passing the
377438``-Dadd_flint_rpath=true `` option to the ``meson `` build system::
378439
379- pip install --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
380- --config-settings=setup-args="-Dadd_flint_rpath=true" \
381- python-flint
440+ pip install \
441+ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
442+ --config-settings=setup-args="-Dadd_flint_rpath=true" \
443+ python-flint
382444
383445For versions of ``python-flint `` before ``0.7.0 `` the build system is
384446``setuptools `` (or ``numpy.distutils `` for ``Python < 3.12 ``). In this case
@@ -447,14 +509,14 @@ running ``python`` again or by restarting the Jupyter kernel.
447509If you have installed ``FLINT `` in a non-standard location then you should set
448510the ``pkg-config `` path as described in :ref: `non_standard_location ` above::
449511
450- pip install --no-build-isolation \
451- --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
452- --editable .
512+ pip install
513+ --no-build-isolation \
514+ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \
515+ --editable .
453516
454517To fully remove the editable install you can run::
455518
456519 pip uninstall python-flint
457520
458521and then delete the ``build `` directory that was created in the root of the
459522``python-flint `` git repo.
460-
0 commit comments