简体   繁体   中英

Git Best Practice: How to structure multiple python modules needed for one large app

I have created a flask app that uses python modules that have been created by others in my team. To make it work on my pycharm I download the modules and load them in [either using init.py files or using full references] to use them.

I want to understand what is the best way to store this kind of flask app and the python modules its references so that when someone downloads the app it can get all it needs. And very importantly keeping the flask app stuff [like app.py and html] completely separate from the python modules.

Currently my app.py just calls the functions in these python modules, so it has a degree of independence but I want to make sure I follow best practices and make it easy for my team to make changes to these modules and for me to update myself with these changes.

In summary, what is the best way to store / use / update flask apps that are dependent on other python modules on GitHub and how one can then use this GitHub organization to easily setup part of the whole application on their local system?

I would say you can make a repository per module and one for your application.

The modules are dependencies of your application.

You can define a dependency from github in a requirement.txt like this:

git+git://github.com/path/to/my-module@master#egg=my-module
SomeOtherPackage==1.0.4

You can specify a branch , a commit , a tag , a release .

See How to state in requirements.txt a direct github source for more details and the requirements files documentation .


When you want to update a module you push it in its own repository and then on your application you can update the requirement.txt to update the commit hash the tag or the release or whatever you used if it needs to be updated and then just reinstall the dependency.


Another solution instead of installing them as dependencies with pip you could use Git Submodules . The modules are still separated in their own repositories and these repositories are available inside your application repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM