45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
# -------------------------------
|
|
# Difficult Rocket
|
|
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
# All rights reserved
|
|
# -------------------------------
|
|
import os
|
|
import shutil
|
|
import warnings
|
|
import traceback
|
|
|
|
package_path = 'Difficult_Rocket_rs'
|
|
lib_path = '../lib'
|
|
build_path = 'build'
|
|
|
|
if not os.path.exists(lib_path):
|
|
os.mkdir(lib_path)
|
|
|
|
builds = os.listdir(build_path)
|
|
print(os.path.abspath('.'))
|
|
|
|
try:
|
|
shutil.copy('src/__init__.py', os.path.join(lib_path, '__init__.py'))
|
|
except shutil.SameFileError:
|
|
traceback.print_exc()
|
|
|
|
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)):
|
|
# file_name = os.path.join(lib_path, file.replace(package_path, f'{package_path}.{DR_runtime.DR_Rust_version}'))
|
|
file_name = os.path.join(lib_path, file)
|
|
shutil.rmtree(file_name, ignore_errors=True)
|
|
try:
|
|
shutil.copy(os.path.join(build_path, build_dir, package_path, file), file_name)
|
|
except (shutil.SameFileError, PermissionError):
|
|
# print(os.path.exists(os.path))
|
|
print(os.listdir(lib_path))
|
|
traceback.print_exc()
|
|
continue
|
|
# os.remove(file_name)
|
|
# shutil.copy(os.path.join(build_path, build_dir, package_path, file), file_name)
|
|
# shutil.rmtree(os.path.join(build_path, build_dir))
|
|
# print(os.path.join(build_path, build_dir))
|