staran 0.1.0__py3-none-any.whl → 0.1.2__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.
tools/date/__init__.py DELETED
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- Date模块 - 高性能日期处理工具
6
- 支持C扩展加速和跨平台兼容
7
- """
8
-
9
- from .date import Date
10
- from .platform_utils import (
11
- get_today,
12
- date_to_timestamp,
13
- days_between,
14
- is_leap_year_c,
15
- has_c_extension,
16
- get_platform_info,
17
- PlatformDateUtils
18
- )
19
-
20
- # 导出主要类和函数
21
- __all__ = [
22
- 'Date',
23
- 'get_today',
24
- 'date_to_timestamp',
25
- 'days_between',
26
- 'is_leap_year_c',
27
- 'has_c_extension',
28
- 'get_platform_info',
29
- 'PlatformDateUtils'
30
- ]
31
-
32
- # 模块信息
33
- __version__ = '1.0.0'
34
- __author__ = 'Staran Team'
35
- __description__ = 'High-performance date processing with C extension support'
36
-
37
- # 便捷访问
38
- def create_date(*args, **kwargs):
39
- """便捷的日期创建函数"""
40
- return Date(*args, **kwargs)
41
-
42
- def today():
43
- """快速获取今日日期"""
44
- return Date()
45
-
46
- def from_string(date_string):
47
- """从字符串创建日期"""
48
- return Date(date_string)
49
-
50
- def from_timestamp(timestamp):
51
- """从时间戳创建日期(需要先实现该功能)"""
52
- import datetime
53
- dt = datetime.datetime.fromtimestamp(timestamp)
54
- return Date(dt.year, dt.month, dt.day)
55
-
56
- # 检查C扩展状态并显示信息
57
- if has_c_extension():
58
- print("✅ Date模块已加载,C扩展可用")
59
- else:
60
- print("⚠️ Date模块已加载,使用Python备用实现")
@@ -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)