0

When installing a python package via pip, can I make the folder in which this package is installed a git repo by default?

After installing a package with pip (like pip install numpy --user) I frequently change lines of code in the site-packages folder in which it is installed. After some time, I invariably lose track of the changes I have made, and regret not having tracked the folder with git. Can I make every folder in site-packages containing a package installed with pip a git repo by default? (If I recall correctly, the package management system of Julia had such a facility, for example.)

fabian
  • 1,062
  • 1
  • 8
  • 18
  • https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch – Chris_Rands Sep 08 '20 at 17:52
  • 2
    @fabian No, there is no automatic way. Why do you change installed packages? Is it something that should be reported upstream? – phd Sep 08 '20 at 18:00
  • @Chris_Rands The question is not how to install from a git repo but how to create a new git repo for every installed package to track local changes. – phd Sep 08 '20 at 18:01
  • Thanks @phd for your reply! What a pity there is no automatic way. I wonder if there was a simply way to write a bash script modifying the standard `pip` command, but I guess that's too complicated. (I often just try to understand the detailed workings of a few calls now and then and modifying the code sometimes helps me to understand the essential parts.) – fabian Sep 08 '20 at 18:20
  • I'm still not sure what you're trying to do here. Do you want to track the version of each package installed via pip? Or are you trying to develop a python application that installs to your system via `pip`? – Praveen Premaratne Sep 08 '20 at 18:56
  • 1
    Also, why are you changing the source code of packages in the `site-packages`? Are you trying to install multiple versions of the same package on your system? – Praveen Premaratne Sep 08 '20 at 19:00
  • Thanks @PraveenPremaratne for your reply! I want to track the version of a package installed via pip which I modify slightly. Most often its because I install a package which is interesting though not mature, barely mantained, and some function calls crash. Then, I sometimes go into the package and modify the source code with a little hack. – fabian Sep 08 '20 at 19:32
  • For this sort of thing, the only thing I can think of is to clone the repo of the package and install manually or use a [virtualenv](https://virtualenv.pypa.io/en/latest/index.html) to isolated python environments or to use [pip download](https://pip.pypa.io/en/stable/reference/pip_download/) to make a copy at a location of your choice and install from there. Unfortunately, none of these approaches version controls things so you'd need to do that by hand. – Praveen Premaratne Sep 08 '20 at 20:04

0 Answers0