Skip to main content

funget

HTTP 文件传输工具,提供单线程下载、Range 并发下载、断点续传和 PUT/POST 上传。 核心由 Rust 实现,同时提供 Python 库和独立命令行二进制两种用法。

安装

命令行是独立的原生二进制,不需要 Python 环境。下面四条渠道装出来的 funget 命令是同一套实现,funget --version 报同一个版本号。

pip install funget 不在其中 —— 它装的是 Python 库,不带 funget 命令, 见后面的「作为 Python 库」。

apt(Debian / Ubuntu)

funget 没有进 Debian 官方档案,所以要先加一次 farfarfun 的包源。加过之后 apt install / apt upgrade 就和系统自带的包一样:

curl -fsSL https://farfarfun.github.io/packages/farfarfun.gpg \
  | sudo tee /usr/share/keyrings/farfarfun.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/farfarfun.gpg] https://farfarfun.github.io/packages/deb stable main" \
  | sudo tee /etc/apt/sources.list.d/farfarfun.list
sudo apt update && sudo apt install funget

amd64 和 arm64 都有。包里是静态链接的二进制,没有任何依赖,Debian 12 / Ubuntu 22.04 这类较老的发行版同样能装。源是组织共用的 (farfarfun/packages),加一次之后别的 farfarfun 工具也能直接 apt install。

Homebrew(macOS / Linux)

同理,先加一次 tap:

brew tap farfarfun/packages https://github.com/farfarfun/packages
brew trust farfarfun/packages
brew install funget

tap 那行要把 URL 写出来,因为 brew tap a/b 默认去找 github.com/a/homebrew-b, 而那个仓库同时还是 apt 源,不叫 homebrew-packages。trust 那行也不能省: Homebrew 6.0 起第三方 tap 默认不可信,不 trust 就只能写全名 brew install farfarfun/packages/funget。这两行加过一次之后就是裸名字装。

formula 装的是预编好的二进制,不从源码编;它由 farfarfun/packages 按每次 release 的 SHA256SUMS 统一渲染,和 APT 索引共用一个仓库。

cargo

cargo install funget

裸二进制

从 Releases 直接取,适合 CI 镜像和不想加源的机器。推荐静态链接的 musl 版,哪个发行版都能跑:

curl -fsSL https://github.com/farfarfun/funget/releases/latest/download/funget-x86_64-unknown-linux-musl.tar.gz \
  | tar -xz
sudo install -m 0755 funget /usr/local/bin/

Release 里也有不打包的裸文件(funget-x86_64-unknown-linux-gnu、 funget-aarch64-apple-darwin、funget-x86_64-pc-windows-msvc.exe 等)。 Linux 的 gnu 裸文件是动态链接的,需要 glibc 2.39 或更高;它存在的理由是 musl 静态版不走 glibc 的 NSS,靠 mDNS / LDAP / nss-* 插件解析主机名的环境只有 gnu 版能用。其余情况一律优先 musl。

附件的校验和在同一个 release 的 SHA256SUMS 里。

作为 Python 库

pip install funget

需要 Python 3.12 或更高版本。无任何运行时依赖,各平台提供预编译 wheel, 安装时不需要 Rust 工具链。

**这条渠道只给 Python API,不装 funget 命令。**命令行走上面四条渠道的任意 一条 —— 它们和 wheel 里的扩展模块是同一套引擎,只是分发方式不同。这么分是因为 把 CLI 链进扩展模块会让每个 pip install funget 的人都下载一份 clap (约 500 KB,占扩展体积的 12%),而需要命令行的人装的通常也不是 wheel;顺带 也不再出现 pip 的 funget 和 /usr/bin/funget 在 PATH 里打架。

作为 Rust 库

下载/上传引擎本身发布在 crates.io 上,可以脱离 Python 和 CLI 单独使用:

[dependencies]
funget-core = "0.3"

crate 的版本线是独立的 0.x —— 它的公开模块当初是为跨 crate 复用而 pub 的, 不是按公共 Rust API 设计的,所以在 0.x 期间仍会调整。详见 crates/funget-core/README.md。

命令行

funget download https://httpbin.org/bytes/1024 -o file.bin
funget download https://httpbin.org/bytes/1024 --worker 8 --block-size 50
funget download https://httpbin.org/bytes/1024 -o file.bin --resume   # 中断后重跑继续
funget upload ./file.bin https://httpbin.org/put
funget info https://httpbin.org/bytes/1024
funget info --json https://httpbin.org/bytes/1024
funget download --auto https://httpbin.org/bytes/1024 -o file.bin

