1 回答
- 最新
- 投票最多
- 评论最多
0
Hi,
you could create a component which deploys send_mqtt. Then you create your foo and foo2 components with a dependency to send_mqtt.
A particular recipes example could look like:
- send_mqtt
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "my.send_mqtt",
"ComponentVersion": "1.0.0",
"ComponentDescription": "Send messages via MQTT",
"ComponentPublisher": "Myself",
"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 recipe
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "my.foo",
"ComponentVersion": "1.0.0",
"ComponentDescription": "Foo",
"ComponentPublisher": "Myself",
"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"
}
]
}
]
}
In foo.py you can then import send_mqtt.
KR,
Philipp
This is great help, thanks a lot