Last active
December 6, 2022 22:00
-
-
Save drmalex07/866df4bb235ddd5ecf6f to your computer and use it in GitHub Desktop.
Provide a custom setuptools command. #setuptools #distutils #setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup, find_packages | |
from distutils.cmd import Command | |
class Foo(Command): | |
description = "Run foo command" | |
user_options = [ | |
('baz=', None, 'Baz Option'), | |
('dry-run', None, 'Dry run'), | |
] | |
def initialize_options(self): | |
self.baz = -1 | |
self.dry_run = False | |
def finalize_options(self): | |
self.baz = int(self.baz) | |
self.dry_run = bool(self.dry_run) | |
def run(self): | |
print 'Running foo with baz=%d, dry=%r' % (self.baz, self.dry_run) | |
setup( | |
name='helloworld', | |
... | |
cmdclass = { | |
'foo': Foo | |
}, | |
... | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment