Why run setup.py, can I just paste in the code?
I am writing a python CLI application that has dependencies on several libraries (Paramiko, etc.). If I download their source and just place them under my main application source, I can import them and everything works fine. Why would I ever run setup.py installations or work with python package managers?
I understand that when deploying server side applications, it is quite normal for an administrator to run easy_install / pip commands etc. to install prerequsites, but for script like CLI applications that need to be distributed as standalone applications that only depend on python binaries, what is the recommended approach?
source to share
A few reasons:
-
Not all packages are pure-python packages. Easily include C extensions in your package and
setup.py
automate the compilation process. -
Automatic dependency management; dependencies are declared and set to have the installer tools (
pip
,easy_install
,zc.buildout
). Dependencies can also be declared dynamically (try importingjson
, if that fails, declare a dependency onsimplejson
, etc.). -
Custom resource installation preferences. The installation process is highly customizable and dynamic. The same applies to dependency detection;
cx_Oracle
has to jump over quite a few hoops to make installation easier with all the different platforms and quirks of Oracle library distribution options that need to be supported, for example.
Why do you still want to do this for CLI scripting? It depends on how important the CLI is to you; will you support this in the coming years? Then I use it anyway setup.py
because it documents what the dependencies are, including the minimum version requirements. You can add tests ( python setup.py test
) and easily deploy them to new locations or update dependencies.
source to share