Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

git - Manage python modules repeatedly updated in both local and original repository

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...