__init__.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import os
  2. from devtools.yamaker.fileutil import re_sub_file
  3. from devtools.yamaker.project import NixProject
  4. from devtools.yamaker import python
  5. def post_install(self):
  6. dist_files = python.extract_dist_info(self)
  7. re_sub_file(
  8. f"{self.dstdir}/cython.py",
  9. r"# Change content of this file to change uids for cython programs - cython.*",
  10. rf"# Change content of this file to change uids for cython programs - cython {self.version} r0",
  11. )
  12. self.yamakes.clear()
  13. self.yamakes["."] = self.module(
  14. module="PY3_LIBRARY",
  15. NO_LINT=True,
  16. RESOURCE_FILES=python.prepare_resource_files(self, *dist_files),
  17. )
  18. for path, dirs, files in os.walk(self.dstdir):
  19. for file in files:
  20. if file.endswith(".c"):
  21. file = f"{path}/{file}"
  22. with open(file) as f:
  23. first_line = f.readline()
  24. if first_line.startswith("/* Generated by Cython"):
  25. os.remove(file)
  26. cython = NixProject(
  27. owners=["g:python-contrib"],
  28. arcdir="contrib/tools/cython",
  29. nixattr=python.make_nixattr("cython"),
  30. copy_sources=["Cython/", "cygdb.py", "cython.py"],
  31. keep_paths=[
  32. "Cython/Includes/numpy.pxd",
  33. "Cython/Utility/CommonTypes.c",
  34. "Cython/ya.make",
  35. "generated_c_headers.h",
  36. "generated_cpp_headers.h",
  37. ],
  38. post_install=post_install,
  39. )