I have 2 Heroku apps, both Pyhon, and some python modules that are shared between them (i.e.: they are the same in both apps). What is the best way to set up my git / requirements.txt to achieve the following?
My gut feeling tells me I need to have the shared code as a Python package, on disk, and in development add it to each app's PYTHONPATH. Further, I would add it (how? using a private server? from s3? as a vendor dir?) to the requriments.txt on each app.
... but I can't quite nail it.
Any thoughts?
You can use pip requirements files to do that. You may have one for local development and one for your apps. Please check out the requirements file format for more info.
file:///path/to/your/lib/project#egg=MyProject
This should give you readonly access from your app, which is useful for shared code (e.g. git clone of a project). Please note that it will point to HEAD. This should fit requirements 1, 2, 3.
For the project layout, you can check out the setuptools documentation; e.g. create a setup.py and a package with your code in it. You can look at the requests library which is a good example.
git://git.myproject.org/MyProject.git#egg=MyProject
This should pick up whatever code you pushed to your repo. I don't have experience with Heroku, but if they support requirements file that should just work. This should fit requirement 1, and I hope 4.
If you want to use private git repo with heroku, please refer to heroku documentation (please note that it is username:password basic auth and does not have email address). If you don't want to use a password you can use a revocable OAuth token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With