download 默认走分块下载路径。--auto 根据大小和 Range 支持选择策略,文件超过 10 MiB 且服务端支持 Range 时使用分块下载,其余情况使用单线程。--single 强制单线程。

info --json 每次成功时在标准输出写一个 JSON 对象,包含 url、final_url (无重定向时为 null)、filename、filesize(字节,空文件或大小未知时为 0) 和布尔值 supports_range。文件信息探测失败时退出码为 1,诊断信息写入标准错误。

download、upload、info 三个子命令共用一组 HTTP 开关,短选项与 curl 对齐:

开关 说明
-H, --header LINE 追加请求头,格式 Name: value,可重复
-u, --user USER:PASSWORD Basic 认证。按第一个冒号切分,-u user: 是空密码
-A, --user-agent NAME 覆盖默认的 funget/<版本号>
--timeout SECONDS 连接与读取超时。download 默认 30,upload 默认 60
-x, --proxy URL 支持 http://、https://、socks5://、socks5h://
-k, --insecure 接受无效证书(含主机名不匹配)
--cacert FILE 追加信任的 PEM 证书,可重复;一个文件里放整条证书链也可以
--no-native-certs 不读系统证书库,只用内置的 webpki 根证书
--no-location 不跟随重定向。funget 默认跟随,所以这里是反向开关(curl 是正向的 -L)
--max-redirs N 最多跟随多少跳,默认 10

download 和 upload 另有 -s, --silent 关掉进度条(非 TTY 环境本来就不画)。 不传 -x 时沿用 HTTP_PROXY / HTTPS_PROXY / NO_PROXY 环境变量,与 curl 一致。

下载时可以传 --sha256 HEX 校验本地文件。摘要是发布方提供的 64 位十六进制字符串,大小写均可。 同大小的已有文件也会校验。摘要不匹配时命令返回 1 并保留文件,要重新下载可加 --overwrite。

funget download --auto --resume --sha256 "$EXPECTED_SHA256" -o data.bin "$URL"
funget download --auto --progress=plain -o data.bin "$URL" 2>transfer.log

下载和上传均支持 --progress=plain,传输期间每 5 秒向标准错误写一行,结束时再写一次。 总大小未知时显示已传字节数、速度和耗时。单线程续传时,如果 Ctrl+C 时本地文件比最近一次 保存的断点稍长,重跑同一命令会从已确认的位置继续,并重新获取断点之后的字节。

运行 funget --help 或 funget <command> --help 查看完整参数。

证书

TLS 信任的是内置 webpki 根证书与系统证书库的并集,所以企业私有 CA、内网自签 证书这类场景只要机器上装好了就能直接用。极少数机器的系统证书库 rustls 一张都解析 不了(截断过的 ca-certificates bundle 等),客户端会构造失败,用 --no-native-certs 退回只用内置根证书。

Python API

download() 会先检查文件大小和 Range 支持:超过 10 MiB 且服务器支持 Range 时并发下载,否则使用单线程。

from funget import download

ok = download(
    "https://httpbin.org/bytes/1024",
    "./downloads/file.bin",
    overwrite=True,
)

也可以显式选择下载方式:

from funget import multi_thread_download, simple_download

simple_download(
    "https://httpbin.org/bytes/1024", "./downloads/small.bin", chunk_size=64 * 1024
)
multi_thread_download(
    "https://httpbin.org/bytes/1024",
    "./downloads/large.bin",
    worker_num=8,
    block_size=50,
)

上传支持 PUT 和 multipart POST:

from pathlib import Path
from tempfile import TemporaryDirectory

from funget import single_upload

with TemporaryDirectory() as directory:
    filepath = Path(directory) / "example-upload.txt"
    filepath.write_text("funget upload example\n", encoding="utf-8")

    single_upload("https://httpbin.org/put", str(filepath), method="PUT")
    single_upload("https://httpbin.org/post", str(filepath), method="POST")

该示例使用公开测试服务,运行时需要网络连接。生产环境请使用接受相应 PUT 或 multipart POST 请求的上传地址。

断点续传

传 resume=True 后,中断的下载在下次调用时从断点继续,单线程和并发两条路径都支持:

from funget import download

download("https://example.com/huge.iso", "./huge.iso", resume=True)

续传期间会在目标文件旁维护 huge.iso.funget.json 状态文件,下载成功后自动删除。 远端文件若发生变化(ETag、Last-Modified 或大小不匹配),续传状态会被丢弃并重新下载, 不会拼出一个损坏的文件。默认关闭,不开启时行为与旧版完全一致。

