Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add module from RPM as a requirement

So I have this project with many dependencies that are being installed from pip and are documented in requirements.txt I need to add another dependency now that doesn't exist on pip and I have it as an RPM in some address. What is the most Pythonic way to install it as a requirement? Thanks! The code will run on RHEL and Fedora

like image 534
Pavel Zagalsky Avatar asked Dec 28 '16 09:12

Pavel Zagalsky


People also ask

How do I download a module from requirements txt?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.


1 Answers

In this case, the Pythonic thing to do would be to simply fail if a dependency cannot be met. It's okay, and your users will appreciate a helpful error if they haven't satisfied a prerequisite for the installation. Consider the numerous Python packages out there with C library dependencies in order to be built and installed correctly. In your project, still declare all of your Python dependencies in your "setup.py" and "requirements.txt" files, but there's nothing in the Python packaging toolchain which will install an RPM for you (nor should it!), so just stop there and let the install fail if an RPM wasn't installed.

Aside from that, you may want to consider packaging your Python application itself as an RPM. You have RPM dependencies, and your target platform is Fedora/RHEL. By packaging your application as an RPM, you can declare dependencies on other RPMs which automates installation of those required packages. Worry about being Pythonic within the build phase of your RPM, and use RPM magic to do the rest.

I recommend against the use of configuration management tools (Puppet, Ansible, etc.), as they will overly complicate your build process. Those tools are great for their intended uses, but here it would be like using a cannon to swat a fly.

like image 196
Alex Smith Avatar answered Oct 03 '22 05:10

Alex Smith