Coder Social home page Coder Social logo

virendrakabra14 / lpython Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lcompilers/lpython

0.0 0.0 0.0 18.2 MB

Python compiler

Home Page: https://lpython.org/

License: Other

Shell 0.23% C++ 80.99% Python 13.77% C 1.84% Nix 0.17% CMake 1.19% Batchfile 0.01% Yacc 0.94% Jupyter Notebook 0.76% Xonsh 0.09%

lpython's Introduction

LPython

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:

  • The best possible performance for numerical, array-oriented code
  • Run on all platforms
  • Compile a subset of Python yet be fully compatible with Python
  • Explore designs so that LPython eventually can compile all Python code
  • Fast compilation
  • Excellent user-friendly diagnostic messages: error, warnings, hints, notes, etc.
  • Ahead-of-Time compilation to binaries, plus interactive usage (Jupyter notebook)
  • Transforming Python code to C++, Fortran and other languages

And more.

Installation

Step 0: Prerequisites

Here is the list of requirements needed to build LPython:

  • Python (3.10+)
  • Conda

For Windows, these are additionally required:

  • Miniforge Prompt
  • Visual Studio (with "Desktop Development with C++" workload)

Please follow the steps for your desired platform.

Step 1: Install Conda

This step involves installing Conda using a conda-forge distribution called Miniforge.

Please follow the instructions here to install Conda on your platform:

Miniforge download link (for Linux, MacOS and Windows): https://github.com/conda-forge/miniforge/#download

Step 2: Setting up

This step involves setting up the required configuration to run the programs in LPython.

Linux

Run the below command to install binutils-dev package on Linux.

sudo apt install binutils-dev

Windows

Please follow the below steps for Windows:

  • Install Visual Studio, for example the version 2022.

    • You can download the Community version for free from: https://visualstudio.microsoft.com/downloads/.
    • 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).
  • Launch the Miniforge prompt from the Desktop.

    • It is recommended to use MiniForge instead of Powershell as the main terminal to build and write code for LPython.
  • In the MiniForge Prompt, initialize the MSVC compiler using the below command:

    call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd" -arch=x64
  • You can optionally test MSVC via:

    cl /?
    link /?

    Both commands must print several pages of help text.

Step 3: Build LPython

  • Clone LPython using the following commands

    git clone https://github.com/lcompilers/lpython.git
    cd lpython

    You may also use GitHub Desktop to do the same.

Linux and MacOS

  • Create a Conda environment using the pre-existing file:

    conda env create -f environment_unix.yml
    conda activate lp
  • Generate prerequisite files; build in Debug Mode:

    ./build0.sh
    ./build1.sh

Windows

  • Create a Conda environment using the pre-existing file:

    conda env create -f environment_win.yml
    conda activate lp
  • Generate prerequisite files; build in Release Mode:

    call build0.bat
    call build1.bat
  • Tests and examples

    ctest
    inst\bin\lpython examples\expr2.py
    inst\bin\lpython examples\expr2.py -o a.out
    a.out
  • Whenever you are updating a test case file, you also need to update all the reference results associated with that test case:

    python run_tests.py -u --skip-run-with-dbg
    
  • To see all the options associated with LPython test suite, use:

    python run_tests.py --help
    

Tests:

Linux or MacOS

  • Run tests:

    ctest
    ./run_tests.py
  • Run integration tests:

    cd integration_tests
    ./run_tests.py

Windows

  • Run integration tests

    python run_tests.py --skip-run-with-dbg
  • Update reference tests

    python run_tests.py -u --skip-run-with-dbg

Speed up Integration Tests on MacOS

Integration tests run slowly because Apple checks the hash of each executable online before running.

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 to run software locally that does not meet the system's security policy."

Examples (Linux or MacOS)

You can run the following examples manually in a terminal:

./src/bin/lpython examples/expr2.py
./src/bin/lpython examples/expr2.py -o expr
./expr
./src/bin/lpython --show-ast examples/expr2.py
./src/bin/lpython --show-asr examples/expr2.py
./src/bin/lpython --show-cpp examples/expr2.py
./src/bin/lpython --show-llvm examples/expr2.py
./src/bin/lpython --show-c examples/expr2.py

Contributing

We welcome contributions from anyone, even if you are new to compilers or to open source. It might sound daunting to contribute to a compiler at first, but please do, it is not complicated. We will help you with technical issues and help improve your contribution so that it can be merged.

To contribute, submit a Pull Request (PR) against our repository at:

https://github.com/lcompilers/lpython

and don't forget to clean your history, see example.

Please report any bugs you may find at our issue tracker: https://github.com/lcompilers/lpython/issues. Or, even better, fork the repository on GitHub and create a PR. We welcome all changes, big or small, and we will help you make a PR if you are new to git.

If you have any questions or need help, please ask us at Zulip (project chat) or our mailinglist.

See the CONTRIBUTING document for more information.

lpython's People

Contributors

certik avatar czgdp1807 avatar thirumalai-shaktivel avatar smit-create avatar namannimmo10 avatar shaikh-ubaid avatar akshanshbhatt avatar dpoerio avatar haozeke avatar abdelrahmankhaledd avatar ansharlubis avatar hsnyder avatar madhav2310 avatar implicitall avatar faze-geek avatar abdullahjavednesar avatar bughunterstudios avatar hp77-creator avatar ankitas11 avatar harshsingh-24 avatar redbopo avatar gptsarthak avatar anutosh491 avatar sc0rpi0n101 avatar krshrimali avatar rebcabin avatar oshanath avatar virendrakabra14 avatar ronnuriel avatar awvwgk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.