How to structure a python projects with shared sub

2019-02-10 19:42发布

问题:

I have multiple projects that shares child apps with other projects. When working within the project directory I want to be able to make changes to the app, update it, and pull those updates into the second project.

Requirement:

  • No use of symbolic links (my IDE's debugger doesn't work well with them)
  • No compiling/rerun a script. I would like to make changes to the app without having to rerun a script/buildout.
  • Apps must be within the project folder.

Here's the structure:

app_one (git repo)
  |-- app_one (actual app uses by projects)
  |   +-- models.py
  |-- README.md
  +-- setup.py

project_one  (git repo)
  |-- project_one
  |   |-- apps
  |   |   |-- app_one
  |   |   |   +-- models.py
  |   |   | -- app_two
  |-- setup.cfg
  +-- setup.py

project_two  (git repo)
  |-- project_two
  |   |-- apps
  |   |   |-- app_one (same app as project_one)
  |   |   |   +-- models.py
  |   |   | -- app_two
  |-- setup.cfg
  +-- setup.py

Currently I'm using git-submodules for this; the downside is there is no way to link to a subfolder of a repo. I recently read about subtree, would this work better?

Ideally I would like to use buildout, but I haven't found a good way to accomplish this without the use of symbolic links. If there's a way to to do this please let me know.

Any suggestions would be greatly appreciated.

回答1:

mr.developer. When a mr.developer source is checked out and activated, it becomes a setuptools/distribute develop egg in the buildout and so the checkout will be what is used by any scripts (such as a zc.recipe.egg generated python interpreter) in the buildout.