Sometimes you just need to do weird cursed things…
With pip
Python’s official spec is in PEP508.
pip install 'git+https://github.com/yaleman/kanidm.git@mycoolbranch#subdirectory=pykanidm'
With poetry
kanidm = { git = "git@github.com:yaleman/kanidm.git", branch = "mycoolbranch", subdirectory = "pykanidm" }
Or slightly more easy to read:
[tool.poetry.dependencies.kanidm]
git = "git@github.com:yaleman/kanidm.git"
branch = "mycoolbranch"
subdirectory = "pykanidm"