Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install -r requirements.txt from puppet?

Tags:

python

pip

puppet

I have a pip style requirements.txt file I use for keeping track of my python dependencies, I'm moving my dev environment over to vagrant + puppet. So far I've been using the pip provider built into puppet to install individual packages like this:

package {
  ["django", "nose"]:
      ensure => present,
      provider => pip
}

Is it possible to pass in my requirements.txt instead and have puppet keep the packages up to date whenever that file changes?

like image 666
piohhmy Avatar asked Jan 29 '14 01:01

piohhmy


People also ask

Does pip use requirements txt?

Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are often called “pip requirements. txt files”, since requirements. txt is usually what these files are named (although, that is not a requirement).

Where is pip requirements txt?

Typically the requirements. txt file is located in the root directory of your project. Notice we have a line for each package, then a version number. This is important because as you start developing your python applications, you will develop the application with specific versions of the packages in mind.

Where should I place requirements txt?

Save the Python requirements. txt file in the project source code repository so that other developers can easily install all of the Python modules and packages when they clone or check out your project. Use the pip install -r requirements.


1 Answers

Yes it is possible. Instead of defining a package resource, define a "exec" resource instead that will take the requirements.txt as variable and runs the pip install command.

E.g.

class pip_install(
 $path_requirements_file,
){

  exec { "pip_requirements_install":
    command     => "pip install -r ${path_requirements_file}",
    refreshonly => true,
  }

}
like image 173
cocheese Avatar answered Sep 23 '22 13:09

cocheese