Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from setuptools import setup, find_packages
- import os
- import pathlib
- import glob
- from setuptools.command.build_py import build_py as _build_py
- from pkg_resources import resource_filename
- MODULE_NAME = "autogen-test-repo"
- PYTHON_DIR = '.'
- INCLUDE_PATH = 'include/testlib'
- REGISTERS = {
- __name__: [
- 'test_build_py/test_regset_pd.yml',
- ]
- }
- class BuildPyCommand(_build_py):
- """Custom build_py command which runs autogen."""
- user_options = _build_py.user_options
- registers = REGISTERS
- # def find_data_files(self, package, src_dir):
- # orig_files = _build_py.find_data_files(self, package, src_dir)
- # return orig_files
- def run(self):
- cwd = pathlib.Path().absolute()
- build_lib = pathlib.Path(self.build_lib)
- if not build_lib.exists():
- build_lib.mkdir(parents=True)
- if self.registers:
- for pkg, srcs in self.registers.items():
- for src in srcs:
- command = ['autogen_register']
- command.extend(['-b', 'axil'])
- reg_source = resource_filename(pkg, src)
- abs_reg_source = os.path.abspath(reg_source)
- command.extend(['-s', abs_reg_source])
- os.chdir(self.build_lib)
- # command must be run in the output dir
- self.spawn(command)
- os.chdir(str(cwd))
- _build_py.run(self)
- setup(
- name=MODULE_NAME,
- author='Me',
- author_email="me@example.com",
- description="Autogen Test Repo",
- url="",
- license='Proprietary',
- classifiers=[
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 2.7",
- "License :: OTHER/PROPRIETARY LICENSE",
- "Operating System :: POSIX",
- "Private :: Do Not Upload to public pypi server",
- ],
- setup_requires=['setuptools_scm'],
- install_requires=[
- ],
- extras_require={
- 'test': [
- 'pytest>=4.0.0',
- 'pytest-timeout',
- ],
- },
- include_package_data=True,
- packages=find_packages(PYTHON_DIR, exclude=['*.tests']),
- data_files=[
- (INCLUDE_PATH, glob.glob('c_includes/*.h')),
- ],
- cmdclass={
- 'build_py': BuildPyCommand,
- },
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement