Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Template for custom Distutils commands with dependencies
"""Template for custom Distutils commands with dependencies"""
from distutils.core import Command
commands = {}
try:
from third_party_package import something
class MyCommand(Command):
description = "Use ThirdPartyPackage™ to frob the project source"
user_options = []
def initialize_options(self):
"""Use this to set option defaults before parsing."""
pass
def finalize_options(self):
"""Code to validate/modify command-line/config input goes here."""
pass
def run(self):
"""Your actual command functionality goes here."""
something.frob(self.distribution.packages)
commands['frobnicate'] = MyCommand
except ImportError:
pass
# from distutils.core import setup
# setup(..., cmdclass=commands)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment