setup.py 1.11 KB
Newer Older
Janis Streib's avatar
INIT  
Janis Streib committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from setuptools import setup
from distutils.command.build_py import build_py
import subprocess
import os
import py_compile

class APIGenBuild(build_py):
    def run(self):
        gen = subprocess.run(['net-api-generator', 'python'], check=True, capture_output=True)
        if not self.dry_run:
            target_dir = os.path.join(self.build_lib, 'netdb_client_lib')
            self.mkpath(target_dir)

            with open(os.path.join(target_dir, 'model.py'), 'wb') as fobj:
                fobj.write(gen.stdout)
                py_compile.compile(os.path.join(target_dir, 'model.py'))
        build_py.run(self)
        
        
setup(
    name='netdb_client_lib',
    version='1.0',
    author='Dr. Meta',
    description='This is a meta package to install the automatically generated NET-API 3.0 definitions.',
    install_requires=['net_api_generator @ git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master'],
    setup_requires=['net_api_generator @ git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master'],
    packages=['netdb_client_lib'],
    cmdclass={'build_py': APIGenBuild}
)