Skip to main content

Introduction

disthelper is a command line tool that helps you manage a Python distribution. You may want to create Python scripts to automate common maintenance tasks for your project. But where do you put them? How about the standard setup.py framework? You can think of setup.py as a “make” tool for Python, although it’s more like how Ian Bicking describes it and less like an actual make tool with targets and dependencies. For example, if you wrote a script to build your project docs and another to upload them, you could run these commands from your setup.py file:

python setup.py build_docs upload_docs

What it does

disthelper just automates the use of distutils so you don’t have to think about how to create a custom setup.py command. It sets up the module / submodule structure, edits your setup.cfg, and adds new command modules as you request them. disthelper doesn’t do anything you couldn’t do by hand.

Install

You can easy_install it:

easy_install disthelper

Or grab the source

Create a command

disthelper is implemented as a Paste extension. Let’s say you want to create this build_docs command I mentioned. cd into your project directory and type:

$ paster distcmd build_docs
| Selected and implied templates:
|   disthelper#distcmd  A disthelper-based package for setup.py commands
|
| ** creating ./setup.py (you'll probably need to edit this)
| Variables:
|   command:       build_docs
|   distcmds_mod:  distcmds
|   package:       foo
| Creating template distcmd
|   Recursing into +package+
|     Creating ./foo/
|     Recursing into +distcmds_mod+
|       Creating ./foo/distcmds/
|       Copying +command+.py_tmpl to ./foo/distcmds/build_docs.py
|       Copying __init__.py to ./foo/distcmds/__init__.py
|     Copying __init__.py to ./foo/__init__.py
| patching ./setup.cfg ...
|
| ./foo/distcmds/build_docs.py
| ...is ready to edit
| run as:
|     python setup.py build_docs
|

If you don’t already have a Python package it will prompt you for its name. Assuming you named your package foo, you should see the following layout:

$ tree
| .
| |-- foo
| |   |-- __init__.py
| |   `-- distcmds
| |       |-- __init__.py
| |       `-- build_docs.py
| |-- setup.cfg
| `-- setup.py
|
| 2 directories, 5 files

Your command is ready to run:

$ python setup.py build_docs --help
| Global options:
|   --verbose (-v)  run verbosely (default)
|   --quiet (-q)    run quietly (turns verbosity off)
|   --dry-run (-n)  don't actually do anything
|   --help (-h)     show detailed help message
|
| Options for 'build_docs' command:
|   --long-option (-l)        <help>
|   --other-long-option (-o)  <help>
|
| usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
|    or: setup.py --help [cmd1 cmd2 ...]
|    or: setup.py --help-commands
|    or: setup.py cmd --help
|

However, it doesn’t do anything useful yet so get to it!

My command disappeared, what do I do?

Unfortunately, distutils will completely ignore any ImportError in your command so one day your command might simply disappear. To check that your command is set up correctly, run:

$ paster distcmd build_docs --check
| Selected and implied templates:
|   disthelper#distcmd  A disthelper-based package for setup.py commands
|
| Variables:
|   command:       build_docs
|   distcmds_mod:  distcmds
|   package:       foo
| attempting to import foo.distcmds.build_docs
| OK
| checking vars in ./setup.cfg
|
| build_docs OK

Other make like tools

disthelper isn’t designed for complex builds, dependency management, etc, it just helps you create maintenance scripts. You may want to check out…

  • Vellum

    • Vellum is a simple build tool like make but written in Python using a simple yet flexible YAML based format.

  • SCONS

    • A software construction tool

  • zc.buildout

    • System for managing development buildouts

Changelog

  • 0.9.2

    • fixed another bug in generating setup.py files

    • added shelldoc support for functional tests (README examples)

  • 0.9.1

    • fixed handling of setup.py file when one doesn’t already exist

  • 0.9

    • first release, basic paster command working

Release files for disthelper 0.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for disthelper 0.9.2
File Size Uploaded
disthelper-0.9.2.tar.gz 11.2 kB Details

Release files / disthelper-0.9.2.tar.gz

Download URL disthelper-0.9.2.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8a14230c2925d7025bca990195bdabdd34cfacba1630265a2728339bb29c64bd
BLAKE2b-256 checksum
How to use checksums
2e51b9b13f2281979f497fe0da01cb7443f13de89a7a0318f13ab9bdf5aaaac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9.2 This release

1 release file

0.9.1

1 release file

0.9

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page