Search code examples
pythondeploymentpackaging

How would I package and deploy Python application like Mercurial hooks?


In this case, the application consists of one or more Python files, plus a settings.ini file. Now the Python files when being installed need to be installed in ~/.hg (as default) or prompted where the user want them installed. The installation also requires text to be appended to files like hgrc. Is there already a specific Python package that does all of this, or if anyone has any experience in this area please share.

As far as I have looked, Python packaging refers to setuptools and easy_install. The basis for packaging is a setup.py file. A problem with this is that such a setup file is used for a couple of dissimilar tasks:

  • Generating documentation.
  • Creating a release (source/binary).
  • Actually installing the software.

Combining these tasks in one file is a bit of a hazard and leads to problems now and then. or distutils, but I am not sure if these packages support the notion of user prompting and deployment like appending text to existing files, and creating new ones.


Solution

  • I would include a custom script (bin/ command) which will poke the users' .hgrc and others. Doing it without the user consent would be rude.

    User story

    • Install package: easy_install pkgname and this deploys myproject-init-hg (UNIX executable, can be also written in Python)

    • The installation finished and tells the user to run commmand myproject-init-hg

    setup.py include mechanism to distribute and deploy bin/ style scripts.