参数

所有公开 API 均返回 bool,不抛异常。常用参数:

参数 单位 说明
worker_num 个 并发下载的分块并发数
block_size MiB 多线程下载分块大小
chunk_size 字节 单线程下载或上传读取块大小
max_retries 次 失败后的最大重试次数,退避 2^n 秒
timeout 秒 单次读取超时(不是整体下载超时)
headers - 自定义 HTTP 请求头
auth - (用户名, 密码) 二元组,走 Basic 认证
resume - 是否启用断点续传,默认 False
filesize 字节 已知文件大小,传了就跳过 HEAD 探测
insecure - 接受无效证书,默认 False。对应 CLI 的 -k
cacert - 追加信任的 PEM 证书路径,对应 CLI 的 --cacert
proxy - 代理地址,不传则读 HTTP_PROXY / HTTPS_PROXY / NO_PROXY

insecure、cacert、proxy 与 resume、filesize 一样只能按关键字传 (keyword-only)—— 原有签名是冻结的,新能力一律往后追加。完整签名见 src/funget/__init__.pyi。

重定向默认跟随,最多 10 跳;Python 侧不开放这两个旋钮,CLI 的 --no-location / --max-redirs 是排障用的。


关于 farfarfun

farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。

本项目基于 MIT 协议开源。

Metadata

Release files for funget 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for funget 1.4.0
File Size Uploaded Provenance Actions
funget-1.4.0.tar.gz 77.1 kB Without provenance Details for funget-1.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for funget 1.4.0
File Actions
funget-1.4.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for funget-1.4.0-cp312-abi3-win_amd64.whl
funget-1.4.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for funget-1.4.0-cp312-abi3-musllinux_1_2_x86_64.whl
funget-1.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for funget-1.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
funget-1.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for funget-1.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
funget-1.4.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for funget-1.4.0-cp312-abi3-macosx_11_0_arm64.whl
funget-1.4.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for funget-1.4.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 11.6 MB

Release files / funget-1.4.0.tar.gz

Download URL funget-1.4.0.tar.gz
Size 77.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ddaef1add71984af942e2f2cca8b06d58927a686a9a29a047099917baec981c7
BLAKE2b-256 checksum
How to use checksums
5bdbfdcbead6652792dd984b68b27a229c4116e9b25489ec56f0e46435133076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-win_amd64.whl

Download URL funget-1.4.0-cp312-abi3-win_amd64.whl
Size 2.0 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
aef6044fd07dae0770ef027ba2781c9c12533f1e6c30ffe2ae5cfb780c111fee
BLAKE2b-256 checksum
How to use checksums
0a5affbf4b0b4822a292dffc2b0c69b61f39dc770ee22ecc1bd81e4eff9e00a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL funget-1.4.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 2.2 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
1720683a42c4ce0a3a6a081f122290aafafccaba9b8afbe4653930e5d9843638
BLAKE2b-256 checksum
How to use checksums
e638561e83b4fcf020d601bbf0e81e58da5933615fb6940f88181e6838077af2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL funget-1.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e8d3569df93e22ac5f76fa021e7551bc3923f8464a54ae59f1ede22d5fac5ac6
BLAKE2b-256 checksum
How to use checksums
c8f7993e3c24a9b78eb9ba10ad32ebf82c576c28882226142fbc208b75648c16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL funget-1.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.9 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
1373701da1b9d2d73ef795479dc2a8bc788725ccaceb4868a03c122f4984d95f
BLAKE2b-256 checksum
How to use checksums
e655845095173fddf82c2335a84b7739d0af1068a82e6d9997c7a92646f8dbc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL funget-1.4.0-cp312-abi3-macosx_11_0_arm64.whl
Size 1.8 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aae0531d57f7ec86b5779f209c2760bbc42bb6d47b3ef1224438bcc6505adc6c
BLAKE2b-256 checksum
How to use checksums
c67564d7105b80547ef9094fa463bcda0d825fb376d7f2ed8c612498b26410a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / funget-1.4.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL funget-1.4.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 1.9 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1e5aae376114a6f6fac489a8855d7076ced4cb5113182091a6f779e67942ae32
BLAKE2b-256 checksum
How to use checksums
f3145e626cc417dfbdaf32e620cbe2701ae9c9a050d61d7bac7341e49bfbf520
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for funget 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.4.0 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page