简体   繁体   中英

Python: incorporate git repo in project

What is best practice for incorporating git repositories into the own project which do not contain a setup.py? There are several ways that I could imagine, but it doesn't seem clear which is best.

  1. Copy the relevant code and include it into the own project

    pro:

    • Only use the relevant code,

    con:

    • git repo might be updated
    • need to do this for every project again
    • feels like stealing
  2. Cloning the repository and writing a setup.py and install it with pip

    pro:

    • easy
    • package can be updated
    • can use package like any normal pip package

    con:

    • feels weird
  3. Clone the repository and add the path to the project's search path

    pro:

    • easy
    • package can be updated

    con:

    • needing to adjust the search path also feels strange

In my opinion, you forgot the best option: Ask the original project maintainer to make the package available via pip . Since pip can install directly from git repositories this doesn't take more than a setup.py -- in particular, you don't need a PyPI account, you don't need to tag releases, etc.

If that's not possible then I would opt for your second option, ie provide my own setup.py file in a fork of the project. This makes incorporating upstream changes pretty easy (basically you simply git pull them from the upstream repo) and gives you all the benefits of package management (automatic installation, dependency management, etc.).

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