Uruchamianie niestandardowej kompilacji setuptools podczas instalacji
Próbowałem zaimplementować kompilację kompasu podczas setuptools 'build
, ale poniższy kod uruchamia kompilację podczas jawnegobuild
polecenie i nie działa podczasinstall
.
#!/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,
},
)
Wszelkie niestandardowe instrukcje na stronieBuild.run
(np. drukowanie) nie ma zastosowania podczasinstall
też, aledist
instancja zawiera wcommands
przypisuj tylko mojebuild
instancje implementacji poleceń. Niesamowite! Ale myślę, że problem leży w złożonych relacjach międzysetuptools
idistutils
. Czy ktoś wie, jak wykonać niestandardowy bieg podczas budowyinstall
w Pythonie 2.7?
Aktualizacja: Znalazłem toinstall
zdecydowanie nie dzwonibuild
polecenie, ale dzwonibdist_egg
który biegniebuild_ext
. Wygląda na to, że powinienem wdrożyć rozszerzenie kompilacji „Compass”.