Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning custom setuptools build during install
    primarykey
    data
    text
    <p>I've tried to implement Compass compiling during setuptools' <code>build</code>, but the following code runs compilation during explicit <code>build</code> command and doesn't runs during <code>install</code>.</p> <pre class="lang-python prettyprint-override"><code>#!/usr/bin/env python import os import setuptools from distutils.command.build import build SETUP_DIR = os.path.dirname(os.path.abspath(__file__)) class BuildCSS(setuptools.Command): description = 'build CSS from SCSS' user_options = [] def initialize_options(self): pass def run(self): os.chdir(os.path.join(SETUP_DIR, 'django_project_dir', 'compass_project_dir')) import platform if 'Windows' == platform.system(): command = 'compass.bat compile' else: command = 'compass compile' import subprocess try: subprocess.check_call(command.split()) except (subprocess.CalledProcessError, OSError): print 'ERROR: problems with compiling Sass. Is Compass installed?' raise SystemExit os.chdir(SETUP_DIR) def finalize_options(self): pass class Build(build): sub_commands = build.sub_commands + [('build_css', None)] setuptools.setup( # Custom attrs here. cmdclass={ 'build': Build, 'build_css': BuildCSS, }, ) </code></pre> <p>Any custom instructions at <code>Build.run</code> (e.g. some printing) doesn't apply during <code>install</code> too, but <code>dist</code> instance contains in <code>commands</code> attribute only my <code>build</code> command implementation instances. Incredible! But I think the trouble is in complex relations between <code>setuptools</code> and <code>distutils</code>. Does anybody knows how to make custom building run during <code>install</code> on Python 2.7?</p> <p><strong>Update:</strong> Found that <code>install</code> definitely doesn't calls <code>build</code> command, but it calls <code>bdist_egg</code> which runs <code>build_ext</code>. Seems like I should implement "Compass" build extension.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload