funread-api 1.2.6__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.
- funread_api-1.2.6/.github/workflows/ci.yml +52 -0
- funread_api-1.2.6/.gitignore +197 -0
- funread_api-1.2.6/LICENSE +21 -0
- funread_api-1.2.6/PKG-INFO +94 -0
- funread_api-1.2.6/README.md +63 -0
- funread_api-1.2.6/pyproject.toml +78 -0
- funread_api-1.2.6/scripts/build-binary.sh +76 -0
- funread_api-1.2.6/scripts/export_openapi.py +134 -0
- funread_api-1.2.6/scripts/setup.sh +155 -0
- funread_api-1.2.6/src/funread_api/__init__.py +1 -0
- funread_api-1.2.6/src/funread_api/accounts.py +559 -0
- funread_api-1.2.6/src/funread_api/app.py +82 -0
- funread_api-1.2.6/src/funread_api/cli.py +738 -0
- funread_api-1.2.6/src/funread_api/paths.py +79 -0
- funread_api-1.2.6/src/funread_api/security.py +382 -0
- funread_api-1.2.6/src/funread_api/v1/__init__.py +49 -0
- funread_api-1.2.6/src/funread_api/v1/auth.py +522 -0
- funread_api-1.2.6/src/funread_api/v1/deps.py +251 -0
- funread_api-1.2.6/src/funread_api/v1/pool.py +346 -0
- funread_api-1.2.6/src/funread_api/v1/reader.py +439 -0
- funread_api-1.2.6/src/funread_api/v1/rss.py +504 -0
- funread_api-1.2.6/src/funread_api/v1/shelf.py +533 -0
- funread_api-1.2.6/src/funread_api/v1/sources.py +256 -0
- funread_api-1.2.6/tests/accounts_support.py +86 -0
- funread_api-1.2.6/tests/conftest.py +120 -0
- funread_api-1.2.6/tests/test_accounts.py +223 -0
- funread_api-1.2.6/tests/test_api.py +130 -0
- funread_api-1.2.6/tests/test_auth.py +989 -0
- funread_api-1.2.6/tests/test_cli.py +422 -0
- funread_api-1.2.6/tests/test_paths.py +78 -0
- funread_api-1.2.6/tests/test_reader_api.py +945 -0
- funread_api-1.2.6/tests/test_rss_api.py +548 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
# 这个仓库在 2026-10-17 之前**没有任何 CI** —— 223 个测试只在本地跑,而
|
|
4
|
+
# `funbuild build` 直接从本机推 PyPI。理由和对策同 funread 那边的 ci.yml:
|
|
5
|
+
# 这条流水线拦不住一个已经发出去的坏版本,它只负责让问题在 push 后几分钟内
|
|
6
|
+
# 可见。
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [master]
|
|
10
|
+
pull_request:
|
|
11
|
+
workflow_dispatch:
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ci-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
timeout-minutes: 15
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- uses: astral-sh/setup-uv@v5
|
|
25
|
+
with:
|
|
26
|
+
enable-cache: true
|
|
27
|
+
|
|
28
|
+
- name: 装依赖
|
|
29
|
+
# **显式钉 3.12**,不靠 uv 自己挑:requires-python 是 >=3.12,不指定的话
|
|
30
|
+
# uv 会选机器上最新的满足版本(本地试的时候它挑了 3.13),于是「声明的
|
|
31
|
+
# 下限」从来没被跑过,而 runner 镜像换一次默认 Python,测的版本就悄悄
|
|
32
|
+
# 变了。这里不跑矩阵是因为只有一个下限要守,要加 3.13 以后再说。
|
|
33
|
+
#
|
|
34
|
+
# **装的是 PyPI 上的 funread,不是隔壁目录的源码。** 这是有意的:
|
|
35
|
+
# funread-api 声明的是 `funread[reader]>=1.1.127`,CI 验的就该是「照着
|
|
36
|
+
# 这个声明装出来的组合能不能跑」。代价是核心库里还没发版的改动在这儿
|
|
37
|
+
# 看不到 —— 那种跨仓库的联调本来也只有 monorepo 的工作区能覆盖
|
|
38
|
+
# (本地 PYTHONPATH=src:../funread/src)。
|
|
39
|
+
run: uv sync --extra dev --python 3.12
|
|
40
|
+
|
|
41
|
+
- name: ruff
|
|
42
|
+
run: uv run ruff check .
|
|
43
|
+
|
|
44
|
+
- name: 格式
|
|
45
|
+
run: uv run ruff format --check .
|
|
46
|
+
|
|
47
|
+
- name: pytest
|
|
48
|
+
# 全部离线。conftest.py 的 autouse fixture 除了把库换成临时 SQLite,
|
|
49
|
+
# 还把整个 funsecret 层打成 None —— 本机那份配置指向生产 PostgreSQL。
|
|
50
|
+
# --fail-on-skip:少装一个 extra 对应的用例会 skip 而不是报错,绿得毫无
|
|
51
|
+
# 意义 —— 这里把 skip 当失败。实现在 tests/conftest.py。
|
|
52
|
+
run: uv run pytest -q --fail-on-skip
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
uv.lock
|
|
104
|
+
|
|
105
|
+
# pdm
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
107
|
+
#pdm.lock
|
|
108
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
109
|
+
# in version control.
|
|
110
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
111
|
+
.pdm.toml
|
|
112
|
+
|
|
113
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
114
|
+
__pypackages__/
|
|
115
|
+
|
|
116
|
+
# Celery stuff
|
|
117
|
+
celerybeat-schedule
|
|
118
|
+
celerybeat.pid
|
|
119
|
+
|
|
120
|
+
# SageMath parsed files
|
|
121
|
+
*.sage.py
|
|
122
|
+
|
|
123
|
+
# Environments
|
|
124
|
+
.env
|
|
125
|
+
.venv
|
|
126
|
+
env/
|
|
127
|
+
venv/
|
|
128
|
+
ENV/
|
|
129
|
+
env.bak/
|
|
130
|
+
venv.bak/
|
|
131
|
+
|
|
132
|
+
# Spyder project settings
|
|
133
|
+
.spyderproject
|
|
134
|
+
.spyproject
|
|
135
|
+
|
|
136
|
+
# Rope project settings
|
|
137
|
+
.ropeproject
|
|
138
|
+
|
|
139
|
+
# mkdocs documentation
|
|
140
|
+
/site
|
|
141
|
+
|
|
142
|
+
# mypy
|
|
143
|
+
.mypy_cache/
|
|
144
|
+
.dmypy.json
|
|
145
|
+
dmypy.json
|
|
146
|
+
|
|
147
|
+
# Pyre type checker
|
|
148
|
+
.pyre/
|
|
149
|
+
|
|
150
|
+
# pytype static type analyzer
|
|
151
|
+
.pytype/
|
|
152
|
+
|
|
153
|
+
# Cython debug symbols
|
|
154
|
+
cython_debug/
|
|
155
|
+
|
|
156
|
+
# PyCharm
|
|
157
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
158
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
159
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
160
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
161
|
+
#.idea/
|
|
162
|
+
|
|
163
|
+
*.db
|
|
164
|
+
hubs/cache
|
|
165
|
+
hubs/book/pkl
|
|
166
|
+
hubs/book/source
|
|
167
|
+
hubs/rss/pkl
|
|
168
|
+
hubs/rss/source
|
|
169
|
+
|
|
170
|
+
# ---- AI 编码助手 ----
|
|
171
|
+
# 只忽略本地状态;团队有意共享的 agent / 命令 / 规则定义仍然版本化。
|
|
172
|
+
# 必须写 `dir/*` 而不是 `dir/`:父目录被整体排除后 git 不会下探,
|
|
173
|
+
# 下面的 `!` 取消规则就永远不会生效。
|
|
174
|
+
.claude/*
|
|
175
|
+
!.claude/agents/
|
|
176
|
+
!.claude/commands/
|
|
177
|
+
!.claude/skills/
|
|
178
|
+
!.claude/settings.json
|
|
179
|
+
.codex/*
|
|
180
|
+
!.codex/prompts/
|
|
181
|
+
.cursor/*
|
|
182
|
+
!.cursor/agents/
|
|
183
|
+
!.cursor/rules/
|
|
184
|
+
|
|
185
|
+
# 其余助手:目前没有共享内容,整体忽略
|
|
186
|
+
.aider*
|
|
187
|
+
.gemini/
|
|
188
|
+
.continue/
|
|
189
|
+
.windsurf/
|
|
190
|
+
.roo/
|
|
191
|
+
.cline/
|
|
192
|
+
.specstory/
|
|
193
|
+
CLAUDE.local.md
|
|
194
|
+
AGENTS.local.md
|
|
195
|
+
|
|
196
|
+
# farlog writes here when the API runs (including under pytest)
|
|
197
|
+
logs/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 farfarfun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: funread-api
|
|
3
|
+
Version: 1.2.6
|
|
4
|
+
Summary: funread 采集源管理后端服务
|
|
5
|
+
Project-URL: Organization, https://github.com/farfarfun
|
|
6
|
+
Project-URL: Repository, https://github.com/farfarfun/funread-api
|
|
7
|
+
Project-URL: Releases, https://github.com/farfarfun/funread-api/releases
|
|
8
|
+
Author-email: 牛哥 <niuliangtao@qq.com>, farfarfun <farfarfun@qq.com>
|
|
9
|
+
Maintainer-email: 牛哥 <niuliangtao@qq.com>, farfarfun <farfarfun@qq.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: aiomysql>=0.2.0
|
|
14
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
15
|
+
Requires-Dist: fastapi>=0.110.0
|
|
16
|
+
Requires-Dist: funauth[fastapi]>=0.2.3
|
|
17
|
+
Requires-Dist: funread[js,reader]>=1.2.5
|
|
18
|
+
Requires-Dist: itsdangerous>=2.1.0
|
|
19
|
+
Requires-Dist: pydantic>=2.0.0
|
|
20
|
+
Requires-Dist: requests>=2.28.0
|
|
21
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
|
22
|
+
Requires-Dist: typer>=0.12
|
|
23
|
+
Requires-Dist: uvicorn[standard]>=0.27.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: httpx2>=0.1.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: httpx>=0.27.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# funread-api
|
|
33
|
+
|
|
34
|
+
`funread` 的后端服务,依赖 [funread](https://github.com/farfarfun/funread) 核心库并对外暴露 API,供
|
|
35
|
+
[funread-web](https://github.com/farfarfun/funread-web) 调用。搭配使用见
|
|
36
|
+
[funread-dev](https://github.com/farfarfun/funread-dev)。
|
|
37
|
+
|
|
38
|
+
## Install and run
|
|
39
|
+
|
|
40
|
+
Install a released version with `uv`:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv tool install funread-api
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The named CLI owns the server lifecycle:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
funread-api server start
|
|
50
|
+
funread-api server status
|
|
51
|
+
funread-api server stop
|
|
52
|
+
funread-api server run --port 18811
|
|
53
|
+
funread-api server restart
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The server listens on `127.0.0.1:18811` by default. `start` writes its PID and log to
|
|
57
|
+
`.run/funread-api.pid` and `.run/funread-api.log` below the current working directory;
|
|
58
|
+
`run` keeps the process in the foreground. Visit `/docs` for the API documentation and
|
|
59
|
+
`/healthz` for health checks.
|
|
60
|
+
|
|
61
|
+
For a repository checkout, `scripts/setup.sh` keeps installation separate from runtime:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
scripts/setup.sh install-dev
|
|
65
|
+
scripts/setup.sh install-prod [version]
|
|
66
|
+
scripts/setup.sh publish
|
|
67
|
+
scripts/setup.sh start
|
|
68
|
+
scripts/setup.sh status
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Runtime actions invoke only the installed `funread-api` CLI. The same CLI also provides
|
|
72
|
+
`upgrade [version]`, `rollback <version>`, and `uninstall`; the last action stops the
|
|
73
|
+
managed service before removing the package.
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uv sync --extra dev
|
|
79
|
+
uv run pytest -q
|
|
80
|
+
uv run ruff check .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 关于 farfarfun
|
|
86
|
+
|
|
87
|
+
[farfarfun](https://github.com/farfarfun) 是一个专注于实用工具库的开源组织,
|
|
88
|
+
涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
|
|
89
|
+
|
|
90
|
+
- 🏠 组织主页:<https://github.com/farfarfun>
|
|
91
|
+
- 📦 PyPI:<https://pypi.org/user/niuliangtao/>
|
|
92
|
+
- 📧 联系:farfarfun@qq.com
|
|
93
|
+
|
|
94
|
+
本项目基于 [MIT](LICENSE) 协议开源。
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# funread-api
|
|
2
|
+
|
|
3
|
+
`funread` 的后端服务,依赖 [funread](https://github.com/farfarfun/funread) 核心库并对外暴露 API,供
|
|
4
|
+
[funread-web](https://github.com/farfarfun/funread-web) 调用。搭配使用见
|
|
5
|
+
[funread-dev](https://github.com/farfarfun/funread-dev)。
|
|
6
|
+
|
|
7
|
+
## Install and run
|
|
8
|
+
|
|
9
|
+
Install a released version with `uv`:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv tool install funread-api
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The named CLI owns the server lifecycle:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
funread-api server start
|
|
19
|
+
funread-api server status
|
|
20
|
+
funread-api server stop
|
|
21
|
+
funread-api server run --port 18811
|
|
22
|
+
funread-api server restart
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The server listens on `127.0.0.1:18811` by default. `start` writes its PID and log to
|
|
26
|
+
`.run/funread-api.pid` and `.run/funread-api.log` below the current working directory;
|
|
27
|
+
`run` keeps the process in the foreground. Visit `/docs` for the API documentation and
|
|
28
|
+
`/healthz` for health checks.
|
|
29
|
+
|
|
30
|
+
For a repository checkout, `scripts/setup.sh` keeps installation separate from runtime:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
scripts/setup.sh install-dev
|
|
34
|
+
scripts/setup.sh install-prod [version]
|
|
35
|
+
scripts/setup.sh publish
|
|
36
|
+
scripts/setup.sh start
|
|
37
|
+
scripts/setup.sh status
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Runtime actions invoke only the installed `funread-api` CLI. The same CLI also provides
|
|
41
|
+
`upgrade [version]`, `rollback <version>`, and `uninstall`; the last action stops the
|
|
42
|
+
managed service before removing the package.
|
|
43
|
+
|
|
44
|
+
## Development
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv sync --extra dev
|
|
48
|
+
uv run pytest -q
|
|
49
|
+
uv run ruff check .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 关于 farfarfun
|
|
55
|
+
|
|
56
|
+
[farfarfun](https://github.com/farfarfun) 是一个专注于实用工具库的开源组织,
|
|
57
|
+
涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
|
|
58
|
+
|
|
59
|
+
- 🏠 组织主页:<https://github.com/farfarfun>
|
|
60
|
+
- 📦 PyPI:<https://pypi.org/user/niuliangtao/>
|
|
61
|
+
- 📧 联系:farfarfun@qq.com
|
|
62
|
+
|
|
63
|
+
本项目基于 [MIT](LICENSE) 协议开源。
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "funread-api"
|
|
3
|
+
version = "1.2.6"
|
|
4
|
+
description = "funread 采集源管理后端服务"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
# [reader] pulls in lxml/cssselect/jsonpath-ng — the rule engine needs them,
|
|
9
|
+
# the collection pipeline does not.
|
|
10
|
+
# 阅读源规则入库与扫描接口从 1.2.5 开始提供。
|
|
11
|
+
"funread[reader,js]>=1.2.5",
|
|
12
|
+
"fastapi>=0.110.0",
|
|
13
|
+
"uvicorn[standard]>=0.27.0",
|
|
14
|
+
"pydantic>=2.0.0",
|
|
15
|
+
"SQLAlchemy>=2.0.0",
|
|
16
|
+
"requests>=2.28.0",
|
|
17
|
+
# 读者账号(注册/登录/邀请码/角色)整套走 funauth。它要求 py3.12 + SQLAlchemy
|
|
18
|
+
# async,这也是账号表建在本服务而不是 funread 核心库里的原因 —— 后者下限是
|
|
19
|
+
# 3.11,不该为了账号功能抬高只用采集的人的 Python 下限。
|
|
20
|
+
"funauth[fastapi]>=0.2.3",
|
|
21
|
+
# funauth 是纯 async 的,而本服务其余部分同步。两个 driver 都要装:账号表走
|
|
22
|
+
# async 引擎,阅读层继续走 funread 的同步引擎,同一个库两个连接。
|
|
23
|
+
"aiosqlite>=0.20.0",
|
|
24
|
+
"aiomysql>=0.2.0",
|
|
25
|
+
# Starlette 的 SessionMiddleware 签 cookie 用它,不是 starlette 的硬依赖。
|
|
26
|
+
"itsdangerous>=2.1.0",
|
|
27
|
+
# 命令行入口(src/funread_api/cli.py)用的框架。funread 那边也会间接带进来,
|
|
28
|
+
# 但这里是直接 import,必须自己声明下界。
|
|
29
|
+
"typer>=0.12",
|
|
30
|
+
]
|
|
31
|
+
license = "MIT"
|
|
32
|
+
license-files = ["LICENSE"]
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
funread-api = "funread_api.cli:main"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = ["pytest>=7.0.0", "pytest-cov>=4.0.0", "httpx>=0.27.0", "httpx2>=0.1.0", "ruff>=0.1.0"]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Organization = "https://github.com/farfarfun"
|
|
42
|
+
Repository = "https://github.com/farfarfun/funread-api"
|
|
43
|
+
Releases = "https://github.com/farfarfun/funread-api/releases"
|
|
44
|
+
|
|
45
|
+
[[project.authors]]
|
|
46
|
+
name = "牛哥"
|
|
47
|
+
email = "niuliangtao@qq.com"
|
|
48
|
+
|
|
49
|
+
[[project.authors]]
|
|
50
|
+
name = "farfarfun"
|
|
51
|
+
email = "farfarfun@qq.com"
|
|
52
|
+
[[project.maintainers]]
|
|
53
|
+
name = "牛哥"
|
|
54
|
+
email = "niuliangtao@qq.com"
|
|
55
|
+
|
|
56
|
+
[[project.maintainers]]
|
|
57
|
+
name = "farfarfun"
|
|
58
|
+
email = "farfarfun@qq.com"
|
|
59
|
+
[build-system]
|
|
60
|
+
requires = ["hatchling"]
|
|
61
|
+
build-backend = "hatchling.build"
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.wheel]
|
|
64
|
+
packages = ["src/funread_api"]
|
|
65
|
+
|
|
66
|
+
[tool.ruff]
|
|
67
|
+
line-length = 100
|
|
68
|
+
target-version = "py312"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint]
|
|
71
|
+
select = ["E", "F", "I", "N", "W"]
|
|
72
|
+
ignore = ["E501"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.isort]
|
|
75
|
+
# funread is the sibling workspace package, not a third-party dependency. Ruff
|
|
76
|
+
# only sees it installed into site-packages and would otherwise split it away
|
|
77
|
+
# from funread_api, which is how the import blocks are actually written.
|
|
78
|
+
known-first-party = ["funread", "funread_api"]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# 把 funread-api 打成一个不依赖 Python 环境的单文件可执行程序。
|
|
4
|
+
#
|
|
5
|
+
# 用途:自托管的人下载一个文件就能跑,不用装 Python / uv,也不用担心共享环境里
|
|
6
|
+
# 的旧包盖掉新版(这个坑我们自己踩过好几次)。
|
|
7
|
+
#
|
|
8
|
+
# ./scripts/build-binary.sh # 产物在 dist/funread-api
|
|
9
|
+
# ./scripts/build-binary.sh /tmp/out # 指定输出目录
|
|
10
|
+
#
|
|
11
|
+
# 产物约 50 MB,冷启动约 1.1 秒(解包到临时目录的代价,--onefile 的固有开销)。
|
|
12
|
+
# 嫌慢可以把 --onefile 换成 --onedir:启动快得多,但变成一个目录而不是一个文件。
|
|
13
|
+
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
17
|
+
OUT_DIR="${1:-$HERE/dist}"
|
|
18
|
+
WORK_DIR="$(mktemp -d)"
|
|
19
|
+
trap 'rm -rf "$WORK_DIR"' EXIT
|
|
20
|
+
|
|
21
|
+
echo "==> 在干净环境里构建($WORK_DIR)"
|
|
22
|
+
uv venv --python 3.12 "$WORK_DIR/.venv" >/dev/null
|
|
23
|
+
|
|
24
|
+
# **必须装在同一个环境里**:PyInstaller 只打包它能 import 到的东西,
|
|
25
|
+
# `--hidden-import` 对没装的包无能为力。
|
|
26
|
+
uv pip install --python "$WORK_DIR/.venv/bin/python" --quiet pyinstaller
|
|
27
|
+
uv pip install --python "$WORK_DIR/.venv/bin/python" --quiet "$HERE"
|
|
28
|
+
|
|
29
|
+
# asyncpg / psycopg2 **不是** funread-api 的声明依赖 —— 它们要编译扩展,而本地
|
|
30
|
+
# 开发只用 SQLite。但线上是 PostgreSQL,漏了的话二进制跑起来一切正常,直到第一
|
|
31
|
+
# 次连库才报 `ModuleNotFoundError: No module named 'asyncpg'`。这一行是踩过的坑。
|
|
32
|
+
uv pip install --python "$WORK_DIR/.venv/bin/python" --quiet asyncpg psycopg2-binary
|
|
33
|
+
|
|
34
|
+
cat > "$WORK_DIR/entry.py" <<'PY'
|
|
35
|
+
from funread_api.cli import main
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
raise SystemExit(main())
|
|
39
|
+
PY
|
|
40
|
+
|
|
41
|
+
echo "==> PyInstaller 打包"
|
|
42
|
+
# `--collect-submodules` 而不是逐个 `--hidden-import`:这几个包都有运行时按名字
|
|
43
|
+
# 加载的子模块(uvicorn 的 loop/protocol 实现、funread 的源类型注册表),静态
|
|
44
|
+
# 分析扫不出来。
|
|
45
|
+
"$WORK_DIR/.venv/bin/pyinstaller" \
|
|
46
|
+
--onefile \
|
|
47
|
+
--name funread-api \
|
|
48
|
+
--distpath "$OUT_DIR" \
|
|
49
|
+
--workpath "$WORK_DIR/build" \
|
|
50
|
+
--specpath "$WORK_DIR" \
|
|
51
|
+
--collect-submodules funread \
|
|
52
|
+
--collect-submodules funread_api \
|
|
53
|
+
--collect-submodules funauth \
|
|
54
|
+
--collect-submodules uvicorn \
|
|
55
|
+
--hidden-import aiosqlite \
|
|
56
|
+
--hidden-import asyncpg \
|
|
57
|
+
--hidden-import psycopg2 \
|
|
58
|
+
--noconfirm \
|
|
59
|
+
"$WORK_DIR/entry.py"
|
|
60
|
+
|
|
61
|
+
echo
|
|
62
|
+
echo "==> 冒烟测试"
|
|
63
|
+
"$OUT_DIR/funread-api" --help >/dev/null
|
|
64
|
+
echo " --help 正常"
|
|
65
|
+
|
|
66
|
+
# 真连一次库是唯一能证明 C 扩展都在的办法:lxml、psycopg2、asyncpg、bcrypt
|
|
67
|
+
# 任何一个没打进去,都只会在运行到那一步时才崩。
|
|
68
|
+
if "$OUT_DIR/funread-api" accounts list >/dev/null 2>&1; then
|
|
69
|
+
echo " 连库正常(C 扩展齐全)"
|
|
70
|
+
else
|
|
71
|
+
echo " ⚠ 连不上库 —— 可能是本机没配库地址,也可能是驱动没打进去。"
|
|
72
|
+
echo " 手动确认:$OUT_DIR/funread-api accounts list"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
echo
|
|
76
|
+
ls -lh "$OUT_DIR/funread-api" | awk '{print "==> 完成:", $NF, "(" $5 ")"}'
|