__init__.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import os
  2. import shutil
  3. from devtools.yamaker.arcpath import ArcPath
  4. from devtools.yamaker.modules import py_srcs, Linkable, Switch
  5. from devtools.yamaker.project import NixProject
  6. from devtools.yamaker import python
  7. def post_install(self):
  8. python.extract_dist_info(self)
  9. # pypi archive with grpcio contains cpp core and python files
  10. # Python files in this archive are located in src/python/grpcio
  11. # In order to exclude additional PEERDIR usage in Arcadia
  12. # let's move src/python/grpcio content directly to contrib/python/grpcio/py3
  13. python_source_location = os.path.join(self.dstdir, "src/python/grpcio")
  14. grpcio_files = os.listdir(python_source_location)
  15. # move all files to root
  16. for elem in grpcio_files:
  17. shutil.move(os.path.join(python_source_location, elem), self.dstdir)
  18. # remove unnecessary folder src
  19. shutil.rmtree(os.path.join(self.dstdir, "src"))
  20. # Collect python files but remove files for pypi build and
  21. # yamaker related files
  22. with self.yamakes["."] as pb:
  23. py_src_common = py_srcs(
  24. self.dstdir,
  25. remove=[
  26. ".yandex_meta/__init__.py", # yamaker settings
  27. "grpc_core_dependencies.py",
  28. "support.py",
  29. "commands.py",
  30. "_spawn_patch.py",
  31. "_parallel_compile_patch.py",
  32. "grpc_version.py",
  33. ],
  34. )
  35. pb.to_py_library(
  36. module="PY3_LIBRARY",
  37. PY_SRCS=py_src_common,
  38. PEERDIR=["contrib/libs/grpc", "contrib/python/six"],
  39. ADDINCL=[
  40. "${ARCADIA_BUILD_ROOT}/contrib/libs/grpc",
  41. "contrib/libs/grpc",
  42. "contrib/libs/grpc/include",
  43. ArcPath("contrib/python/grpcio/py3", FOR="cython"),
  44. ],
  45. )
  46. # Function pointer is not sanitized for ubsan.
  47. # This decision has been done in original grpc repo.
  48. # see https://github.com/grpc/grpc/blob/v1.45.0/tools/bazel.rc#L103
  49. pb.after(
  50. "ADDINCL",
  51. Switch({"SANITIZER_TYPE == undefined": Linkable(CXXFLAGS=["-fno-sanitize=function"])}),
  52. )
  53. grpcio = NixProject(
  54. owners=["g:python-contrib"],
  55. projects=["python/grpcio"],
  56. arcdir="contrib/python/grpcio/py3",
  57. nixattr=python.make_nixattr("grpcio"),
  58. ignore_targets=[
  59. "cygrpc.cpython-310-x86_64-linux-gnu",
  60. ],
  61. copy_sources=[
  62. "src/python/grpcio/**/*.py",
  63. "src/python/grpcio/**/*.pxi",
  64. "src/python/grpcio/**/*.pxd",
  65. "src/python/grpcio/**/*.pyx",
  66. ],
  67. post_install=post_install,
  68. )