This is an example Python package which can be downloaded and executed by a single uvx command. It is designed to read JSON from STDIN, and output JSON to STDOUT, as part of a bare-bones simple xyOps Event Plugin.
Here is the Plugin command for this package:
uvx git+https://github.com/pixlcore/xyplug-sample-uvx.git@v1.0.1Here is an example invocation with some test data piped in:
echo '{"xy":1,"test":[2,3]}' | uvx git+https://github.com/pixlcore/xyplug-sample-uvx.git@v1.0.1Expected output:
Read JSON from STDIN:
{
"xy": 1,
"test": [
2,
3
]
}
{ "xy":1, "code":0 }
Note: xyOps will ignore and pass through the "pretty-printed" JSON output, and only consume the compact message at the end.
- Make sure you have a properly-formatted
pyproject.tomlfile at the root of your repo. - Create
src/YOUR_PACKAGE_NAMEparent dirs (no dashes allowed). - Place
__init__.pyandcli.pyin that directory. - Tag the repo to match the version in
pyproject.toml(currently1.0.1):
git tag v1.0.1
git push origin v1.0.1- The console script name is
xyplug-sample-uvxand maps toxyplug_sample_uvx.cli:mainvia[project.scripts]inpyproject.toml. - The importable Python package uses underscores (
xyplug_sample_uvx) since hyphens are not valid in module names. - Includes one third-party dependency:
requests(and its transitive deps likeurllib3), to demonstrate thatuvxdownloads and installs dependencies automatically. The CLI prints a version check to stdout at startup.