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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
import os
import shutil
from devtools.yamaker.arcpath import ArcPath
from devtools.yamaker.modules import py_srcs, Linkable, Switch
from devtools.yamaker.project import NixProject
from devtools.yamaker import python
def post_install(self):
python.extract_dist_info(self)
# pypi archive with grpcio contains cpp core and python files
# Python files in this archive are located in src/python/grpcio
# In order to exclude additional PEERDIR usage in Arcadia
# let's move src/python/grpcio content directly to contrib/python/grpcio/py3
python_source_location = os.path.join(self.dstdir, "src/python/grpcio")
grpcio_files = os.listdir(python_source_location)
# move all files to root
for elem in grpcio_files:
shutil.move(os.path.join(python_source_location, elem), self.dstdir)
# remove unnecessary folder src
shutil.rmtree(os.path.join(self.dstdir, "src"))
# Collect python files but remove files for pypi build and
# yamaker related files
with self.yamakes["."] as pb:
py_src_common = py_srcs(
self.dstdir,
remove=[
".yandex_meta/__init__.py", # yamaker settings
"grpc_core_dependencies.py",
"support.py",
"commands.py",
"_spawn_patch.py",
"_parallel_compile_patch.py",
"grpc_version.py",
],
)
pb.to_py_library(
module="PY3_LIBRARY",
PY_SRCS=py_src_common,
PEERDIR=["contrib/libs/grpc", "contrib/python/six"],
ADDINCL=[
"${ARCADIA_BUILD_ROOT}/contrib/libs/grpc",
"contrib/libs/grpc",
"contrib/libs/grpc/include",
ArcPath("contrib/python/grpcio/py3", FOR="cython"),
],
)
# Function pointer is not sanitized for ubsan.
# This decision has been done in original grpc repo.
# see https://github.com/grpc/grpc/blob/v1.45.0/tools/bazel.rc#L103
pb.after(
"ADDINCL",
Switch({"SANITIZER_TYPE == undefined": Linkable(CXXFLAGS=["-fno-sanitize=function"])}),
)
grpcio = NixProject(
owners=["g:python-contrib"],
projects=["python/grpcio"],
arcdir="contrib/python/grpcio/py3",
nixattr=python.make_nixattr("grpcio"),
ignore_targets=[
"cygrpc.cpython-310-x86_64-linux-gnu",
],
copy_sources=[
"src/python/grpcio/**/*.py",
"src/python/grpcio/**/*.pxi",
"src/python/grpcio/**/*.pxd",
"src/python/grpcio/**/*.pyx",
],
post_install=post_install,
)
|