ipa-python-kit 0.1.1__tar.gz → 0.1.2__tar.gz

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.
Files changed (122) hide show
  1. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/.gitignore +4 -1
  2. ipa_python_kit-0.1.2/.vscode/settings.json +22 -0
  3. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/PKG-INFO +30 -8
  4. ipa_python_kit-0.1.2/README.md +44 -0
  5. ipa_python_kit-0.1.2/alembic/README +1 -0
  6. ipa_python_kit-0.1.2/alembic/env.py +82 -0
  7. ipa_python_kit-0.1.2/alembic/script.py.mako +29 -0
  8. ipa_python_kit-0.1.2/alembic/versions/5227325b977d_baseline.py +34 -0
  9. ipa_python_kit-0.1.2/alembic.ini +149 -0
  10. ipa_python_kit-0.1.2/main.py +30 -0
  11. ipa_python_kit-0.1.2/main.spec +75 -0
  12. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/pyproject.toml +95 -113
  13. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/pytest.ini +1 -1
  14. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/ruff.toml +10 -9
  15. ipa_python_kit-0.1.2/scripts/build +3 -0
  16. ipa_python_kit-0.1.2/src/conf/__init__.py +50 -0
  17. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/ipa_python_kit.egg-info/PKG-INFO +30 -8
  18. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/ipa_python_kit.egg-info/SOURCES.txt +11 -1
  19. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/ipa_python_kit.egg-info/requires.txt +2 -0
  20. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/_version.py +3 -3
  21. ipa_python_kit-0.1.2/tests/subprocess_test/child.py +30 -0
  22. ipa_python_kit-0.1.2/tests/subprocess_test/pipe_test.py +81 -0
  23. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/uv.lock +5283 -5159
  24. ipa_python_kit-0.1.1/.vscode/settings.json +0 -21
  25. ipa_python_kit-0.1.1/README.md +0 -24
  26. ipa_python_kit-0.1.1/main.py +0 -3
  27. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/.pre-commit-config.yaml +0 -0
  28. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/.pypirc.example +0 -0
  29. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/docs/README.md +0 -0
  30. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/scripts/publish +0 -0
  31. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/scripts/setup +0 -0
  32. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/setup.cfg +0 -0
  33. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/biz/__init__.py +0 -0
  34. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/ipa_python_kit.egg-info/dependency_links.txt +0 -0
  35. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/ipa_python_kit.egg-info/top_level.txt +0 -0
  36. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/__init__.py +0 -0
  37. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/cli/__init__.py +0 -0
  38. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/cli/model.py +0 -0
  39. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/cli/proxy.py +0 -0
  40. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/cli/seaweedfs.py +0 -0
  41. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/ctx/__init__.py +0 -0
  42. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/__init__.py +0 -0
  43. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/_math.py +0 -0
  44. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/_queue.py +0 -0
  45. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/base.py +0 -0
  46. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/config.py +0 -0
  47. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/container.py +0 -0
  48. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/echarts.py +0 -0
  49. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/exception.py +0 -0
  50. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/handler.py +0 -0
  51. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/lifecycle.py +0 -0
  52. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/net.py +0 -0
  53. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/notice.py +0 -0
  54. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/page.py +0 -0
  55. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/point.py +0 -0
  56. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/process.py +0 -0
  57. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/spatial.py +0 -0
  58. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/data_type/unitable.py +0 -0
  59. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/datetime/__init__.py +0 -0
  60. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/datetime/core.py +0 -0
  61. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/decorator/__init__.py +0 -0
  62. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/decorator/exception.py +0 -0
  63. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/echarts/__init__.py +0 -0
  64. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/echarts/core/__init__.py +0 -0
  65. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/extra/simpy/__init__.py +0 -0
  66. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/extra/simpy/core.py +0 -0
  67. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/fastapi/__init__.py +0 -0
  68. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/fastapi/core/__init__.py +0 -0
  69. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/__init__.py +0 -0
  70. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/_async.py +0 -0
  71. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/_lambda.py +0 -0
  72. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/_object.py +0 -0
  73. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/app.py +0 -0
  74. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/database.py +0 -0
  75. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/dict.py +0 -0
  76. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/num.py +0 -0
  77. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/shortcut.py +0 -0
  78. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/func/table.py +0 -0
  79. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/i18n/__init__.py +0 -0
  80. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/i18n/core.py +0 -0
  81. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/i18n/locales/__init__.py +0 -0
  82. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/io/__init__.py +0 -0
  83. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/io/buffer.py +0 -0
  84. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/__init__.py +0 -0
  85. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/builder.py +0 -0
  86. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/fmt.py +0 -0
  87. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/handler.py +0 -0
  88. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/model/__init__.py +0 -0
  89. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/model/dict_config.py +0 -0
  90. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/logger/util.py +0 -0
  91. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/math/__init__.py +0 -0
  92. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/math/core.py +0 -0
  93. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/network/__init__.py +0 -0
  94. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/pkg/__init__.py +0 -0
  95. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/pkg/hot_reload.py +0 -0
  96. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/pydantic/__init__.py +0 -0
  97. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/pydantic/core/__init__.py +0 -0
  98. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/system/__init__.py +0 -0
  99. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/system/disk.py +0 -0
  100. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/system/process.py +0 -0
  101. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/visualization/__init__.py +0 -0
  102. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/visualization/_networkx.py +0 -0
  103. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/websocket/__init__.py +0 -0
  104. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/src/sdk/websocket/core/__init__.py +0 -0
  105. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/cli_test.py +0 -0
  106. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/ctx_test.py +0 -0
  107. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/data_type_test.py +0 -0
  108. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/datetime_test.py +0 -0
  109. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/decorator_test.py +0 -0
  110. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/echarts_test.py +0 -0
  111. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/fastapi_test.py +0 -0
  112. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/i18n_test.py +0 -0
  113. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/io_test.py +0 -0
  114. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/logger_test.py +0 -0
  115. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/math_test.py +0 -0
  116. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/network_test.py +0 -0
  117. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/point_test.py +0 -0
  118. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/pydantic_test.py +0 -0
  119. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/python_test.py +0 -0
  120. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/system_test.py +0 -0
  121. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/vis_test.py +0 -0
  122. {ipa_python_kit-0.1.1 → ipa_python_kit-0.1.2}/tests/websocket_test.py +0 -0
