Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from setuptools import setup, find_packages
  5. import os
  6. import pathlib
  7. import glob
  8.  
  9. from setuptools.command.build_py import build_py as _build_py
  10. from pkg_resources import resource_filename
  11.  
  12. MODULE_NAME = "autogen-test-repo"
  13.  
  14. PYTHON_DIR = '.'
  15.  
  16. INCLUDE_PATH = 'include/testlib'
  17.  
  18. REGISTERS = {
  19.     __name__: [
  20.         'test_build_py/test_regset_pd.yml',
  21.     ]
  22. }
  23.  
  24.  
  25. class BuildPyCommand(_build_py):
  26.     """Custom build_py command which runs autogen."""
  27.     user_options = _build_py.user_options
  28.     registers = REGISTERS
  29.  
  30.     # def find_data_files(self, package, src_dir):
  31.     #     orig_files = _build_py.find_data_files(self, package, src_dir)
  32.     #     return orig_files
  33.  
  34.     def run(self):
  35.         cwd = pathlib.Path().absolute()
  36.         build_lib = pathlib.Path(self.build_lib)
  37.  
  38.         if not build_lib.exists():
  39.             build_lib.mkdir(parents=True)
  40.  
  41.         if self.registers:
  42.             for pkg, srcs in self.registers.items():
  43.                 for src in srcs:
  44.                     command = ['autogen_register']
  45.                     command.extend(['-b', 'axil'])
  46.                     reg_source = resource_filename(pkg, src)
  47.                     abs_reg_source = os.path.abspath(reg_source)
  48.                     command.extend(['-s', abs_reg_source])
  49.                     os.chdir(self.build_lib)
  50.                     # command must be run in the output dir
  51.                     self.spawn(command)
  52.                     os.chdir(str(cwd))
  53.  
  54.         _build_py.run(self)
  55.  
  56.  
  57. setup(
  58.     name=MODULE_NAME,
  59.     author='Me',
  60.     author_email="me@example.com",
  61.     description="Autogen Test Repo",
  62.     url="",
  63.     license='Proprietary',
  64.     classifiers=[
  65.         "Programming Language :: Python :: 3",
  66.         "Programming Language :: Python :: 2.7",
  67.         "License :: OTHER/PROPRIETARY LICENSE",
  68.         "Operating System :: POSIX",
  69.         "Private :: Do Not Upload to public pypi server",
  70.     ],
  71.     setup_requires=['setuptools_scm'],
  72.     install_requires=[
  73.     ],
  74.     extras_require={
  75.         'test': [
  76.             'pytest>=4.0.0',
  77.             'pytest-timeout',
  78.         ],
  79.     },
  80.     include_package_data=True,
  81.     packages=find_packages(PYTHON_DIR, exclude=['*.tests']),
  82.     data_files=[
  83.         (INCLUDE_PATH, glob.glob('c_includes/*.h')),
  84.     ],
  85.     cmdclass={
  86.         'build_py': BuildPyCommand,
  87.     },
  88. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement