--- tags: feature author: Oliver.W & Meng --- # Python Library with Serverless ## Requirements * 用户可以通过依赖文件 requirements.txt 来安装python依赖。 * 通过支持用户上传私有库和自定义库 * python依赖安装到系统默认位置,不安装在用户文件的根目录。 ## 建议方案 ### 不带库部署 > 支持使用公共库开发的项目 * 支持 installDependencies * 支持通用 requirements.txt 方式安装 #### 使用方式 1. 生成 requirements.txt (pip标准安装文件),不同 python 工具使用以下方式生成requirements 文件 (pip,conda, poetry) * pip freeze > requirements.txt * conda list -e > requirements.txt * poetry export -f requirements.txt 2. 使用 sls deploy 部署 --- * (SCF) 执行 pip install -r requirements.txt (-t ./tencent-requirements) 根据依赖文件安装库。 * (SCF) 执行用户代码 python3 main.py ### 带库部署 > 支持使用私有库和自定义库的情况 * 定义固定库目录,如 * tencent_requirements\ * 需要也可以在 serverless.yml 配置中指定目录。 #### 使用方式 1. [可选]生成 requirements.txt 2. 将依赖文件移动到固定目录 3. 使用 sls deploy 部署 --- * (SCF) [可选,有requirements.txt] 安装依赖文件 pip install -r requirements.txt * (SCF) 复制固定目录库到依赖目录 cp tencent_requirements\ \python\packages * (SCF) 执行用户代码 python3 main.py ## Actions Things * -t hook. in compoents logic. * remove yaml (python library import feature) feature.
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up