setup.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import sys
  2. import shutil
  3. import os
  4. from Cython.Build import cythonize
  5. from setuptools import setup
  6. from setuptools.extension import Extension
  7. def copyfile(src, dst):
  8. if not src.lower().endswith('.py'):
  9. try:
  10. shutil.copyfile(src, dst, follow_symlinks=True)
  11. except shutil.SameFileError:
  12. pass
  13. return
  14. with open(src, 'r', encoding='utf8') as inf, open(dst, 'w', encoding='utf8') as outf:
  15. for line in inf.readlines():
  16. if line.startswith('from lc18report_dev'):
  17. outf.write(line.replace(
  18. 'from lc18report_dev', 'from lc18report'))
  19. continue
  20. outf.write(line)
  21. def copy_src():
  22. root_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src')
  23. src_dir = os.path.join(root_dir, 'lc18report_dev')
  24. dst_dir = os.path.join(root_dir, 'lc18report')
  25. os.makedirs(dst_dir, exist_ok=True)
  26. for root, subdirs, files in os.walk(src_dir):
  27. dst_root = root.replace(src_dir, dst_dir)
  28. for subdir in subdirs:
  29. dst_subdir = os.path.join(dst_root, subdir)
  30. os.makedirs(dst_subdir, exist_ok=True)
  31. for file in files:
  32. file_dst = file
  33. need_compile = file.endswith('.py') and file != '__init__.py'
  34. if need_compile:
  35. file_dst = file.replace('.py', '.pyx')
  36. src = os.path.join(root, file)
  37. dst = os.path.join(dst_root, file_dst)
  38. copyfile(src, dst)
  39. def clean_up():
  40. root_dir = os.path.dirname(os.path.abspath(__file__))
  41. src_dir = os.path.join(root_dir, 'src', 'lc18report')
  42. build_dir = os.path.join(root_dir, 'build')
  43. egg_info_dir = os.path.join(root_dir, 'lc18report.egg-info')
  44. shutil.rmtree(src_dir, ignore_errors=True)
  45. shutil.rmtree(build_dir, ignore_errors=True)
  46. shutil.rmtree(egg_info_dir, ignore_errors=True)
  47. copy_src()
  48. setup(
  49. name='lc18report',
  50. version='0.7.21',
  51. description='Reporting Program for CarrierGene Lung Cancer 18-gene panel',
  52. author='CarrierGene.IVDg',
  53. author_email='rui.li@nuprobe.com',
  54. packages=['lc18report'],
  55. package_dir={'lc18report': 'src/lc18report'},
  56. package_data={
  57. 'lc18report': [
  58. 'template/report_template_v*.conf',
  59. 'template/report_template_v*.docx',
  60. 'template/yuedong_template_v*.conf',
  61. 'template/yuedong_template_v*.docx',
  62. ],
  63. },
  64. install_requires=[
  65. 'pycryptodomex>=3.11.0',
  66. 'python-docx>=0.8.11',
  67. 'pandas>=1.3.1',
  68. 'PyYAML>=5.4.1',
  69. 'openpyxl>=3.0.7',
  70. 'xlrd>=2.0.1',
  71. 'packaging>=21.3',
  72. 'matplotlib>=3.5.1',
  73. ],
  74. python_requires='>=3.6',
  75. entry_points='''
  76. [console_scripts]
  77. lc18=lc18report.main:main
  78. ''',
  79. ext_modules=cythonize(
  80. [Extension("lc18report.*", ["src/lc18report/*.pyx"])],
  81. language_level="3"
  82. ),
  83. )
  84. clean_up()