import os
import pathlib
import subprocess
from configparser import ConfigParser
import setuptools
config = ConfigParser()
config.read('./torch_tb_profiler/config/config.ini')
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, rel_path)) as fp:
return fp.read()
def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
version = line.split(delim)[1]
if os.getenv('TORCH_TB_PROFILER_BUILD_VERSION'):
version = os.getenv('TORCH_TB_PROFILER_BUILD_VERSION')
return version
INSTALL_REQUIRED = [
"pandas >= 1.0.0",
"tensorboard >= 2.11.0"
]
TESTS_REQUIRED = INSTALL_REQUIRED + [
"torch >= 1.8",
"torchvision >= 0.8"
]
EXTRAS = {
"s3": ["boto3"],
"blob": ["azure-storage-blob"],
"gs": ["google-cloud-storage"]
}
class build_fe(setuptools.Command):
"""Build the frontend"""
description = "run yarn build on frontend directory"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
cwd = pathlib.Path().absolute()
root = pathlib.Path(__file__).parent.absolute()
os.chdir(root / "fe")
subprocess.run(["yarn", "build:copy"], check=True)
os.chdir(cwd)
setuptools.setup(
name="torch-tb-profiler-ascend",
version=get_version(os.path.join('torch_tb_profiler', '__init__.py')),
description="PyTorch Ascend Profiler TensorBoard Plugin",
long_description=f"PyTorch Ascend Profiler TensorBoard Plugin: {config.get('URL', 'repository_url')}",
url=config.get('URL', 'repository_url'),
author="Ascend Team",
author_email=config.get('EMAIL', 'author_email'),
cmdclass={
"build_fe": build_fe
},
packages=setuptools.find_packages(),
package_data={
"torch_tb_profiler": ["static/**", "config/**"],
},
entry_points={
"tensorboard_plugins": [
"torch_profiler = torch_tb_profiler.plugin:TorchProfilerPlugin",
],
},
python_requires=">=3.6.2",
install_requires=INSTALL_REQUIRED,
tests_require=TESTS_REQUIRED,
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
license='BSD-3',
keywords='pytorch tensorboard profile plugin',
extras_require=EXTRAS
)