Managing sys.path for multiple developers

后端 未结 1 411
忘了有多久
忘了有多久 2021-01-23 22:11

The problem I\'m facing is small but annoying:

A colleague is working on one project in version control system X (VCS-X). Another colleague is working in another versi

相关标签:
1条回答
  • 2021-01-23 22:31

    Nobody should be doing sys.path.append! This is a workflow problem that you should address first and foremost.

    In this situation it will be appropriate to package the toolbox into a distribution. The developer who just wants to use the code from toolbox, i.e. via an import statement or command line script, will execute:

    pip install --user toolbox
    

    The developer who wants to work on the toolbox code should also be using pip install. However, this developer should clone the repo, create/activate a virtual environment, and execute:

     pip install --editable .
    

    In both situations, pip will sort out the necessary sys.path stuff for you in the correct way.

    Follow the PyPA Python Packaging User Guide for the details on how to create a distribution.

    0 讨论(0)
提交回复
热议问题