Difficult-Rocket/libs/Difficult_Rocket_rs/setup.py

57 lines
1.7 KiB
Python
Raw Normal View History

2023-01-20 18:31:05 +08:00
# -------------------------------
# Difficult Rocket
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
import os
2023-01-20 20:20:35 +08:00
import sys
2023-01-20 18:31:05 +08:00
import shutil
import warnings
from setuptools import setup
from setuptools_rust import Binding, RustExtension
2023-01-20 20:20:35 +08:00
sys.path.append('../../')
if '../../' in sys.path:
from Difficult_Rocket import DR_option
package_path = 'Difficult_Rocket_rs'
2023-01-20 18:31:05 +08:00
setup(
name='Difficult_Rocket_rs',
version='0.0.0.1',
2023-01-20 20:20:35 +08:00
author='shenjackyuanjie',
author_email='3695888@qq.com',
license='CC BY-NC-SA 4.0',
2023-01-20 18:31:05 +08:00
rust_extensions=[RustExtension(target="Difficult_Rocket_rs.Difficult_Rocket_rs",
2023-01-20 20:20:35 +08:00
# rust_version='2021',
2023-01-20 18:31:05 +08:00
binding=Binding.PyO3)],
packages=[package_path],
zip_safe=False
)
lib_path = './lib'
build_path = './build'
2023-01-20 20:20:35 +08:00
if 'clean' in sys.argv:
shutil.rmtree(lib_path, ignore_errors=True)
shutil.rmtree(build_path, ignore_errors=True)
sys.exit(0)
2023-01-20 18:31:05 +08:00
if not os.path.exists(lib_path):
os.mkdir(lib_path)
builds = os.listdir(build_path)
for build_dir in builds:
if not os.path.exists(os.path.join(build_path, build_dir, package_path)):
warnings.warn(f'package not found at {build_path}/{build_dir}')
continue
for file in os.listdir(os.path.join(build_path, build_dir, package_path)):
shutil.copy(os.path.join(build_path, build_dir, package_path, file), os.path.join(lib_path, file))
2023-01-20 20:20:35 +08:00
shutil.rmtree(os.path.join(build_path, build_dir))
# print(os.path.join(build_path, build_dir))
for package_file in os.listdir(package_path):
shutil.copy(os.path.join(package_path, package_file), os.path.join(lib_path, package_file))