Manage python modules repeatedly updated in both l

2019-09-14 18:38发布

I like to edit python modules installed with pip. But, I do not know good way to avoid conflicts between local update and original one when upgrade a module.

For example,

$ pip install some_module
$ vim ~/.../some_module/something.py # update the file
$ pip install --upgrade some_module

It should occurs some trouble because of conflicts between local and original repository. (The assumption that original repo is on github is OK)

I guess One of alternatives is forking repository on github and pip install git+<repo_url>, but I'm not have confident.

What is good way to avoid this trouble?

标签: python git pip
1条回答
smile是对你的礼貌
2楼-- · 2019-09-14 19:18

You should not be editing the core files of a module, if you need to modify it you should be extending (subclassing) it and over-riding the functionality and adding your own functions, that way your code is separate from the repo's code and won't be over-written by an update or upgrade

You could also Use a virtual environment, a virtual environment is an isolated python installation/environment, it makes it easy to manage dependencies and different version of libraries/ version of python

this should get you started

http://docs.python-guide.org/en/latest/dev/virtualenvs/

查看更多
登录 后发表回答