summaryrefslogtreecommitdiffstats
path: root/build/plugins/create_init_py.py
blob: 69d17c2fd605e3e092069ae3220df1267975945c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os

from ymake import macro, Unit


@macro
def CREATE_INIT_PY_STRUCTURE(unit: Unit, *args: tuple[str, ...]):
    if unit.get('DISTBUILD') or unit.get('AUTOCHECK'):
        return
    target_dir = unit.get('PY_PROTOS_FOR_DIR')
    path_list = target_dir.split(os.path.sep)[1:]
    inits = [os.path.join("${ARCADIA_BUILD_ROOT}", '__init__.py')]
    for i in range(1, len(path_list) + 1):
        inits.append(os.path.join("${ARCADIA_BUILD_ROOT}", os.path.join(*path_list[0:i]), '__init__.py'))
    unit.ontouch(inits)