Skip to content

Latest commit

 

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

How to use Python API

Just install ytsaurus-client using pip.

Detailed documentation can be found here.

How to build and develop python libraries

In this README we will be assuming you are not root.

Preparation and installation

We suppose that you use venv for python playground: how to install it.

Let call project checkout directory as <source_root> and project build directory as <build_root>.

export SOURCE_ROOT=<source_root>
export BUILD_ROOT=<build_root>

To work with ytsaurus python libraries you should prepare environment and modules:

  1. Build native libraries presented by cmake targets yson_lib, driver_lib, driver_rpc_lib
cd "$BUILD_ROOT" && ninja yson_lib driver_lib driver_rpc_lib
  1. Create directory to store prepared modules, let call it <ytsaurus_python>
mkdir "$YTSAURUS_PYTHON"
  1. Install wheel package pip3 install wheel

  2. Install yt_setup package in editable mode, this library provide instruments to prepare modules layout.

cd "$SOURCE_ROOT" && pip install -e yt/python/packages
  1. Run generate_python_proto to build proto modules (it requires protoc to be installed, see build instruction).
generate_python_proto --source-root "$SOURCE_ROOT" --output "$YTSAURUS_PYTHON"`
  1. Run prepare_python_modules to prepare all python modules
prepare_python_modules --source-root "$SOURCE_ROOT" --build-root "$BUILD_ROOT" --output-path "$YTSAURUS_PYTHON" --prepare-bindings-libraries`

After that ytsaurus python libraries can be used by adding <ytsaurus_python> to PYTHONPATH.

Packaging

To build package you need to copy setup.py from yt/python/packages/<package_name>/ to the <ytsaurus_python> and run setup script.

For pure python libraries (ytsaurus-client, ytsaurus-local) you should run python3 setup.py bdist_wheel --universal, for binary libraries (ytsaurus-yson, ytsaurus-rpc-driver) you should run python3 setup.py bdist_wheel --py-limited-api cp34

You will find wheel files .whl files in $YTSAURUS_PYTHON/dist directory, alternatively you can specify --dist-dir option.