staran 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,109 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- 简化的C扩展编译脚本
6
- 使用Python的setuptools来处理复杂的链接问题
7
- """
8
-
9
- from setuptools import setup, Extension
10
- import platform
11
- import os
12
- import sys
13
-
14
- def get_extension_name():
15
- """获取平台特定的扩展名"""
16
- system = platform.system().lower()
17
- if system == 'darwin':
18
- return 'date_utils_macos'
19
- elif system == 'linux':
20
- return 'date_utils_linux'
21
- elif system == 'windows':
22
- return 'date_utils_windows'
23
- else:
24
- return 'date_utils'
25
-
26
- def main():
27
- print(f"🔨 Python setuptools 编译器")
28
- print(f"平台: {platform.system()} {platform.machine()}")
29
- print(f"Python: {platform.python_version()}")
30
-
31
- extension_name = get_extension_name()
32
- print(f"目标模块: {extension_name}")
33
-
34
- # 定义扩展
35
- extension = Extension(
36
- extension_name,
37
- sources=['date_utils.c'],
38
- extra_compile_args=['-O3', '-std=c99'] if platform.system() != 'Windows' else ['/O2'],
39
- )
40
-
41
- # 编译
42
- setup(
43
- name=extension_name,
44
- version='1.0.0',
45
- ext_modules=[extension],
46
- zip_safe=False,
47
- script_args=['build_ext', '--inplace']
48
- )
49
-
50
- # 检查编译结果
51
- expected_files = []
52
- if platform.system() == 'Windows':
53
- expected_files.append(f'{extension_name}.pyd')
54
- else:
55
- expected_files.extend([
56
- f'{extension_name}.so',
57
- f'{extension_name}.cpython-*.so'
58
- ])
59
-
60
- print(f"\n🔍 检查编译结果...")
61
- found_file = None
62
- for pattern in expected_files:
63
- if '*' in pattern:
64
- import glob
65
- matches = glob.glob(pattern)
66
- if matches:
67
- found_file = matches[0]
68
- break
69
- elif os.path.exists(pattern):
70
- found_file = pattern
71
- break
72
-
73
- if found_file:
74
- print(f"✅ 编译成功: {found_file}")
75
-
76
- # 快速测试
77
- print(f"🧪 快速测试...")
78
- try:
79
- # 临时添加当前目录到路径
80
- if '.' not in sys.path:
81
- sys.path.insert(0, '.')
82
-
83
- module = __import__(extension_name)
84
- print(f"✅ 模块导入成功")
85
-
86
- # 测试基本功能
87
- today = module.get_today()
88
- print(f"当前日期: {today}")
89
-
90
- timestamp = module.date_to_timestamp(2024, 6, 15)
91
- print(f"时间戳测试: {timestamp}")
92
-
93
- platform_info = module.get_platform_info()
94
- print(f"平台信息: {platform_info}")
95
-
96
- print(f"🎉 所有测试通过!")
97
-
98
- except Exception as e:
99
- print(f"❌ 测试失败: {e}")
100
- return False
101
- else:
102
- print(f"❌ 编译失败:找不到输出文件")
103
- return False
104
-
105
- return True
106
-
107
- if __name__ == '__main__':
108
- success = main()
109
- sys.exit(0 if success else 1)