@@ -2,9 +2,12 @@
2
2
  logs
3
3
  dist
4
4
  build
5
+ data
5
6
  *.log
6
7
 
7
8
  **/*.egg-info
8
9
  .pypirc
9
10
 
10
- src/sdk/_version.py
11
+ src/sdk/_version.py
12
+
13
+ !scripts/**
@@ -0,0 +1,22 @@
1
+ {
2
+ "python.autoComplete.extraPaths": [
3
+ "${workspaceFolder}"
4
+ ],
5
+ // 用于语言服务分析(语法检查、跳转等)的路径
6
+ "python.analysis.extraPaths": [
7
+ "${workspaceFolder}"
8
+ ],
9
+ // // 确保终端中 PYTHONPATH 包含 src 目录,但实际上这种方式不通用
10
+ // // 终端中生效的 PYTHONPATH(可选,确保终端运行时也能识别)
11
+ // "terminal.integrated.env.windows": {
12
+ // "PYTHONPATH": "${workspaceFolder}/src;${workspaceFolder};${env:PYTHONPATH}"
13
+ // },
14
+ // "terminal.integrated.env.osx": {
15
+ // "PYTHONPATH": "${workspaceFolder}/src:${workspaceFolder}:${env:PYTHONPATH}"
16
+ // },
17
+ // "terminal.integrated.env.linux": {
18
+ // "PYTHONPATH": "${workspaceFolder}/src:${workspaceFolder}:${env:PYTHONPATH}"
19
+ // },
20
+ "python.envFile": "${workspaceFolder}/.env",
21
+ "jupyter.envFile": "${workspaceFolder}/.env"
22
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipa-python-kit
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: kit for python
5
5
  Author-email: xdewx <present150608@sina.com>
6
6
  Keywords: python,kit,lib,util
@@ -10,6 +10,7 @@ Requires-Dist: deprecated>=1.3.1
10
10
  Requires-Dist: pint>=0.21.1
11
11
  Requires-Dist: pydantic>=2.10.6
12
12
  Requires-Dist: pyhumps>=3.8.0
13
+ Requires-Dist: typer>=0.20.1
13
14
  Provides-Extra: system
14
15
  Requires-Dist: psutil>=7.2.1; extra == "system"
15
16
  Provides-Extra: i18n
@@ -27,6 +28,7 @@ Provides-Extra: visualization
27
28
  Requires-Dist: matplotlib>=3.7.5; extra == "visualization"
28
29
  Requires-Dist: pyecharts>=2.0.9; extra == "visualization"
29
30
  Provides-Extra: orm
31
+ Requires-Dist: alembic>=1.14.1; extra == "orm"
30
32
  Requires-Dist: sqlmodel>=0.0.29; extra == "orm"
31
33
  Provides-Extra: network
32
34
  Requires-Dist: networkx>=3.1; extra == "network"
@@ -50,18 +52,38 @@ Requires-Dist: simpy>=4.1.1; extra == "des"
50
52
  3. darker for code format
51
53
  4. ruff for lint
52
54
  5. commitlint for commit message format
55
+ 6. typer for cli
56
+ 7. sqlmodel for database ORM
57
+ 8. alembic for database migration
53
58
 
54
- ## 使用方式
59
+ ## introduction
55
60
 
56
- - 初始化环境:`./scripts/setup`
61
+ the project uses `src-layout`, includes `sdk` (for publish) and `biz` (for business logic).
62
+ `sdk` is designed for publish and no need to rename, we use file/folder mapping `mylib=src/sdk` in `pyproject.toml`.
57
63
 
58
- - 执行测试:`uv run -m pytest`
64
+ ### dev
59
65
 
60
- - 启动服务:`uv run main.py`
66
+ before you start:
61
67
 
62
- - 构建发布:`./scripts/publish`
68
+ 1. must run `./scripts/setup`
69
+ 1. just replace `mylib` with `[the name you want]` in the whole project
70
+ 1. remember to `uv pip install -e .[all]` to make sure `mylib` is available in development.
63
71
 
72
+ ### unit test
64
73
 
65
- ## TODO
74
+ `uv run -m pytest`
66
75
 
67
- - [ ] 处理自身与依赖的最低python版本要求关系
76
+ ### run cli
77
+
78
+ `uv run main.py --help`
79
+
80
+ ### release sdk
81
+
82
+ 1. `cp .pypirc.example .pypirc`
83
+ 2. replace your token in `.pypirc`
84
+ 3. `git tag vx.y.z`
85
+ 4. `./scripts/publish`
86
+
87
+ ### build executable file
88
+
89
+ `./scripts/build`
@@ -0,0 +1,44 @@
1
+ # pyproject-tmpl
2
+
3
+ ## features
4
+
5
+ 1. pytest
6
+ 2. pre-commit
7
+ 3. darker for code format
8
+ 4. ruff for lint
9
+ 5. commitlint for commit message format
10
+ 6. typer for cli
11
+ 7. sqlmodel for database ORM
12
+ 8. alembic for database migration
13
+
14
+ ## introduction
15
+
16
+ the project uses `src-layout`, includes `sdk` (for publish) and `biz` (for business logic).
17
+ `sdk` is designed for publish and no need to rename, we use file/folder mapping `mylib=src/sdk` in `pyproject.toml`.
18
+
19
+ ### dev
20
+
21
+ before you start:
22
+
23
+ 1. must run `./scripts/setup`
24
+ 1. just replace `mylib` with `[the name you want]` in the whole project
25
+ 1. remember to `uv pip install -e .[all]` to make sure `mylib` is available in development.
26
+
27
+ ### unit test
28
+
29
+ `uv run -m pytest`
30
+
31
+ ### run cli
32
+
33
+ `uv run main.py --help`
34
+
35
+ ### release sdk
36
+
37
+ 1. `cp .pypirc.example .pypirc`
38
+ 2. replace your token in `.pypirc`
39
+ 3. `git tag vx.y.z`
40
+ 4. `./scripts/publish`
41
+
42
+ ### build executable file
43
+
44
+ `./scripts/build`
@@ -0,0 +1 @@
1
+ Generic single-database configuration.
@@ -0,0 +1,82 @@
1
+ from logging.config import fileConfig
2
+
3
+ from sqlalchemy import engine_from_config, pool
4
+ from sqlmodel import SQLModel
5
+
6
+ from alembic import context
7
+ from conf import setup_alembic
8
+
9
+ # this is the Alembic Config object, which provides
10
+ # access to the values within the .ini file in use.
11
+ config = context.config
12
+
13
+ setup_alembic(config)
14
+
15
+ # Interpret the config file for Python logging.
16
+ # This line sets up loggers basically.
17
+ if config.config_file_name is not None:
18
+ fileConfig(config.config_file_name)
19
+
20
+
21
+ # add your model's MetaData object here
22
+ # for 'autogenerate' support
23
+ # from myapp import mymodel
24
+ # target_metadata = mymodel.Base.metadata
25
+ target_metadata = [
26
+ SQLModel.metadata,
27
+ ]
28
+
29
+ # other values from the config, defined by the needs of env.py,
30
+ # can be acquired:
31
+ # my_important_option = config.get_main_option("my_important_option")
32
+ # ... etc.
33
+
34
+
35
+ def run_migrations_offline() -> None:
36
+ """Run migrations in 'offline' mode.
37
+
38
+ This configures the context with just a URL
39
+ and not an Engine, though an Engine is acceptable
40
+ here as well. By skipping the Engine creation
41
+ we don't even need a DBAPI to be available.
42
+
43
+ Calls to context.execute() here emit the given string to the
44
+ script output.
45
+
46
+ """
47
+ url = config.get_main_option("sqlalchemy.url")
48
+ context.configure(
49
+ url=url,
50
+ target_metadata=target_metadata,
51
+ literal_binds=True,
52
+ dialect_opts={"paramstyle": "named"},
53
+ )
54
+
55
+ with context.begin_transaction():
56
+ context.run_migrations()
57
+
58
+
59
+ def run_migrations_online() -> None:
60
+ """Run migrations in 'online' mode.
61
+
62
+ In this scenario we need to create an Engine
63
+ and associate a connection with the context.
64
+
65
+ """
66
+ connectable = engine_from_config(
67
+ config.get_section(config.config_ini_section, {}),
68
+ prefix="sqlalchemy.",
69
+ poolclass=pool.NullPool,
70
+ )
71
+
72
+ with connectable.connect() as connection:
73
+ context.configure(connection=connection, target_metadata=target_metadata)
74
+
75
+ with context.begin_transaction():
76
+ context.run_migrations()
77
+
78
+
79
+ if context.is_offline_mode():
80
+ run_migrations_offline()
81
+ else:
82
+ run_migrations_online()
@@ -0,0 +1,29 @@
1
+ """${message}
2
+
3
+ Revision ID: ${up_revision}
4
+ Revises: ${down_revision | comma,n}
5
+ Create Date: ${create_date}
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlmodel
12
+ import sqlalchemy as sa
13
+ ${imports if imports else ""}
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = ${repr(up_revision)}
17
+ down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
18
+ branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
19
+ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
20
+
21
+
22
+ def upgrade() -> None:
23
+ """Upgrade schema."""
24
+ ${upgrades if upgrades else "pass"}
25
+
26
+
27
+ def downgrade() -> None:
28
+ """Downgrade schema."""
29
+ ${downgrades if downgrades else "pass"}
@@ -0,0 +1,34 @@
1
+ """baseline
2
+
3
+ Revision ID: 5227325b977d
4
+ Revises:
5
+ Create Date: 2026-01-07 16:34:35.310175
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ import sqlalchemy as sa
12
+ import sqlmodel
13
+
14
+ from alembic import op
15
+
16
+ # revision identifiers, used by Alembic.
17
+ revision: str = "5227325b977d"
18
+ down_revision: Union[str, Sequence[str], None] = None
19
+ branch_labels: Union[str, Sequence[str], None] = None
20
+ depends_on: Union[str, Sequence[str], None] = None
21
+
22
+
23
+ def upgrade() -> None:
24
+ """Upgrade schema."""
25
+ # ### commands auto generated by Alembic - please adjust! ###
26
+ pass
27
+ # ### end Alembic commands ###
28
+
29
+
30
+ def downgrade() -> None:
31
+ """Downgrade schema."""
32
+ # ### commands auto generated by Alembic - please adjust! ###
33
+ pass
34
+ # ### end Alembic commands ###
@@ -0,0 +1,149 @@
1
+ # A generic, single database configuration.
2
+
3
+ [alembic]
4
+ # path to migration scripts.
5
+ # this is typically a path given in POSIX (e.g. forward slashes)
6
+ # format, relative to the token %(here)s which refers to the location of this
7
+ # ini file
8
+ script_location = %(here)s/alembic
9
+
10
+ # template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11
+ # Uncomment the line below if you want the files to be prepended with date and time
12
+ # see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13
+ # for all available tokens
14
+ # file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15
+
16
+ # sys.path path, will be prepended to sys.path if present.
17
+ # defaults to the current working directory. for multiple paths, the path separator
18
+ # is defined by "path_separator" below.
19
+ prepend_sys_path = .
20
+
21
+
22
+ # timezone to use when rendering the date within the migration file
23
+ # as well as the filename.
24
+ # If specified, requires the tzdata library which can be installed by adding
25
+ # `alembic[tz]` to the pip requirements.
26
+ # string value is passed to ZoneInfo()
27
+ # leave blank for localtime
28
+ # timezone =
29
+
30
+ # max length of characters to apply to the "slug" field
31
+ # truncate_slug_length = 40
32
+
33
+ # set to 'true' to run the environment during
34
+ # the 'revision' command, regardless of autogenerate
35
+ # revision_environment = false
36
+
37
+ # set to 'true' to allow .pyc and .pyo files without
38
+ # a source .py file to be detected as revisions in the
39
+ # versions/ directory
40
+ # sourceless = false
41
+
42
+ # version location specification; This defaults
43
+ # to <script_location>/versions. When using multiple version
44
+ # directories, initial revisions must be specified with --version-path.
45
+ # The path separator used here should be the separator specified by "path_separator"
46
+ # below.
47
+ # version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
48
+
49
+ # path_separator; This indicates what character is used to split lists of file
50
+ # paths, including version_locations and prepend_sys_path within configparser
51
+ # files such as alembic.ini.
52
+ # The default rendered in new alembic.ini files is "os", which uses os.pathsep
53
+ # to provide os-dependent path splitting.
54
+ #
55
+ # Note that in order to support legacy alembic.ini files, this default does NOT
56
+ # take place if path_separator is not present in alembic.ini. If this
57
+ # option is omitted entirely, fallback logic is as follows:
58
+ #
59
+ # 1. Parsing of the version_locations option falls back to using the legacy
60
+ # "version_path_separator" key, which if absent then falls back to the legacy
61
+ # behavior of splitting on spaces and/or commas.
62
+ # 2. Parsing of the prepend_sys_path option falls back to the legacy
63
+ # behavior of splitting on spaces, commas, or colons.
64
+ #
65
+ # Valid values for path_separator are:
66
+ #
67
+ # path_separator = :
68
+ # path_separator = ;
69
+ # path_separator = space
70
+ # path_separator = newline
71
+ #
72
+ # Use os.pathsep. Default configuration used for new projects.
73
+ path_separator = os
74
+
75
+ # set to 'true' to search source files recursively
76
+ # in each "version_locations" directory
77
+ # new in Alembic version 1.10
78
+ # recursive_version_locations = false
79
+
80
+ # the output encoding used when revision files
81
+ # are written from script.py.mako
82
+ # output_encoding = utf-8
83
+
84
+ # database URL. This is consumed by the user-maintained env.py script only.
85
+ # other means of configuring database URLs may be customized within the env.py
86
+ # file.
87
+
88
+ # keep empty to let setup_alembic load from conf/__init__.py
89
+ sqlalchemy.url =
90
+
91
+
92
+ [post_write_hooks]
93
+ # post_write_hooks defines scripts or Python functions that are run
94
+ # on newly generated revision scripts. See the documentation for further
95
+ # detail and examples
96
+
97
+ # format using "black" - use the console_scripts runner, against the "black" entrypoint
98
+ # hooks = black
99
+ # black.type = console_scripts
100
+ # black.entrypoint = black
101
+ # black.options = -l 79 REVISION_SCRIPT_FILENAME
102
+
103
+ # lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
104
+ # hooks = ruff
105
+ # ruff.type = module
106
+ # ruff.module = ruff
107
+ # ruff.options = check --fix REVISION_SCRIPT_FILENAME
108
+
109
+ # Alternatively, use the exec runner to execute a binary found on your PATH
110
+ # hooks = ruff
111
+ # ruff.type = exec
112
+ # ruff.executable = ruff
113
+ # ruff.options = check --fix REVISION_SCRIPT_FILENAME
114
+
115
+ # Logging configuration. This is also consumed by the user-maintained
116
+ # env.py script only.
117
+ [loggers]
118
+ keys = root,sqlalchemy,alembic
119
+
120
+ [handlers]
121
+ keys = console
122
+
123
+ [formatters]
124
+ keys = generic
125
+
126
+ [logger_root]
127
+ level = WARNING
128
+ handlers = console
129
+ qualname =
130
+
131
+ [logger_sqlalchemy]
132
+ level = WARNING
133
+ handlers =
134
+ qualname = sqlalchemy.engine
135
+
136
+ [logger_alembic]
137
+ level = INFO
138
+ handlers =
139
+ qualname = alembic
140
+
141
+ [handler_console]
142
+ class = StreamHandler
143
+ args = (sys.stderr,)
144
+ level = NOTSET
145
+ formatter = generic
146
+
147
+ [formatter_generic]
148
+ format = %(levelname)-5.5s [%(name)s] %(message)s
149
+ datefmt = %H:%M:%S
@@ -0,0 +1,30 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ from typer import Typer
5
+
6
+ # TODO: i don't want to add this manually, but i have no idea how to do it automatically at present
7
+ sys.path.append(str(Path(__file__).parent / "src"))
8
+
9
+ print(sys.path)
10
+
11
+ cmd = Typer()
12
+
13
+
14
+ @cmd.command()
15
+ def sub(a: int, b: int) -> int:
16
+ c = a - b
17
+ print(f"sub({a}, {b}) = {c}")
18
+ return c
19
+
20
+
21
+ @cmd.command()
22
+ def setup_db():
23
+ from conf import setup_database
24
+
25
+ # if you need to use database, invoke setup_database freely
26
+ setup_database()
27
+
28
+
29
+ if __name__ == "__main__":
30
+ cmd()
@@ -0,0 +1,75 @@
1
+ # -*- mode: python ; coding: utf-8 -*-
2
+
3
+ datas=[
4
+ ("src/conf","conf"),
5
+ ("src/sdk","ipa"),
6
+ ("src/biz","biz"),
7
+ ("alembic","alembic"),
8
+ ("alembic.ini","."),
9
+ ]
10
+
11
+ a = Analysis(
12
+ ['main.py'],
13
+ pathex=[],
14
+ binaries=[],
15
+ datas=datas,
16
+ hiddenimports=[
17
+ "typer", "click", "ctypes", "_ctypes",
18
+ "colorlog",
19
+ 'scipy', 'scipy._cyutility',
20
+ "alembic",
21
+ 'sqlalchemy', 'sqlmodel', "sqlalchemy.sql.default_comparator",
22
+ "sqlalchemy.engine.url", "sqlalchemy.dialects.sqlite",
23
+ 'sqlite3',
24
+ "uvicorn.logging", # 核心日志模块
25
+ "uvicorn.logging.DefaultFormatter", # 显式指定默认格式化器
26
+ "logging.config", # Python 标准库日志配置
27
+ "colorama", # 若使用颜色日志,需添加(Uvicorn 可能依赖)
28
+ "uvicorn.loops",
29
+ "uvicorn.loops.auto",
30
+ "uvicorn.protocols",
31
+ "uvicorn.protocols.http",
32
+ "uvicorn.protocols.http.auto",
33
+ "uvicorn.protocols.websockets",
34
+ "uvicorn.protocols.websockets.auto",
35
+ "uvicorn.lifespan",
36
+ "uvicorn.lifespan.on",
37
+ "fastapi.middleware.cors"
38
+ ],
39
+ hookspath=[],
40
+ hooksconfig={},
41
+ runtime_hooks=[],
42
+ excludes=[],
43
+ noarchive=False,
44
+ optimize=0,
45
+ )
46
+ pyz = PYZ(a.pure)
47
+
48
+ onefile=False
49
+ exe = EXE(
50
+ pyz,
51
+ a.scripts,
52
+ [],
53
+ exclude_binaries=not onefile,
54
+ name='main',
55
+ debug=False,
56
+ bootloader_ignore_signals=False,
57
+ strip=False,
58
+ upx=True,
59
+ console=True,
60
+ disable_windowed_traceback=False,
61
+ argv_emulation=False,
62
+ target_arch=None,
63
+ codesign_identity=None,
64
+ entitlements_file=None,
65
+ )
66
+ if not onefile:
67
+ coll = COLLECT(
68
+ exe,
69
+ a.binaries,
70
+ a.datas,
71
+ strip=False,
72
+ upx=True,
73
+ upx_exclude=[],
74
+ name='main',
75
+ )