|
| 1 | +# Serverless Devs - Python 安装包 |
| 2 | + |
| 3 | +[](https://badge.fury.io/py/serverless-devs) |
| 4 | +[](https://pypi.org/project/serverless-devs/) |
| 5 | +[](https://pepy.tech/project/serverless-devs) |
| 6 | + |
| 7 | +通过 Python pip 安装 Serverless Devs 开发者工具(自动安装最新版本)。 |
| 8 | + |
| 9 | +## 特性 |
| 10 | + |
| 11 | +- ✅ 自动安装最新版 Serverless Devs |
| 12 | +- ✅ 自动处理 Node.js 环境依赖 |
| 13 | +- ✅ 支持 Windows、Linux、macOS |
| 14 | +- ✅ 一键安装,开箱即用 |
| 15 | + |
| 16 | +## 安装 |
| 17 | + |
| 18 | +### 使用 pip 安装 |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install serverless-devs |
| 22 | +``` |
| 23 | + |
| 24 | +### 使用国内镜像加速 |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install serverless-devs -i https://pypi.tuna.tsinghua.edu.cn/simple |
| 28 | +``` |
| 29 | + |
| 30 | +安装过程会自动: |
| 31 | +1. 下载并安装 Serverless Devs 官方安装脚本 |
| 32 | +2. 自动检测并安装 Node.js(如果需要) |
| 33 | +3. 安装最新版本的 Serverless Devs |
| 34 | + |
| 35 | +## 使用 |
| 36 | + |
| 37 | +安装完成后,可以直接使用 `s` 命令: |
| 38 | + |
| 39 | +```bash |
| 40 | +# 查看版本 |
| 41 | +s --version |
| 42 | + |
| 43 | +# 查看帮助 |
| 44 | +s --help |
| 45 | + |
| 46 | +# 配置密钥 |
| 47 | +s config add |
| 48 | + |
| 49 | +# 初始化项目 |
| 50 | +s init |
| 51 | + |
| 52 | +# 部署项目 |
| 53 | +s deploy |
| 54 | +``` |
| 55 | + |
| 56 | +## 手动安装/重新安装 |
| 57 | + |
| 58 | +如果自动安装失败,或需要重新安装最新版本: |
| 59 | + |
| 60 | +```bash |
| 61 | +s-install |
| 62 | +``` |
| 63 | + |
| 64 | +## 卸载 |
| 65 | + |
| 66 | +```bash |
| 67 | +pip uninstall serverless-devs |
| 68 | +``` |
| 69 | + |
| 70 | +> 注意:这只会卸载 Python 包装器,不会卸载 Serverless Devs 本身。 |
| 71 | +> 如需完全卸载,请手动删除 Serverless Devs: |
| 72 | +> - Linux/macOS: `rm -rf ~/.s` |
| 73 | +> - Windows: 删除 `C:\Users\<用户名>\.s` 目录 |
| 74 | +
|
| 75 | +## 支持的平台 |
| 76 | + |
| 77 | +- ✅ Windows (x64) |
| 78 | +- ✅ Linux (x64) |
| 79 | +- ✅ macOS (x64/arm64) |
| 80 | + |
| 81 | +## 环境要求 |
| 82 | + |
| 83 | +- Python 3.7+ |
| 84 | +- 互联网连接(用于下载安装脚本) |
| 85 | + |
| 86 | +## 工作原理 |
| 87 | + |
| 88 | +本包通过 pip 安装后,会执行 Serverless Devs 官方安装脚本: |
| 89 | + |
| 90 | +```bash |
| 91 | +curl -o- -L https://cli.serverless-devs.com/install.sh | bash |
| 92 | +``` |
| 93 | + |
| 94 | +该脚本会: |
| 95 | +1. 检测系统环境 |
| 96 | +2. 自动安装 Node.js(如果需要) |
| 97 | +3. 通过 npm 安装最新版 Serverless Devs |
| 98 | + |
| 99 | +## 常见问题 |
| 100 | + |
| 101 | +### Q: 安装失败怎么办? |
| 102 | + |
| 103 | +A: 请尝试以下方法: |
| 104 | +```bash |
| 105 | +# 1. 手动运行安装 |
| 106 | +s-install |
| 107 | + |
| 108 | +# 2. 使用国内镜像 |
| 109 | +export NPM_REGISTRY=https://registry.npmmirror.com |
| 110 | +s-install |
| 111 | + |
| 112 | +# 3. 直接使用官方安装脚本 |
| 113 | +curl -o- -L https://cli.serverless-devs.com/install.sh | bash |
| 114 | +``` |
| 115 | + |
| 116 | +### Q: 如何更新到最新版本? |
| 117 | + |
| 118 | +A: 重新运行安装命令: |
| 119 | +```bash |
| 120 | +s-install |
| 121 | +``` |
| 122 | + |
| 123 | +或使用 npm: |
| 124 | +```bash |
| 125 | +npm update -g @serverless-devs/s |
| 126 | +``` |
| 127 | + |
| 128 | +### Q: 如何查看安装的版本? |
| 129 | + |
| 130 | +A: 运行: |
| 131 | +```bash |
| 132 | +s --version |
| 133 | +``` |
| 134 | + |
| 135 | +### Q: Windows 下 PowerShell 执行策略问题 |
| 136 | + |
| 137 | +A: 如果遇到执行策略限制,请以管理员身份运行 PowerShell 并执行: |
| 138 | +```powershell |
| 139 | +Set-ExecutionPolicy RemoteSigned -Scope CurrentUser |
| 140 | +``` |
| 141 | + |
| 142 | +## 相关链接 |
| 143 | + |
| 144 | +- 官方网站: https://www.serverless-devs.com/ |
| 145 | +- GitHub: https://github.com/Serverless-Devs/Serverless-Devs |
| 146 | +- 文档中心: https://docs.serverless-devs.com/ |
| 147 | +- 应用中心: https://registry.serverless-devs.com/ |
| 148 | +- 钉钉交流群: 33947367 |
| 149 | + |
| 150 | +## License |
| 151 | + |
| 152 | +MIT License |
0 commit comments