from setuptools import setup
from setuptools.command.install import install
import subprocess
import os
import re
from packaging.tags import sys_tags
import os

tag = next(sys_tags())

class CustomInstall(install):
    def run(self):
        install.run(self)
        # 安装路径 = site-packages
        install_dir = os.path.abspath(self.install_lib)
        src = os.path.join("lib64", "mstx.so")
        dst = os.path.join(install_dir, "mstx.so")
        src_abs = os.path.join(install_dir, src)
        if os.path.exists(dst) or os.path.islink(dst):
            os.unlink(dst)
        rel_src = os.path.relpath(src_abs, install_dir)
        os.symlink(rel_src, dst)

setup(
    name = 'mstx',
    version = os.environ.get('WHL_VERSION', '26.0.0'),
    author =' mstx',
    author_email = 'mstx',
    description = 'mstx',
    long_description = open('README.md', encoding='utf-8').read(),
    long_description_content_type = 'text/markdown',
    url = 'https://gitcode.com/Ascend/mstx',
    options={
        'bdist_wheel':{
            'plat_name': tag.platform}},
    packages = ['lib64', 'include'],
    cmdclass={"install": CustomInstall},
    include_package_data = True,
    license= 'MIT',
    classifiers = [
        'Programming Language :: Python :: 3',
        'Operating System :: Linux',
    ],
    python_requires = '>=3.7'
)