Рейтинг@Mail.ru

Building from source

Building from source

For downloading Tarantool source and building it, the platforms can differ and the preferences can differ. But strategically the steps are always the same.

  1. Get tools and libraries that will be necessary for building and testing.

    The absolutely necessary ones are:

    • A program for downloading source repositories.
      For all platforms, this is git. It allows downloading the latest complete set of source files from the Tarantool repository on GitHub.

    • A C/C++ compiler.
      Ordinarily, this is gcc and g++ version 4.6 or later. On Mac OS X, this is Clang version 3.2+.

    • A program for managing the build process.
      For all platforms, this is CMake version 2.8+.

    • ReadLine library, any version

    • ncurses library, any version

    • OpenSSL library, version 1.0.1+

    • cURL library, version 0.725+

    • LibYAML library, version 0.1.4+

    • Python and modules.
      Python interpreter is not necessary for building Tarantool itself, unless you intend to use the “Run the test suite” option in step 5. For all platforms, this is python version 2.7+ (but not 3.x). You need the following Python modules:

    To install all required dependencies, follow the instructions for your OS:

    • For Debian/Ubuntu, say:

      $ apt install -y build-essential cmake coreutils sed \
            libreadline-dev libncurses5-dev libyaml-dev libssl-dev \
            libcurl4-openssl-dev libunwind-dev \
            python python-pip python-setuptools python-dev \
            python-msgpack python-yaml python-argparse python-six python-gevent
      
    • For RHEL/CentOS/Fedora, say:

      $ yum install -y gcc gcc-c++ cmake coreutils sed \
            readline-devel ncurses-devel libyaml-devel openssl-devel \
            libcurl-devel libunwind-devel \
            python python-pip python-setuptools python-devel \
            python-msgpack python-yaml python-argparse python-six python-gevent
      
    • For Mac OS X (instructions below are for OS X El Capitan):

      If you’re using Homebrew as your package manager, say:

      $ brew install cmake autoconf binutils zlib \
             readline ncurses libyaml openssl curl libunwind-headers \
             && pip install python-daemon \
             msgpack-python pyyaml configargparse six gevent
      

      Alternatively, download Apple’s default Xcode toolset:

      $ xcode-select --install
      $ xcode-select -switch /Applications/Xcode.app/Contents/Developer
      
    • For FreeBSD (instructions below are for FreeBSD 10.1 release), say:

      $ pkg install -y sudo git cmake gmake gcc coreutils \
            readline ncurses libyaml openssl curl libunwind \
            python27 py27-pip py27-setuptools py27-daemon \
            py27-msgpack-python py27-yaml py27-argparse py27-six py27-gevent
      

    If some Python modules are not available in a repository, it is best to set up the modules by getting a tarball and doing the setup with python setup.py like this:

    # On some machines, this initial command may be necessary:
    $ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
    
    # Python module for parsing YAML (pyYAML), for test suite:
    # (If wget fails, check at http://pyyaml.org/wiki/PyYAML
    # what the current version is.)
    $ cd ~
    $ wget http://pyyaml.org/download/pyyaml/PyYAML-3.10.tar.gz
    $ tar -xzf PyYAML-3.10.tar.gz
    $ cd PyYAML-3.10
    $ sudo python setup.py install
    

    Finally, use Python pip to bring in Python packages that may not be up-to-date in the distro repositories. (On CentOS 7, it will be necessary to install pip first, with sudo yum install epel-release followed by sudo yum install python-pip.)

    $ pip install -r \
          https://raw.githubusercontent.com/tarantool/test-run/master/requirements.txt \
          --user
    

    This step is only necessary once, the first time you do a download.

  2. Use git to download the latest Tarantool source code from the GitHub repository tarantool/tarantool, branch 1.7, to a local directory named ~/tarantool, for example:

    $ git clone --recursive https://github.com/tarantool/tarantool.git -b 1.7 ~/tarantool
    

    On rare occasions, the submodules need to be updated again with the command:

    $ git submodule update --init --recursive
    
  3. Use CMake to initiate the build.

    $ cd ~/tarantool
    $ make clean         # unnecessary, added for good luck
    $ rm CMakeCache.txt  # unnecessary, added for good luck
    $ cmake .            # start initiating with build type=Debug
    

    On some platforms, it may be necessary to specify the C and C++ versions, for example:

    $ CC=gcc-4.8 CXX=g++-4.8 cmake .
    

    The CMake option for specifying build type is -DCMAKE_BUILD_TYPE=type, where type can be:

    • Debug – used by project maintainers
    • Release – used only if the highest performance is required
    • RelWithDebInfo – used for production, also provides debugging capabilities

    The CMake option for hinting that the result will be distributed is -DENABLE_DIST=ON. If this option is on, then later make install will install tarantoolctl files in addition to tarantool files.

  4. Use make to complete the build.

    $ make
    

    Note

    For FreeBSD, use gmake instead.

    This creates the ‘tarantool’ executable in the src/ directory.

    Next, it’s highly recommended to say make install to install Tarantool to the /usr/local directory and keep your system clean. However, it is possible to run the Tarantool executable without installation.

  5. Run the test suite.

    This step is optional. Tarantool’s developers always run the test suite before they publish new versions. You should run the test suite too, if you make any changes in the code. Assuming you downloaded to ~/tarantool, the principal steps are:

    # make a subdirectory named `bin`
    $ mkdir ~/tarantool/bin
    
    # link Python to bin (this may require superuser privileges)
    $ ln /usr/bin/python ~/tarantool/bin/python
    
    # get to the test subdirectory
    $ cd ~/tarantool/test
    
    # run tests using Python
    $ PATH=~/tarantool/bin:$PATH ./test-run.py
    

    The output should contain reassuring reports, for example:

    ======================================================================
    TEST                                            RESULT
    ------------------------------------------------------------
    box/bad_trigger.test.py                         [ pass ]
    box/call.test.py                                [ pass ]
    box/iproto.test.py                              [ pass ]
    box/xlog.test.py                                [ pass ]
    box/admin.test.lua                              [ pass ]
    box/auth_access.test.lua                        [ pass ]
    ... etc.
    

    To prevent later confusion, clean up what’s in the bin subdirectory:

    $ rm ~/tarantool/bin/python
    $ rmdir ~/tarantool/bin
    
  6. Make RPM and Debian packages.

    This step is optional. It’s only for people who want to redistribute Tarantool. We highly recommend to use official packages from the tarantool.org web-site. However, you can build RPM and Debian packages using PackPack or using the dpkg-buildpackage or rpmbuild tools. Please consult dpkg or rpmbuild documentation for details.

  7. Verify your Tarantool installation.

    # if you installed tarantool locally after build
    $ tarantool
    # - OR -
    # if you didn't install tarantool locally after build
    $ ./src/tarantool
    

    This starts Tarantool in the interactive mode.

See also: