Installation Guide
You may choose one of two methods to install TL2cgen on your system:
Download binary releases from PyPI (Recommended)
This is probably the most convenient method. Simply type
pip install tl2cgen
to install the TL2cgen package. The command will locate the binary release that is compatible with your current platform. Check the installation by running
import tl2cgen
in an interactive Python session. This method is available for only Windows, MacOS, and Linux. For other operating systems, see the next section.
Note
Windows users need to install Visual C++ Redistributable
TL2cgen requires DLLs from Visual C++ Redistributable in order to function, so make sure to install it. Exception: If you have Visual Studio installed, you already have access to necessary libraries and thus don’t need to install Visual C++ Redistributable.
Note
Installing OpenMP runtime on MacOS
TL2cgen requires the presence of OpenMP runtime. To install OpenMP runtime on a Mac OSX system, run the following command:
brew install libomp
Download binary releases from Conda
TL2cgen is also available on Conda.
conda install -c conda-forge tl2cgen
to install the TL2cgen package. See https://anaconda.org/conda-forge/tl2cgen to check the available platforms.
Compile TL2cgen from the source
Installation consists of two steps:
Build the native library from C++ code.
Install the Python package.
Note
Name of the native library
Operating System |
Shared library |
---|---|
Windows |
|
Mac OS X |
|
Linux / other UNIX |
|
To get started, clone TL2cgen repo from GitHub.
git clone https://github.com/dmlc/tl2cgen.git
cd tl2cgen
The next step is to build the native library.
1-1. Compiling the native library on Linux and MacOS
Here, we use CMake to generate a Makefile:
mkdir build
cd build
cmake ..
Once CMake finished running, simply invoke GNU Make to obtain the native libraries.
make
The compiled library will be under the build/
directory.
Note
Compiling TL2cgen with multithreading on MacOS
TL2cgen requires the presence of OpenMP runtime. To install OpenMP runtime on a MacOS system, run the following command:
brew install libomp
1-2. Compiling native libraries on Windows
We can use CMake to generate a Visual Studio project. The following snippet assumes that Visual Studio 2022 is installed. Adjust the version depending on the copy that’s installed on your system.
mkdir build
cd build
cmake .. -G"Visual Studio 17 2022" -A x64
Note
Visual Studio 2019 or newer is required
TL2cgen uses the C++17 standard. Ensure that you have Visual Studio version 2019 or newer.
Once CMake finished running, open the generated solution file (tl2cgen.sln
) in Visual Studio.
From the top menu, select Build > Build Solution.
2. Installing Python package
The Python package is located at the python
subdirectory. Run Pip to install the Python
package. The Python package will re-use the native library built in Step 1.
cd python
pip install . # will re-use libtl2cgen.so