3

I'm currently developing a web site in django. I have created a virtualenv within which my pip installs exist. I am versioning my site in source control. The /lib folder is ignored in VCS, where the pip-installed files are kept. But I now have a django app that i have installed via pip that contains database information. So now part of my migrations are not under version control.

I have not deployed any staging or production environment, and I'm the sole dev. But I'll be doing deployment work soon™. And I need to get these migrations under VCS as soon as I can.

My question is how do I version control migrations (and potentially other things) for 3rd-party django apps? I could potentially:

  • version just the migrations folder in the virtualenv.
  • version the entire virtualenv? The /lib folder is 36mb...not anything insane right now.
  • something else? I'm newish to python and so I'm not exactly sure how this works.
Chris Hill
  • 1,914
  • 1
  • 16
  • 24

2 Answers2

2

The majority of third party apps that have models should also ship with migrations for those models. If there is an app which doesn't then you probably need to report that to the app maintainer. You should not have to make migrations for a third party app unless you have explicitly modified/subclassed its models (this is not that common).

Same goes for anything else in third-party libraries. Your version control should be limited to pinning your project to a particular version of the third party library, and should not really have to store anything else.

This is commonly done using a requirements.txt file in your project which lists all the third party dependencies. This file can then be used to rebuild the virtual environment consistently across platforms.

solarissmoke
  • 30,039
  • 14
  • 71
  • 73
0

You should not add pip apps to your version control, you should just run pip install on the production machine. You can pass the version number to pip so you always get the same version pip install requests==2.9.1. The folder your pip installed libraries should be installed in should be outside your VCS completely, the default is something like /usr/lib64/python2.7/site-packages so you either added way too much to your VCS or hacked the pip install path. If you explain better how you got the pip apps into your project directory we might be able to help you get them out.

P.S. You do not own the trade mark on deployment work soon :)

dotcomly
  • 2,154
  • 23
  • 29
  • Haha! I don't? Dammit! Thanks for the reply. I haven't added my pip installs to my vcs, they are ignored. I'm using virtualenv, so the install folder is local, instead of in /usr/lib*. Buut I think I have a solution to my issue is that my 'problem' is not a problem and I don't need to track the migrations of 3rd party apps because they shouldn't require migrations. – Chris Hill Jul 09 '16 at 01:28
  • OK, still not sure how your dev is setup (virtualenv is vague) but either way, you can just keep doing what you are doing and keep the ignore. When you deploy to production just pip install there. Some pip apps might use migrations but you will not need to modify them so the ones they come with will be applied the first time and if you upgrade through pip. – dotcomly Jul 09 '16 at 01:29