97 lines
2.5 KiB
Python
97 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
RustFS S3 Storage Toolkit 安装脚本
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def run_command(command, description):
|
|
"""运行命令并显示结果"""
|
|
print(f"🔧 {description}...")
|
|
try:
|
|
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
|
print(f"✅ {description}成功")
|
|
return True
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"❌ {description}失败: {e}")
|
|
if e.stdout:
|
|
print(f"输出: {e.stdout}")
|
|
if e.stderr:
|
|
print(f"错误: {e.stderr}")
|
|
return False
|
|
|
|
|
|
def main():
|
|
"""主安装流程"""
|
|
print("🚀 RustFS S3 Storage Toolkit 安装脚本")
|
|
print("=" * 50)
|
|
|
|
# 检查 Python 版本
|
|
if sys.version_info < (3, 9):
|
|
print("❌ 需要 Python 3.9 或更高版本")
|
|
sys.exit(1)
|
|
|
|
print(f"✅ Python 版本: {sys.version}")
|
|
|
|
# 检查当前目录
|
|
current_dir = Path.cwd()
|
|
if not (current_dir / "pyproject.toml").exists():
|
|
print("❌ 请在项目根目录运行此脚本")
|
|
sys.exit(1)
|
|
|
|
print(f"✅ 项目目录: {current_dir}")
|
|
|
|
# 安装包
|
|
install_commands = [
|
|
("pip install -e .", "安装 RustFS S3 Storage Toolkit"),
|
|
]
|
|
|
|
for command, description in install_commands:
|
|
if not run_command(command, description):
|
|
print(f"❌ 安装失败,请检查错误信息")
|
|
sys.exit(1)
|
|
|
|
# 验证安装
|
|
print("\n🧪 验证安装...")
|
|
try:
|
|
from rustfs_s3_toolkit import S3StorageToolkit
|
|
print("✅ S3StorageToolkit 导入成功")
|
|
|
|
# 显示版本信息
|
|
import rustfs_s3_toolkit
|
|
print(f"✅ 版本: {rustfs_s3_toolkit.__version__}")
|
|
|
|
except ImportError as e:
|
|
print(f"❌ 导入失败: {e}")
|
|
sys.exit(1)
|
|
|
|
print("\n🎉 安装完成!")
|
|
print("\n📖 使用方法:")
|
|
print("1. 查看示例: python examples/basic_usage.py")
|
|
print("2. 运行测试: python tests/test_toolkit.py")
|
|
print("3. 查看文档: cat README.md")
|
|
|
|
print("\n💡 快速开始:")
|
|
print("""
|
|
from rustfs_s3_toolkit import S3StorageToolkit
|
|
|
|
toolkit = S3StorageToolkit(
|
|
endpoint_url="https://your-rustfs-endpoint.com",
|
|
access_key_id="your-key",
|
|
secret_access_key="your-secret",
|
|
bucket_name="your-bucket"
|
|
)
|
|
|
|
# 测试连接
|
|
result = toolkit.test_connection()
|
|
print(result)
|
|
""")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|