0

I have a repo with multiple sub-directories. Each sub-directory contains an app that's deployable to Heroku. To push the code off, I use git subtree, as suggested here.

This has worked well, and I want to continue in this direction by adding versioned APIs as deployable apps. The problem is that these APIs share substantial amounts of code.

Is there a way to have shared code in this setup, such that the apps are still deployable and the shared code is contained in the repo? The APIs are written in python, so something pip/virtualenv-specific would work.

Allegedly submodules work, but I'd prefer to avoid them as they've left a bad experience.

Community
  • 1
  • 1
ysimonson
  • 1,072
  • 2
  • 9
  • 16

1 Answers1

0

Never got an answer, so here's what I did.

I continued to use subtree instead of submodules. Then for each sub-project, I created two requirements.txt for pip: one for Heroku, one for running a sub-project locally. They look the same, minus the shared lib.

In the Heroku-based requirements.txt, the shared lib is specified like this:

-e git+https://username:password@github.com/org/repo.git#egg=sharedlib&subdirectory=sharedlib

This tells pip to pull the subdirectory sharedlib off repo from github.

In the requirements.txt for running the project locally, the shared lib is specified like this:

-e ../sharedlib

This tells pip to pull the localy subdirectory sharedlib from the repo.

Hope this helps!

ysimonson
  • 1,072
  • 2
  • 9
  • 16