1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 你可以创建一个部署send_mqtt的组件,然后创建你的foo和foo2组件并依赖于send_mqtt。
示例看起来像:
- send_mqtt
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "my.send_mqtt",
"ComponentVersion": "1.0.0",
"ComponentDescription": "通过MQTT发送消息",
"ComponentPublisher": "我自己",
"Manifests": [
{
"Platform": {
"os": "linux"
},
"Lifecycle": {
"Install": "pip3 install --user -r {artifacts:decompressedPath}/send_mqtt/requirements.txt"
},
"Artifacts": [
{
"URI": "s3://MY_BUCKET/my.send_mqtt/1.0.0/send_mqtt.zip",
"Unarchive": "ZIP"
}
]
}
]
}
- foo 示例
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "my.foo",
"ComponentVersion": "1.0.0",
"ComponentDescription": "Foo",
"ComponentPublisher": "我自己",
"ComponentDependencies": {
"my.send_mqtt": {
"VersionRequirement": "^1.0.0"
}
},
"Manifests": [
{
"Platform": {
"os": "linux"
},
"Lifecycle": {
"Run": "export PYTHONPATH=$PYTHONPATH:{my.send_mqtt:artifacts:decompressedPath}/send_mqtt; python3 {artifacts:path}/foo.py"
},
"Artifacts": [
{
"URI": "s3://MY_BUCKET/my.foo/1.0.0/foo.py"
}
]
}
]
}
然后,在foo.py中,你就可以导入send_mqtt。
祝好,
Philipp
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 7 个月前
- AWS 官方已更新 3 年前