aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/.yandex_meta/__init__.py
blob: 3155ec718b875d50370cf9b7450e9ef0d2eebb58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os

from devtools.yamaker.fileutil import re_sub_file
from devtools.yamaker.project import NixProject
from devtools.yamaker import python


def post_install(self):
    dist_files = python.extract_dist_info(self)

    re_sub_file(
        f"{self.dstdir}/cython.py",
        r"# Change content of this file to change uids for cython programs - cython.*",
        rf"# Change content of this file to change uids for cython programs - cython {self.version} r0",
    )

    self.yamakes.clear()
    self.yamakes["."] = self.module(
        module="PY3_LIBRARY",
        NO_LINT=True,
        RESOURCE_FILES=python.prepare_resource_files(self, *dist_files),
    )

    for path, dirs, files in os.walk(self.dstdir):
        for file in files:
            if file.endswith(".c"):
                file = f"{path}/{file}"
                with open(file) as f:
                    first_line = f.readline()
                if first_line.startswith("/* Generated by Cython"):
                    os.remove(file)


cython = NixProject(
    owners=["g:python-contrib"],
    arcdir="contrib/tools/cython",
    nixattr=python.make_nixattr("cython"),
    copy_sources=["Cython/", "cygdb.py", "cython.py"],
    keep_paths=[
        "Cython/Includes/numpy.pxd",
        "Cython/Utility/CommonTypes.c",
        "Cython/ya.make",
        "generated_c_headers.h",
        "generated_cpp_headers.h",
    ],
    post_install=post_install,
)