Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it practical to put Python under version control?

Where practical, I like to have tools required for a build under version control. The ideal is that a fresh checkout will run on any machine with a minimal set of tools required to be installed first.

Is it practical to have Python under version control?

How about python packages? My naive attempt to use Sphinx without installing it fails due to a dependency on Docutils. Is there a way to do use it without installing?

like image 832
Ergwun Avatar asked Dec 15 '22 22:12

Ergwun


2 Answers

Look at virtualenv and buildout for these needs.

virtualenv lets you isolate the Python that is running your project from any other packages installed with that version of Python. So if your project needs Python x.y the only pre-requisite is that you need to ensure that there is a copy of that version of Python available on the system. Any packages you install within the virtualenv are completely isolated from packages installed outside it.

buildout lets you specify package dependencies, so if you need sphinx to build your documentation you just include this in your buildout.cfg file:

parts =
  sphinx

[sphinx]
recipe = collective.recipe.sphinxbuilder

and when you run buildout it will install collective.recipe.sphinxbuilder, download and install docutils and sphinx within the virtualenv, and build your docs.

Your buildout.cfg can include all of the dependencies required to get your system running from an initial checkout of the folder containing the buildout.cfg and a bootstrap.py file. It makes setting up a system for development or final deployment really easy.

like image 109
Duncan Avatar answered Dec 28 '22 06:12

Duncan


No, just like a compiler the python interpreter should be installed system-wide. The same thing applies to tools such as sphinx and docutils (which is most likely installed when installing sphinx via your distribution's package manager).

The same applies to most python packages, especially those that are used by the application itself and available via PyPi.

like image 34
ThiefMaster Avatar answered Dec 28 '22 07:12

ThiefMaster