### Meson Setup Command Example Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Demonstrates the initial Meson setup command with various options and the output when the directory is already configured. It also provides guidance on re-configuring or wiping the build directory. ```console $ meson setup build --pkg-config-path=.local/lib/pkgconfig -Dadd_flint_rpath=true -Dbuildtype=debug Directory already configured. Just run your build command (e.g. ninja) and Meson will regenerate as necessary. Run "meson setup --reconfigure to force Meson to regenerate. If build failures persist, run "meson setup --wipe" to rebuild from scratch using the same options as passed when configuring the build. ``` -------------------------------- ### Meson Wipe Command Example Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Shows how to use the Meson setup --wipe option to delete all built files while retaining the configuration options for the build directory. ```bash meson setup build -Doption=true ... meson setup build --wipe # deletes all built files, option is still true ``` -------------------------------- ### Meson Setup with Custom Paths Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Configures the Meson build, specifying custom paths for pkg-config files and adding library directories to the runtime search path. This is useful when dependencies are installed in non-standard locations. ```bash meson setup build \ --pkg-config-path=/some/dir/lib/pkgconfig \ -Dadd_flint_rpath=true ``` -------------------------------- ### Install python-flint from Source (Ubuntu) Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs the FLINT library and then builds and installs python-flint from source using pip. This process includes setting up a temporary build environment for dependencies like Cython and meson. ```bash sudo apt-get install libflint-dev pip install --no-binary python-flint python-flint ``` -------------------------------- ### Install python-flint from PyPI Source: https://python-flint.readthedocs.io/en/latest/build Installs the latest release of python-flint from PyPI. It attempts to install a binary first, otherwise it downloads, builds, and installs from source. ```python pip install python-flint ``` -------------------------------- ### Build and install from local source Source: https://python-flint.readthedocs.io/en/latest/build Builds and installs python-flint from the source code that has already been downloaded or checked out from Git. ```python pip install . ``` -------------------------------- ### Meson Configuration and Setup Source: https://python-flint.readthedocs.io/en/latest/workflow Explains the initial setup and subsequent configuration of a project using Meson. It covers how Meson handles configuration options persistently and the commands for managing the build process. ```text meson setup meson configure meson setup --reconfigure meson setup --wipe ``` -------------------------------- ### Build and Install python-flint from Local Source Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs python-flint from a local directory or archive containing the source code. This is an alternative to installing directly from PyPI. ```bash pip install path/to/python-flint-directory-or-archive ``` -------------------------------- ### Python-flint Installation from Wheel Source: https://python-flint.readthedocs.io/en/latest/workflow Describes the step for installing the python-flint package after it has been built into a wheel. ```en 1. The wheel is installed using a Python package installer such as `pip`. ``` -------------------------------- ### Install python-flint from PyPI Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs the latest release of python-flint from PyPI, attempting to use a prebuilt binary first. ```python pip install python-flint ``` -------------------------------- ### Install python-flint from local source Source: https://python-flint.readthedocs.io/en/latest/_sources/build Builds and installs python-flint from the local source code directory after checking it out from Git or downloading it. ```python pip install . ``` -------------------------------- ### Meson Build Commands Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Standard commands to set up, compile, and install a project using Meson. These are analogous to autotools commands like ./configure, make, and make install. ```bash meson setup build meson compile -C build meson install -C build ``` -------------------------------- ### Meson Local Install for Python Projects Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Command to install a Python project into a local directory using Meson, specifically for development purposes. This is used instead of a system-wide installation. ```bash meson install --only-changed -C build --destdir ../build-install ``` -------------------------------- ### Install FLINT from Source using Script Source: https://python-flint.readthedocs.io/en/latest/build Uses a provided script to install FLINT dependencies on Ubuntu, build FLINT from a specified git reference, and install it system-wide. This is an alternative to using package managers. ```bash bin/install_flint_ubuntu.sh v3.0.1 # version 3.0.1 bin/install_flint_ubuntu.sh main # latest git ``` -------------------------------- ### Install specific python-flint version Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs a specific version of python-flint from PyPI. ```python pip install python-flint==0.7.0a4 ``` -------------------------------- ### Install python-flint from Source (Ubuntu) Source: https://python-flint.readthedocs.io/en/latest/build Installs the FLINT development library and then installs python-flint from source using pip. This is for users who need to build from source, typically when prebuilt binaries are not available. ```bash sudo apt-get install libflint-dev pip install --no-binary python-flint python-flint ``` -------------------------------- ### Test python-flint Installation Source: https://python-flint.readthedocs.io/en/latest/install Runs the test suite for python-flint to verify a successful installation. This command executes all unit tests and doctests. ```python python -m flint.test ``` ```python from flint.test.__main__ import main main() ``` -------------------------------- ### Test python-flint installation via command line Source: https://python-flint.readthedocs.io/en/latest/_sources/install Runs the test suite and doctests for python-flint from the command line. ```python python -m flint.test ``` -------------------------------- ### Editable Install of python-flint Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs python-flint in editable mode, allowing for live code changes without reinstallation. Requires build tools and FLINT to be installed first. ```bash git clone https://github.com/flintlib/python-flint.git cd python-flint pip install meson meson-python cython ninja pip install --no-build-isolation --editable . ``` ```bash pip install \ --no-build-isolation \ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \ --editable . ``` ```bash pip uninstall python-flint ``` -------------------------------- ### Install python-flint with pip Source: https://python-flint.readthedocs.io/en/latest/_sources/install Installs the latest release of python-flint from PyPI using pip. ```python pip install python-flint ``` -------------------------------- ### Install python-flint using pip Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs python-flint from source using pip after dependencies are met. ```shell pip install . ``` -------------------------------- ### Install FLINT on Ubuntu Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs the FLINT library (version 3.0.1) on Ubuntu systems using apt-get. ```shell sudo apt-get install libflint-dev ``` -------------------------------- ### Install GMP and MPFR on Ubuntu Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs the GMP and MPFR development libraries on Ubuntu systems using apt-get. ```shell sudo apt-get install libgmp-dev libmpfr-dev ``` -------------------------------- ### Install python-flint from Git master Source: https://python-flint.readthedocs.io/en/latest/_sources/build Builds and installs the latest version of python-flint directly from its Git repository's master branch. ```python pip install git+https://github.com/flintlib/python-flint.git@master ``` -------------------------------- ### Install older python-flint (< 0.7.0) from source Source: https://python-flint.readthedocs.io/en/latest/build Installs older versions of python-flint (prior to 0.7.0) from source, requiring manual installation of build requirements and pinning Cython version. ```python pip install Cython==3.0 setuptools numpy pip install --no-build-isolation . ``` -------------------------------- ### Install python-flint with Custom PKG_CONFIG_PATH Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint using pip, specifying a custom path for `pkg-config` files via `--config-settings`. This ensures the meson build system can find FLINT dependencies during installation. ```bash pip install \ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \ python-flint ``` -------------------------------- ### Install python-FLINT with Custom PKG_CONFIG_PATH using pip Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs python-FLINT using pip, specifying a custom path for pkg-config files via the setup-args configuration setting. This allows the build system to find FLINT dependencies installed in a non-standard location. ```bash pip install \ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \ python-flint ``` -------------------------------- ### Installing Development Dependencies Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Installs necessary development dependencies, such as Cython and Meson, from a requirements file into the activated virtual environment. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Install python-flint from Git master Source: https://python-flint.readthedocs.io/en/latest/build Installs the latest version of python-flint directly from its Git repository's master branch. ```python pip install git+https://github.com/flintlib/python-flint.git@master ``` -------------------------------- ### Install FLINT using python-flint script (Ubuntu) Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs FLINT dependencies and builds FLINT from source using a provided script in the python-flint repository. Supports specific versions or the latest git commit. ```shell bin/install_flint_ubuntu.sh v3.0.1 # version 3.0.1 ``` ```shell bin/install_flint_ubuntu.sh main # latest git ``` -------------------------------- ### Meson Install for Local Python Builds Source: https://python-flint.readthedocs.io/en/latest/workflow Command to install a Python project's build artifacts into a local directory for development purposes. ```bash meson install --only-changed -C build --destdir ../build-install ``` -------------------------------- ### Git Repository Setup Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Commands to clone the Python Flint repository and set up the upstream remote for future updates. ```bash git clone git@github.com:your-username/python-flint.git cd python-flint git remote add upstream git@github.com:flintlib/python-flint.git ``` -------------------------------- ### Install dependencies and build without isolation (>=0.7.0) Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs necessary build dependencies (Cython, meson, ninja) and then builds python-flint from source without build isolation. ```python pip install Cython==3.0 meson meson-python ninja pip install --no-build-isolation . ``` -------------------------------- ### Install with meson build system (>= 0.7.0) Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint (version 0.7.0 and later) using the meson build system. Dependencies are typically handled by build isolation. ```python pip install Cython==3.0 meson meson-python ninja pip install --no-build-isolation . ``` -------------------------------- ### Test python-flint installation via command line (quiet) Source: https://python-flint.readthedocs.io/en/latest/_sources/install Runs the test suite and doctests for python-flint from the command line in quiet mode. ```python python -m flint.test --quiet ``` -------------------------------- ### Install build requirements for older versions (<0.7.0) Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs build requirements like Cython and setuptools for python-flint versions prior to 0.7.0, then builds without isolation. ```python pip install Cython==3.0 setuptools numpy pip install --no-build-isolation . ``` -------------------------------- ### Build FLINT from Source Source: https://python-flint.readthedocs.io/en/latest/build Builds FLINT from source using the standard configure, make, and make install process. This is used when FLINT cannot be installed via a package manager and the provided script is not used. ```bash ./configure make make install ``` -------------------------------- ### Get Matrix Rank Source: https://python-flint.readthedocs.io/en/latest/fmpz_mat Returns the rank of the matrix. Includes examples showing rank calculation and how it changes after modification. ```Python >>> A = fmpz_mat(3, 3, range(9)) >>> A.rank() 2 >>> A[2,2] = 10 >>> A.rank() 3 ``` -------------------------------- ### Recommended Build Procedure Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Highlights the recommended approach for building the project, which involves an initial Meson setup followed by using 'spin build' for subsequent tasks. ```bash meson setup build -Dflint_version_check=false spin build ``` -------------------------------- ### Python-Flint Build Process Overview Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Explains the multi-step process of building the python-flint library, from compiling Cython code to creating a distributable wheel. It also touches upon the steps for installation and distribution on PyPI. ```APIDOC Python-Flint Build Steps: 1. Compile Cython code to C code using 'cython'. 2. Compile C code to Python extension modules (shared libraries) using a C compiler, linking against FLINT and other dependencies. 3. Assemble extension modules and Python files into a Python package directory. 4. Bundle the Python package directory into a wheel (zip file). For installation: 5. Install the wheel using a Python package installer (e.g., 'pip'). For PyPI distribution: 5. Bundle all dependencies (e.g., FLINT library) into the wheel. 6. Upload the wheel to 'PyPI'. 7. Users install the wheel from PyPI (e.g., 'pip install python-flint'). ``` -------------------------------- ### Union of Balls Source: https://python-flint.readthedocs.io/en/latest/arb Returns a new arbitrary-precision ball that contains the union of two input balls. The example shows how to get the lower and upper bounds of the resulting union. ```Python x = arb(3).union(5) print(x.lower()) print(x.upper()) ``` -------------------------------- ### Multiple Build Directories with Meson Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Illustrates how to create and manage multiple build directories with different configurations using 'meson setup'. ```bash meson setup build-debug -Dbuildtype=debug meson setup build-release -Dbuildtype=release meson compile -C build-debug ``` -------------------------------- ### Radius (Error Bound) Source: https://python-flint.readthedocs.io/en/latest/acb Returns an upper bound for the radius (magnitude of error) of a complex number `self` as an `arb` (arb-real) object. The example shows how to get and format the radius. ```Python print(acb("1 +/- 0.3", "2 +/- 0.4").rad().str(5, radius=False)) ``` -------------------------------- ### Install python-flint Dependencies on Windows (MSYS2) Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs dependencies and builds GMP, MPFR, and FLINT on Windows using MSYS2 and the MinGW64 toolchain, as used in the python-flint CI build process. ```shell bin/cibw_before_all_windows.sh ``` -------------------------------- ### Install GMP and MPFR on Ubuntu Source: https://python-flint.readthedocs.io/en/latest/build Installs the GMP and MPFR development libraries on Ubuntu using apt-get. These are prerequisites for building FLINT from source if it's not available via a package manager. ```bash sudo apt-get install libgmp-dev libmpfr-dev ``` -------------------------------- ### Install python-flint with RPATH Enabled Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint using pip, specifying both a custom `pkg-config` path and enabling RPATH support during the meson build. RPATH embeds library search paths into the executable, simplifying runtime dependency resolution on Unix-like systems. ```bash pip install \ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \ --config-settings=setup-args="-Dadd_flint_rpath=true" \ python-flint ``` -------------------------------- ### Install python-flint with pip Source: https://python-flint.readthedocs.io/en/latest/install Installs the latest release of python-flint from PyPI using pip. Ensure you are installing into the correct Python environment. ```python pip install python-flint ``` -------------------------------- ### Install python-flint with conda Source: https://python-flint.readthedocs.io/en/latest/_sources/install Installs python-flint from the conda-forge channel using conda. ```python conda install -c conda-forge python-flint ``` -------------------------------- ### Build FLINT from Source Source: https://python-flint.readthedocs.io/en/latest/_sources/build Builds GMP, MPFR, and FLINT from their source code using standard configure, make, and make install commands. ```shell ./configure make make install ``` -------------------------------- ### Meson Build System Commands Source: https://python-flint.readthedocs.io/en/latest/workflow Standard commands for setting up, compiling, and installing a project using the Meson build system. ```bash meson setup build meson compile -C build meson install -C build ``` -------------------------------- ### Install python-flint with conda Source: https://python-flint.readthedocs.io/en/latest/install Installs the latest release of python-flint from the conda-forge channel using conda. ```conda conda install -c conda-forge python-flint ``` -------------------------------- ### Clone and Setup Repository Source: https://python-flint.readthedocs.io/en/latest/workflow Steps to fork, clone the Python Flint repository, and set up the upstream remote for future updates. ```shell cd ``` ```shell git remote add upstream ``` -------------------------------- ### Install specific python-flint version with pip Source: https://python-flint.readthedocs.io/en/latest/_sources/install Installs a specific version of python-flint from PyPI using pip. ```python pip install python-flint==0.6.0 ``` -------------------------------- ### Install a specific version of python-flint Source: https://python-flint.readthedocs.io/en/latest/install Installs a specific version of python-flint using pip by specifying the version number. ```python pip install python-flint==0.6.0 ``` -------------------------------- ### Python Flint: Generator Examples Source: https://python-flint.readthedocs.io/en/latest/_gr Demonstrates how to retrieve generators for different Flint contexts, including gr_fmpzi_ctx and gr_fq_ctx. ```Python >>> from flint.types._gr import gr_fmpzi_ctx, gr_fq_ctx >>> ctx = gr_fmpzi_ctx >>> ctx.gen() I >>> ctx = gr_fq_ctx.new(5, 2) >>> ctx.gen() a ``` -------------------------------- ### Build using spin Tool Source: https://python-flint.readthedocs.io/en/latest/workflow Using the 'spin' tool to simplify the setup and build process for Python Flint. Demonstrates passing arguments to Meson. ```shell spin build -Dflint_version_check=false ``` ```shell =false meson spin ``` -------------------------------- ### Install Python-FLINT Source: https://python-flint.readthedocs.io/en/latest/build Installs the Python-FLINT package using pip. This command assumes that all necessary dependencies, including FLINT, GMP, and MPFR, have already been installed. ```bash pip install . ``` -------------------------------- ### Building with Spin Tool Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Uses the 'spin build' command as a frontend to Meson to set up and build the project in a single step. It can also pass arguments to the underlying Meson commands. ```bash spin build -- -Dflint_version_check=false ``` -------------------------------- ### Alternative Test Execution Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Demonstrates running tests by first installing the package and then executing the test command directly, which is an alternative to using 'spin run'. ```bash pip install . python -m flint.test ``` -------------------------------- ### Configuring and Building with Meson Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Configures the build process using Meson, checking for system dependencies like FLINT, GMP, MPFR, C compilers, and Cython. Then, it compiles the project. ```bash meson setup build meson compile -C build ``` -------------------------------- ### fmpq_mat Initialization and Inverse Source: https://python-flint.readthedocs.io/en/latest/fmpq_mat Demonstrates the initialization of an fmpq_mat and calculating its inverse. Also shows matrix multiplication to verify the inverse. ```python >>> from flint import fmpq >>> A = fmpq_mat(3,3,[1,3,5,2,4,6,fmpq(2,3),2,4]) >>> A.inv() [-3, 3/2, 3/2] [ 3, -1/2, -3] [-1, 0, 3/2] >>> A.inv() * A [1, 0, 0] [0, 1, 0] [0, 0, 1] ``` -------------------------------- ### Python-flint Build Process Overview Source: https://python-flint.readthedocs.io/en/latest/workflow Explains the four main steps involved in building the python-flint package for development and distribution, including compilation and packaging. ```en 1. The Cython code in `python-flint` is compiled to C code using `cython`. 2. The C code generated by `cython` is compiled to Python extension modules (shared libraries) using a C compiler and these are linked against the FLINT library and other dependencies. 3. The extension modules and Python files are all assembled into a Python package directory. 4. The Python package directory is bundled into a wheel (a zip file). ``` -------------------------------- ### Meson Persistent Configuration Options Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Illustrates how Meson setup commands with configuration options are persistent. Subsequent calls combine new options with previously set ones. ```bash meson setup build -Dfirst_option=true meson setup build -Dsecond_option=false # first_option is still true ``` -------------------------------- ### Install python-flint in editable mode Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint in editable mode using pip, meson, and meson-python. Requires cloning the repository and installing build dependencies. The `--no-build-isolation` flag is crucial for the build directory not to be deleted. ```bash git clone https://github.com/flintlib/python-flint.git cd python-flint pip install meson meson-python cython ninja pip install --no-build-isolation --editable . python -m flint.test # recommended if you have made changes ``` -------------------------------- ### Configuring Meson Build Directories Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Demonstrates how to view and change the configuration of an existing Meson build directory using 'meson configure'. ```bash meson configure build-debug # view the configuration meson configure build-debug -Dsome_option=true # change the configuration meson setup build meson configure build -Dsome_option=true -Dsome_other_option=false ``` -------------------------------- ### Install FLINT on macOS Source: https://python-flint.readthedocs.io/en/latest/_sources/build Installs the FLINT library on macOS using the Homebrew package manager. ```shell brew install flint ``` -------------------------------- ### Python-flint Distribution Process Source: https://python-flint.readthedocs.io/en/latest/workflow Outlines the steps for distributing python-flint on PyPI, including bundling dependencies and uploading the wheel. ```en 1. All of the dependencies such as the FLINT library are bundled into the wheel. 2. The wheel is uploaded to `PyPI`. 3. Users install the wheel from PyPI (`pip install python-flint`). ``` -------------------------------- ### Meson Build System Configuration Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Describes the build system for python-flint, which utilizes Meson and Meson-Python. It explains how Meson is configured via 'meson.build' and 'meson.options' files for building wheels compatible with PEP 517. ```APIDOC Meson Build System: - Manages the build process for python-flint using 'meson'. - Configuration files: 'meson.build', 'meson.options'. - Uses 'meson-python' as a PEP 517 build backend for 'pip'. - When installing with 'pip install .', 'meson-python' instructs 'meson' to build a python-flint wheel. ``` -------------------------------- ### Configure and Build Python Flint Source: https://python-flint.readthedocs.io/en/latest/workflow Steps to configure the build using Meson and then build the Python Flint project. Includes options for version checking. ```shell meson setup build ``` ```shell ninja -C build ``` ```shell meson setup build -Dflint_version_check=false ``` ```shell =false meson setup build ``` -------------------------------- ### nmod_poly Initialization and Basic Operations Source: https://python-flint.readthedocs.io/en/latest/nmod_poly Demonstrates the initialization of nmod_poly objects with coefficients and a modulus, and shows basic arithmetic operations like negation and exponentiation. It also illustrates converting a polynomial to a list of its coefficients. ```python >>> from flint import ctx >>> a = nmod_poly([5,1,10,14,8], 7) >>> a x^4 + 3*x^2 + x + 5 >>> -a 6*x^4 + 4*x^2 + 6*x + 2 >>> ctx.pretty = False >>> list(nmod_poly(list(range(3)), 2)) [nmod(0, 2), nmod(1, 2)] >>> nmod_poly([1, 2, 3], 23) ** 3 nmod_poly([1, 6, 21, 21, 17, 8, 4], 23) >>> divmod(nmod_poly([2,0,1,1,6],23), nmod_poly([3,5,7],23)) (nmod_poly([4, 0, 14], 23), nmod_poly([13, 3], 23)) >>> ctx.pretty = True ``` -------------------------------- ### Install specific version of python-flint Source: https://python-flint.readthedocs.io/en/latest/build Installs a particular version of the python-flint library from PyPI, specified using the version number. ```python pip install python-flint==0.7.0a4 ``` -------------------------------- ### Autotools Equivalents for Meson Source: https://python-flint.readthedocs.io/en/latest/workflow Comparison of Meson build commands to their traditional autotools counterparts. ```bash ./configure make make install ``` -------------------------------- ### Test python-flint installation via Python script Source: https://python-flint.readthedocs.io/en/latest/_sources/install Runs the test suite and doctests for python-flint programmatically from within a Python script. ```python from flint.test.__main__ import main main() ``` -------------------------------- ### Python-Flint Compatibility Table Source: https://python-flint.readthedocs.io/en/latest/build A table outlining the compatibility of python-flint releases with CPython, FLINT, and Cython versions, along with their release dates. ```APIDOC python-flint | Release date | CPython | FLINT | Cython ---|---|---|---|--- 0.7.0 | Not yet | 3.10-3.13 | 3.0-3.2? | 3.0-3.1? 0.6.0 | 1st Feb 2024 | 3.9-3.12 | 3.0 | 3.0 0.5.0 | 22nd Oct 2023 | 3.9-3.12 | 3.0 | 3.0 0.4.0 | 8th Aug 2023 | 3.9-3.11 | `2.9.0` (`Arb 2.23.0`) | 3.0 0.3.0 | 7th Dec 2018 | older Python versions | `< 3.0` | `< 3.0` ``` -------------------------------- ### Install Development Dependencies Source: https://python-flint.readthedocs.io/en/latest/workflow Command to install Python development dependencies like Cython and Meson required for building Python Flint. ```shell pip install -e .[dev] ``` -------------------------------- ### Remove python-flint editable install Source: https://python-flint.readthedocs.io/en/latest/build Uninstalls the python-flint package installed in editable mode using pip and removes the build directory. ```bash pip uninstall python-flint ``` -------------------------------- ### fmpq Class Initialization and Arithmetic Source: https://python-flint.readthedocs.io/en/latest/fmpq Demonstrates the initialization of fmpq objects and basic arithmetic operations like addition. ```python >>> fmpq(1,7) + fmpq(50,51) 401/357 ``` -------------------------------- ### Install FLINT on Ubuntu Source: https://python-flint.readthedocs.io/en/latest/build Installs the FLINT development library on Ubuntu using apt-get. This is a runtime dependency for Python-FLINT when building from source. ```bash sudo apt-get install libflint-dev ``` -------------------------------- ### Spin Test Equivalent Meson Commands Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow The underlying Meson and Python commands that 'spin test' is equivalent to, demonstrating the build and test process. ```bash meson compile -C build # rebuild meson install --only-changed -C build --destdir ../build-install export PYTHONPATH="/path/to/python-flint/build-install/usr/lib/python3.12/site-packages" python -m pytest --pyargs flint ``` -------------------------------- ### Testing python-flint after changes Source: https://python-flint.readthedocs.io/en/latest/_sources/build Runs the recommended tests for python-flint after making code modifications, especially useful after an editable installation. ```python python -m flint.test ``` -------------------------------- ### Install FLINT on MacOS Source: https://python-flint.readthedocs.io/en/latest/build Installs the FLINT library on MacOS using the Homebrew package manager. This is a runtime dependency for Python-FLINT when building from source. ```bash brew install flint ``` -------------------------------- ### Spin Commands for Python Flint Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Provides a list of common 'spin' commands used for managing the Python Flint project, including running tests, building, and managing shells. ```bash spin run python -m flint.test # run all tests and doctests meson setup build # Configure the project. spin build # Build the project. spin test # Run the general tests. spin run # Run a command in the local build environment. spin python # Start a Python shell in the local build environment. spin ipython # Start an IPython shell in the local build environment. spin shell # Start a system shell in the local build environment. spin docs # Build the documentation. spin install # Install the project editably in the active Python environment. ``` -------------------------------- ### Install python-flint from Local Source Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint from a local source directory or archive using pip. This command is used after obtaining the source code locally. ```bash pip install path/to/python-flint-directory-or-archive ``` -------------------------------- ### Running Python Flint Tests with Spin Source: https://python-flint.readthedocs.io/en/latest/workflow Simplified command to run Python Flint tests using the spin tool, which handles rebuilding and testing with the local build. ```bash spin test ``` -------------------------------- ### Runtime Library Path Configuration Source: https://python-flint.readthedocs.io/en/latest/_sources/build Demonstrates how to set environment variables to specify the runtime search path for shared libraries (GMP, MPFR, FLINT) on different operating systems. This is crucial when libraries are not in system-default locations. ```bash # Linux export LD_LIBRARY_PATH=$(pwd)/.local/lib # MacOS export DYLD_LIBRARY_PATH=$(pwd)/.local/lib # Windows export PATH=$(pwd)/.local/bin:$PATH ``` -------------------------------- ### Python-flint Compatibility Table Source: https://python-flint.readthedocs.io/en/latest/_sources/build A compatibility matrix for python-flint releases, detailing supported versions of CPython, FLINT, and Cython, along with release dates. This information is particularly relevant when building from source. ```APIDOC python-flint compatibility :header-rows: 1 * - python-flint - Release date - CPython - FLINT - Cython * - 0.7.0 - Not yet - 3.10-3.13 - 3.0-3.2? - 3.0-3.1? * - 0.6.0 - 1st Feb 2024 - 3.9-3.12 - 3.0 - 3.0 * - 0.5.0 - 22nd Oct 2023 - 3.9-3.12 - 3.0 - 3.0 * - 0.4.0 - 8th Aug 2023 - 3.9-3.11 - "2.9.0" (Arb 2.23.0) - 3.0 * - 0.3.0 - 7th Dec 2018 - older Python versions - "< 3.0" - "< 3.0" ``` -------------------------------- ### Install python-flint with non-standard FLINT location Source: https://python-flint.readthedocs.io/en/latest/build Installs python-flint in editable mode when the FLINT library is located in a non-standard path. It uses pip with `--config-settings` to specify the pkg-config path. ```bash pip install --no-build-isolation \ --config-settings=setup-args="--pkg-config-path=$(pwd)/.local/lib/pkgconfig" \ --editable . ``` -------------------------------- ### Spin Commands for Python Flint Source: https://python-flint.readthedocs.io/en/latest/workflow Provides essential 'spin' commands for configuring, testing, building, and running the Python Flint project. Includes commands for general development and specific tasks like coverage measurement and documentation building. ```shell spin setup build spin run python -m flint.test spin build spin test spin run spin python spin ipython spin shell spin docs pip uninstall python-flint ``` -------------------------------- ### Spin Tool for Development Tasks Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Using the Spin tool to simplify common development tasks for Python Flint, such as running tests. Spin acts as a frontend to Meson. ```bash spin test ``` -------------------------------- ### Build-time and Runtime Paths for Setuptools/numpy.distutils Source: https://python-flint.readthedocs.io/en/latest/_sources/build Specifies environment variables used by older build systems (setuptools or numpy.distutils) to locate FLINT dependencies during build time and runtime. Includes C include paths, library paths, linker flags (RPATH), and runtime library paths for different OS. ```bash # Build-time C_INCLUDE_PATH=$(pwd)/.local/include LIBRARY_PATH=$(pwd)/.local/lib LDFLAGS=-Wl,-rpath=$(pwd)/.local/lib # Linux or MacOS # Run-time LD_LIBRARY_PATH=$(pwd)/.local/lib # Linux DYLD_LIBRARY_PATH=$(pwd)/.local/lib # MacOS PATH=$(pwd)/.local/bin:$PATH # Windows ``` -------------------------------- ### Local Dependency Build Script (Unix) Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Details the shell script used for building and installing GMP, MPFR, and FLINT locally within a project. It allows for customization of versions and installation directories. ```Shell bin/build_dependencies_unix.sh # This script downloads and builds GMP, MPFR, and FLINT. # Installs them under the current directory in a subdirectory called '.local'. # Versions and installation directory can be changed by editing bin/build_variables.sh. ``` -------------------------------- ### Running Python Flint Tests Locally Source: https://python-flint.readthedocs.io/en/latest/_sources/workflow Steps to run Python Flint tests using a local build. This involves changing the directory to the installed site-packages and executing the tests with Python. ```bash cd build-install/usr/lib/python3.12/site-packages python -m flint.test ``` -------------------------------- ### Spin Test Command Breakdown Source: https://python-flint.readthedocs.io/en/latest/workflow Detailed breakdown of the commands executed by `spin test`, including compilation, installation, setting PYTHONPATH, and running pytest. ```bash meson compile -C build # rebuild meson install --only-changed -C build --destdir ../build-install export PYTHONPATH="/path/to/python-flint/build-install/usr/lib/python3.12/site-packages" python -m pytest --pyargs flint ``` -------------------------------- ### Flint gr_ctx Context Examples Source: https://python-flint.readthedocs.io/en/latest/_gr Illustrative examples demonstrating the usage of various Flint context properties and methods with different domain types like gr_complex_qqbar_ctx, gr_real_qqbar_ctx, gr_fmpz_ctx, gr_real_float_arf_ctx, gr_nmod_ctx, and gr_real_arb_ctx. ```Python >>> from flint.types._grimport gr_complex_qqbar_ctx, gr_real_qqbar_ctx >>> R1 = gr_complex_qqbar_ctx.new() >>> R2 = gr_real_qqbar_ctx.new() >>> R1.is_algebraically_closed, R2.is_algebraically_closed (True, False) ``` ```Python >>> fromflint.types._grimport gr_fmpz_ctx, gr_real_float_arf_ctx >>> R1 = gr_fmpz_ctx >>> R2 = gr_real_float_arf_ctx.new(10) >>> R1.is_exact, R2.is_exact (True, False) ``` ```Python >>> fromflint.types._grimport gr_fmpz_ctx, gr_fmpq_ctx >>> R1 = gr_fmpz_ctx >>> R2 = gr_fmpq_ctx >>> R1.is_field, R2.is_field (False, True) ``` ```Python >>> fromflint.types._grimport gr_fmpz_ctx, gr_nmod_ctx >>> R1 = gr_fmpz_ctx >>> R2 = gr_nmod_ctx.new(5) >>> R1.is_finite, R2.is_finite (False, True) ``` ```Python >>> fromflint.types._grimport gr_nmod_ctx, gr_fmpz_ctx >>> R1 = gr_nmod_ctx.new(5) >>> R2 = gr_fmpz_ctx >>> R1.is_finite_characteristic, R2.is_finite_characteristic (True, False) ``` ```Python >>> fromflint.types._grimport gr_nmod_ctx >>> R1 = gr_nmod_ctx.new(5) >>> R2 = gr_nmod_ctx.new(6) >>> R1.is_integral_domain, R2.is_integral_domain (True, False) ``` ```Python >>> fromflint.types._grimport gr_fmpz_ctx, gr_nmod_ctx >>> R1 = gr_fmpz_ctx >>> R2 = gr_nmod_ctx.new(5) >>> R1.is_ordered_ring, R2.is_ordered_ring (True, None) ``` ```Python >>> fromflint.types._grimport gr_fmpz_ctx >>> R1 = gr_fmpz_ctx >>> R1.is_unique_factorization_domain True ```