2

I have a custom command called CustomCSS defined in my setup.py file. The command takes two arguments, and does some processing on it. The arguments are defined like:

class CustomCSS(BaseCommand):
    description = "Site level customizations"
    user_options = [
        ('css=', None, 'Specify the path to the custom css file'),
        ('logo=', None, 'Specify the logo to use'),
    ]

In my run method, I can use these arguments like:

def run(self):
    if not self.should_run():
        print('No Custom CSS or logo')
        return

My command mapping is:

setup_args['cmdclass'] = {
    'custom': CustomCSS,
    'js': Bower,
    'css': CSS,
    'build_py': js_css_first(build_py, strict=is_repo),
    'sdist': js_css_first(sdist, strict=True),
    'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled,
}

This command works on it's own independently, and accepts the arguments. However, I also need to run this command with python setup.py develop. I managed to add the command to run with python setup.py develop using the following code:

from setuptools.command.develop import develop
class develop_js_css(develop):
    def run(self):
        if not self.uninstall:
            self.distribution.run_command('custom')
            self.distribution.run_command('js')
            self.distribution.run_command('css')

However, the develop command does not accept arguments. I tried adding arguments using the same syntax as the CustomCSS command, but the command refuses the arguments.

Is there a way I can pass the arguments to the develop command?

Saurabh Sood
  • 213
  • 1
  • 2
  • 9

0 Answers0