|
| 1 | + |
1 | 2 | # SymEngine Python Wrappers
|
2 | 3 |
|
3 |
| -Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), |
| 4 | +Python wrappers to the C++ library [SymEngine](https://github.com/symengine/symengine), |
4 | 5 | a fast C++ symbolic manipulation library.
|
5 | 6 |
|
6 |
| -[](https://travis-ci.org/symengine/symengine.py) [](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) |
| 7 | +[](https://travis-ci.org/symengine/symengine.py) |
| 8 | +[](https://ci.appveyor.com/project/symengine/symengine-py/branch/master) |
7 | 9 |
|
8 | 10 | ## Installation
|
9 | 11 |
|
10 | 12 | ### Pip
|
11 | 13 |
|
12 | 14 | See License section for information about wheels
|
13 | 15 |
|
14 |
| - pip install symengine --user |
| 16 | +```bash |
| 17 | +pip install symengine --user |
| 18 | +``` |
15 | 19 |
|
16 | 20 | ### Conda package manager
|
17 | 21 |
|
18 |
| - conda install python-symengine -c symengine -c conda-forge |
| 22 | +```bash |
| 23 | +conda install python-symengine -c symengine -c conda-forge |
| 24 | +``` |
19 | 25 |
|
20 |
| -optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): |
| 26 | +Optionally, you may choose to install an early [developer preview](https://github.com/symengine/python-symengine-feedstock): |
21 | 27 |
|
22 |
| - conda install python-symengine -c symengine/label/dev -c conda-forge |
| 28 | +```bash |
| 29 | +conda install python-symengine -c symengine/label/dev -c conda-forge |
| 30 | +``` |
23 | 31 |
|
24 | 32 | ### Build from source
|
25 | 33 |
|
26 | 34 | Install prerequisites.
|
27 | 35 |
|
28 |
| - CMake >= 2.8.12 |
29 |
| - Python3 >= 3.8 |
30 |
| - Cython >= 0.29.24 |
31 |
| - SymEngine >= 0.7.0 |
| 36 | +```bash |
| 37 | +CMake >= 2.8.12 |
| 38 | +Python3 >= 3.8 |
| 39 | +Cython >= 0.29.24 |
| 40 | +SymEngine >= 0.7.0 |
| 41 | +``` |
32 | 42 |
|
33 |
| -For SymEngine, only a specific commit/tag (see symengine_version.txt) is supported. |
34 |
| -Latest git master branch may not work as there may be breaking changes in SymEngine. |
| 43 | +For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is supported. |
| 44 | +The latest git master branch may not work as there may be breaking changes in **SymEngine**. |
35 | 45 |
|
36 | 46 | Python wrappers can be installed by,
|
37 | 47 |
|
38 |
| - python setup.py install |
| 48 | +```bash |
| 49 | +python setup.py install |
| 50 | +``` |
| 51 | + |
| 52 | +Additional options to `setup.py` are: |
| 53 | + |
| 54 | +```bash |
| 55 | +python setup.py install build_ext |
| 56 | + --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory |
| 57 | + --compiler=mingw32|msvc|cygwin # Select the compiler for Windows |
| 58 | + --generator=cmake-generator # CMake Generator |
| 59 | + --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC |
| 60 | + --define="var1=value1;var2=value2" # Give options to CMake |
| 61 | + --inplace # Build the extension in source tree |
| 62 | +``` |
| 63 | + |
| 64 | +Standard options to `setup.py` like `--user`, `--prefix` can be used to configure install location. |
| 65 | +NumPy is used if found by default, if you wish to make your choice of NumPy use explicit: then add e.g. `WITH_NUMPY=False` to `--define`. |
| 66 | + |
| 67 | +### Notes on Dependencies |
39 | 68 |
|
40 |
| -Additional options to setup.py are |
| 69 | +If you intend to evaluate floating-point expressions (using **lambdify**), you should consider linking against **LLVM**. Many users might also benefit from linking against **FLINT**, as it is now LGPL-licensed. |
41 | 70 |
|
42 |
| - python setup.py install build_ext |
43 |
| - --symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory |
44 |
| - --compiler=mingw32|msvc|cygwin # Select the compiler for Windows |
45 |
| - --generator=cmake-generator # CMake Generator |
46 |
| - --build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC |
47 |
| - --define="var1=value1;var2=value2" # Give options to CMake |
48 |
| - --inplace # Build the extension in source tree |
| 71 | +In general, **sudo** is only required if you are installing to the default prefix (`/usr/local`). We recommend specifying a custom prefix (`--prefix=$HOME/.local`) to avoid requiring administrative privileges, which most users can do without using **sudo**. |
49 | 72 |
|
50 |
| -Standard options to setup.py like `--user`, `--prefix` can be used to |
51 |
| -configure install location. NumPy is used if found by default, if you wish |
52 |
| -to make your choice of NumPy use explicit: then add |
53 |
| -e.g. ``WITH_NUMPY=False`` to ``--define``. |
| 73 | +If you're uncomfortable specifying the prefix manually, we suggest using **Conda** or installing the pre-built wheels via **pip** instead of building from source. |
54 | 74 |
|
55 |
| -Use SymEngine from Python as follows: |
| 75 | +## Verification |
56 | 76 |
|
57 |
| - >>> from symengine import var |
58 |
| - >>> var("x y z") |
59 |
| - (x, y, z) |
60 |
| - >>> e = (x+y+z)**2 |
61 |
| - >>> e.expand() |
62 |
| - 2*x*y + 2*x*z + 2*y*z + x**2 + y**2 + z**2 |
| 77 | +You can verify the installation of **SymEngine** by using the provided code snippet in this README. This snippet ensures that the installation works as expected and that basic functionality is available. |
63 | 78 |
|
64 |
| -You can read Python tests in `symengine/tests` to see what features are |
65 |
| -implemented. |
| 79 | +```python |
| 80 | +from symengine import var |
| 81 | +x, y, z = var('x y z') |
| 82 | +e = (x + y + z)**2 |
| 83 | +expanded_e = e.expand() |
| 84 | +print(expanded_e) |
| 85 | +``` |
| 86 | +This will output: |
| 87 | +```python |
| 88 | +x**2 + y**2 + z**2 + 2*x*y + 2*x*z + 2*y*z |
| 89 | +``` |
66 | 90 |
|
| 91 | +Note: The verification code provided above checks the functionality of SymEngine. For additional verification specific to SymEngine, please refer to the [official SymEngine Python bindings repository](https://github.com/symengine/symengine.py) for further tests and examples. |
67 | 92 |
|
68 | 93 | ## License
|
69 | 94 |
|
70 |
| -symengine.py is MIT licensed and uses several LGPL, BSD-3 and MIT licensed libraries |
| 95 | +symengine.py is MIT licensed and uses several LGPL, BSD-3, and MIT licensed libraries. |
71 | 96 |
|
72 |
| -Licenses for the dependencies of pip wheels are as follows, |
| 97 | +Licenses for the dependencies of pip wheels are as follows: |
73 | 98 |
|
74 |
| -pip wheels on Unix use GMP (LGPL-3.0-or-later), MPFR (LGPL-3.0-or-later), |
75 |
| -MPC (LGPL-3.0-or-later), LLVM (Apache-2.0), zlib (Zlib), libxml2 (MIT), |
76 |
| -zstd (BSD-3-Clause) and symengine (MIT AND BSD-3-Clause). |
77 |
| -pip wheels on Windows use MPIR (LGPL-3.0-or-later) instead of GMP above and |
78 |
| -pthreads-win32 (LGPL-3.0-or-later) additionally. |
79 |
| -NumPy (BSD-3-Clause) and SymPy (BSD-3-Clause) are optional dependencies. |
80 |
| -Sources for these binary dependencies can be found on https://github.com/symengine/symengine-wheels/releases |
| 99 | +- pip wheels on Unix use **GMP** (LGPL-3.0-or-later), **MPFR** (LGPL-3.0-or-later), **MPC** (LGPL-3.0-or-later), **LLVM** (Apache-2.0), **zlib** (Zlib), **libxml2** (MIT), **zstd** (BSD-3-Clause), and **symengine** (MIT AND BSD-3-Clause). |
| 100 | +- pip wheels on Windows use **MPIR** (LGPL-3.0-or-later) instead of **GMP** above and **pthreads-win32** (LGPL-3.0-or-later) additionally. |
| 101 | +- **NumPy** (BSD-3-Clause) and **SymPy** (BSD-3-Clause) are optional dependencies. |
| 102 | +- Sources for these binary dependencies can be found on [symengine-wheels](https://github.com/symengine/symengine-wheels/releases). |
81 | 103 |
|
0 commit comments