|
1 | 1 | # LPython
|
2 | 2 |
|
3 |
| -LPython is a Python compiler. It is in heavy development, currently in |
4 |
| -pre-alpha stage. Some of the goals of LPython: |
5 |
| - |
6 |
| -* The best possible performance for numerical, array-oriented code |
7 |
| -* Run on all platforms |
8 |
| -* Compile a subset of Python yet be fully compatible with Python |
9 |
| -* Explore designs so that LPython eventually can compile all Python code |
10 |
| -* Fast compilation |
11 |
| -* Excellent user-friendly diagnostic messages: error, warnings, hints, notes, |
| 3 | +LPython is a Python compiler. It is in heavy development, currently in pre-alpha stage. LPython works on Windows, macOS and Linux. Some of the goals of LPython include: |
| 4 | + |
| 5 | +- The best possible performance for numerical, array-oriented code |
| 6 | +- Run on all platforms |
| 7 | +- Compile a subset of Python yet be fully compatible with Python |
| 8 | +- Explore designs so that LPython eventually can compile all Python code |
| 9 | +- Fast compilation |
| 10 | +- Excellent user-friendly diagnostic messages: error, warnings, hints, notes, |
12 | 11 | etc.
|
13 |
| -* Ahead-of-Time compilation to binaries, plus interactive usage (Jupyter |
14 |
| - notebook) |
15 |
| -* Transforming Python code to C++, Fortran and other languages |
| 12 | +- Ahead-of-Time compilation to binaries, plus interactive usage (Jupyter notebook) |
| 13 | +- Transforming Python code to C++, Fortran and other languages |
16 | 14 |
|
17 | 15 | And more.
|
18 | 16 |
|
19 | 17 | # Installation
|
20 | 18 |
|
21 |
| -LPython works on Windows, macOS and Linux. |
| 19 | +## Step 0: Prerequisites |
22 | 20 |
|
23 |
| -## Install Conda |
| 21 | +Here is the list of requirements needed to build LPython: |
| 22 | + |
| 23 | +- Python (3.10+) |
| 24 | +- Conda |
| 25 | + |
| 26 | +For Windows, these are additionally required: |
| 27 | + |
| 28 | +- Miniforge Prompt |
| 29 | +- Visual Studio (with "Desktop Development with C++" workload) |
| 30 | + |
| 31 | +Please follow the steps for your desired platform. |
| 32 | + |
| 33 | +## Step 1: Install Conda |
| 34 | + |
| 35 | +This step involves installing Conda using a conda-forge distribution called Miniforge. |
24 | 36 |
|
25 | 37 | Please follow the instructions here to install Conda on your platform:
|
26 | 38 |
|
27 |
| -https://github.com/conda-forge/miniforge/#download |
| 39 | +Miniforge download link (for Linux, MacOS and Windows): https://github.com/conda-forge/miniforge/#download |
| 40 | + |
| 41 | +## Step 2: Setting up |
| 42 | + |
| 43 | +This step involves setting up the required configuration to run the programs in LPython. |
28 | 44 |
|
29 | 45 | ### Linux
|
30 | 46 |
|
| 47 | +Run the below command to install `binutils-dev` package on Linux. |
| 48 | + |
31 | 49 | ```bash
|
32 | 50 | sudo apt install binutils-dev
|
33 | 51 | ```
|
34 | 52 |
|
35 | 53 | ### Windows
|
36 |
| -Install Visual Studio (MSVC), for example the version 2022, you can download the |
37 |
| -Community version for free from: https://visualstudio.microsoft.com/downloads/. |
38 | 54 |
|
39 |
| -Launch the Miniforge prompt from the Desktop. |
| 55 | +Please follow the below steps for Windows: |
40 | 56 |
|
41 |
| -In the shell, initialize the MSVC compiler using: |
| 57 | +- Install Visual Studio, for example the version 2022. |
42 | 58 |
|
43 |
| -```bash |
44 |
| -call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd" -arch=x64 |
45 |
| -``` |
| 59 | + - You can download the |
| 60 | + Community version for free from: https://visualstudio.microsoft.com/downloads/. |
| 61 | + - After installing Visual Studio and running the Visual Studio Installer, you must install the "Desktop Development with C++" workload which will install Visual C++ Compiler (MSVC). |
46 | 62 |
|
47 |
| -You can optionally test MSVC via: |
| 63 | +- Launch the Miniforge prompt from the Desktop. |
48 | 64 |
|
49 |
| -```bash |
50 |
| -cl /? |
51 |
| -link /? |
52 |
| -``` |
| 65 | + - It is recommended to use MiniForge instead of Powershell as the main terminal to build and write code for LPython. |
53 | 66 |
|
54 |
| -Both commands must print several pages of help text. |
| 67 | +- In the MiniForge Prompt, initialize the MSVC compiler using the below command: |
55 | 68 |
|
56 |
| -## Build LPython |
| 69 | + ```bash |
| 70 | + call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd" -arch=x64 |
| 71 | + ``` |
57 | 72 |
|
58 |
| -Clone LPython |
| 73 | +- You can optionally test MSVC via: |
59 | 74 |
|
60 |
| -```bash |
61 |
| -git clone https://github.com/lcompilers/lpython.git |
62 |
| -cd lpython |
63 |
| -``` |
| 75 | + ```bash |
| 76 | + cl /? |
| 77 | + link /? |
| 78 | + ``` |
| 79 | + |
| 80 | + Both commands must print several pages of help text. |
| 81 | + |
| 82 | +## Step 3: Build LPython |
| 83 | + |
| 84 | +- Clone LPython using the following commands |
| 85 | + |
| 86 | + ```bash |
| 87 | + git clone https://github.com/lcompilers/lpython.git |
| 88 | + cd lpython |
| 89 | + ``` |
| 90 | + |
| 91 | + You may also use GitHub Desktop to do the same. |
64 | 92 |
|
65 | 93 | ### Linux and MacOS
|
66 | 94 |
|
67 | 95 | - Create a Conda environment using the pre-existing file:
|
68 | 96 |
|
69 |
| -```bash |
70 |
| -conda env create -f environment_unix.yml |
71 |
| -conda activate lp |
72 |
| -``` |
| 97 | + ```bash |
| 98 | + conda env create -f environment_unix.yml |
| 99 | + conda activate lp |
| 100 | + ``` |
73 | 101 |
|
74 | 102 | - Generate prerequisite files; build in Debug Mode:
|
75 | 103 |
|
76 |
| -```bash |
77 |
| -./build0.sh |
78 |
| -./build1.sh |
79 |
| -``` |
| 104 | + ```bash |
| 105 | + ./build0.sh |
| 106 | + ./build1.sh |
| 107 | + ``` |
80 | 108 |
|
81 | 109 | ### Windows
|
82 | 110 |
|
83 | 111 | - Create a Conda environment using the pre-existing file:
|
84 | 112 |
|
85 |
| -```bash |
86 |
| -conda env create -f environment_win.yml |
87 |
| -conda activate lp |
88 |
| -``` |
| 113 | + ```bash |
| 114 | + conda env create -f environment_win.yml |
| 115 | + conda activate lp |
| 116 | + ``` |
89 | 117 |
|
90 | 118 | - Generate prerequisite files; build in Release Mode:
|
91 | 119 |
|
92 |
| -```bash |
93 |
| -call build0.bat |
94 |
| -call build1.bat |
95 |
| -``` |
| 120 | + ```bash |
| 121 | + call build0.bat |
| 122 | + call build1.bat |
| 123 | + ``` |
96 | 124 |
|
97 | 125 | - Tests and examples
|
98 | 126 |
|
99 |
| -```bash |
100 |
| -ctest |
101 |
| -inst\bin\lpython examples\expr2.py |
102 |
| -inst\bin\lpython examples\expr2.py -o a.out |
103 |
| -a.out |
104 |
| -``` |
| 127 | + ```bash |
| 128 | + ctest |
| 129 | + inst\bin\lpython examples\expr2.py |
| 130 | + inst\bin\lpython examples\expr2.py -o a.out |
| 131 | + a.out |
| 132 | + ``` |
105 | 133 |
|
106 |
| -- After you update a test case file, you also need to update all the reference results associated with that test case: |
| 134 | +- Whenever you are updating a test case file, you also need to update all the reference results associated with that test case: |
107 | 135 |
|
108 |
| -``` |
109 |
| -python run_tests.py -u --skip-run-with-dbg |
110 |
| -``` |
| 136 | + ``` |
| 137 | + python run_tests.py -u --skip-run-with-dbg |
| 138 | + ``` |
111 | 139 |
|
112 | 140 | - To see all the options associated with LPython test suite, use:
|
113 |
| -``` |
114 |
| -python run_tests.py --help |
115 |
| -``` |
116 | 141 |
|
117 |
| -## Tests (Linux or MacOs): |
| 142 | + ``` |
| 143 | + python run_tests.py --help |
| 144 | + ``` |
118 | 145 |
|
119 |
| -Run tests: |
| 146 | +## Tests: |
120 | 147 |
|
121 |
| -```bash |
122 |
| -ctest |
123 |
| -./run_tests.py |
124 |
| -``` |
| 148 | +### Linux or MacOS |
125 | 149 |
|
126 |
| -Run integration tests: |
| 150 | +- Run tests: |
127 | 151 |
|
128 |
| -```bash |
129 |
| -cd integration_tests |
130 |
| -./run_tests.py |
131 |
| -``` |
| 152 | + ```bash |
| 153 | + ctest |
| 154 | + ./run_tests.py |
| 155 | + ``` |
| 156 | + |
| 157 | +- Run integration tests: |
| 158 | + |
| 159 | + ```bash |
| 160 | + cd integration_tests |
| 161 | + ./run_tests.py |
| 162 | + ``` |
| 163 | + |
| 164 | +### Windows |
132 | 165 |
|
133 |
| -### Speed up Integration Test on Macs |
| 166 | +- Run integration tests |
| 167 | + |
| 168 | + ```bash |
| 169 | + python run_tests.py --skip-run-with-dbg |
| 170 | + ``` |
| 171 | + |
| 172 | +- Update reference tests |
| 173 | + |
| 174 | + ```bash |
| 175 | + python run_tests.py -u --skip-run-with-dbg |
| 176 | + ``` |
| 177 | + |
| 178 | +## Speed up Integration Tests on MacOS |
134 | 179 |
|
135 | 180 | Integration tests run slowly because Apple checks the hash of each
|
136 |
| -executable online before running. You can turn off that feature |
137 |
| -in the Privacy tab of the Security and Privacy item of System |
138 |
| -Preferences, Developer Tools, Terminal.app, "allow the apps below |
| 181 | +executable online before running. |
| 182 | + |
| 183 | +You can turn off that feature in the Privacy tab of the Security and Privacy item of System Preferences > Developer Tools > Terminal.app > "allow the apps below |
139 | 184 | to run software locally that does not meet the system's security
|
140 | 185 | policy."
|
141 | 186 |
|
142 |
| -## Examples (Linux or MacOs) |
| 187 | +## Examples (Linux or MacOS) |
143 | 188 |
|
144 |
| -You can run the following examples by hand in a terminal: |
| 189 | +You can run the following examples manually in a terminal: |
145 | 190 |
|
146 | 191 | ```bash
|
147 | 192 | ./src/bin/lpython examples/expr2.py
|
|
0 commit comments