Installing Python packages From subdirectories with Branches

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

Poetry documents it here.

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"


#python #howto #pip #pep508 #poetry