-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better way of compiling javascript sources in setuptools
- Loading branch information
Showing
3 changed files
with
69 additions
and
29 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,65 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import os | ||
import subprocess | ||
from pathlib import Path | ||
from setuptools import setup | ||
|
||
|
||
# HACK: Compile the webapp sources | ||
subprocess.run( | ||
[ | ||
"docker", | ||
"run", | ||
"--rm", | ||
f"-v={Path(__file__).parent}:/shared", | ||
"-w=/shared", | ||
"diracgrid/dirac-distribution", | ||
"/dirac-webapp-compile.py", | ||
"-D=/shared/src", | ||
"-n=WebAppDIRAC", | ||
], | ||
check=True | ||
) | ||
|
||
# This is required to allow editable pip installs while using the declarative configuration (setup.cfg) | ||
setup() | ||
|
||
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly | ||
# update it when the contents of directories change. | ||
if os.path.exists('MANIFEST'): os.remove('MANIFEST') | ||
|
||
from setuptools import Command, setup | ||
# Note: distutils must be imported after setuptools | ||
from distutils import log | ||
from setuptools.command.develop import develop as _develop | ||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel | ||
|
||
|
||
class build_extjs_sources(Command): | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def get_inputs(self): | ||
return [] | ||
|
||
def get_outputs(self): | ||
return [] | ||
|
||
def run(self): | ||
path = os.path.abspath(os.getcwd()) | ||
cmd = [ | ||
"docker", | ||
"run", | ||
"--rm", | ||
f"-v={path}:/shared", | ||
"-w=/shared", | ||
"diracgrid/dirac-distribution", | ||
"/dirac-webapp-compile.py", | ||
"-D=/shared/src", | ||
"-n=WebAppDIRAC", | ||
] | ||
log.info('> %r', cmd) | ||
subprocess.check_call(cmd) | ||
|
||
|
||
class develop(_develop): | ||
def run(self): | ||
self.run_command("build_extjs_sources") | ||
super().run() | ||
|
||
|
||
class bdist_wheel(_bdist_wheel): | ||
def run(self): | ||
self.run_command("build_extjs_sources") | ||
super().run() | ||
|
||
|
||
cmdclass = { | ||
"develop": develop, | ||
"bdist_wheel": bdist_wheel, | ||
"build_extjs_sources": build_extjs_sources, | ||
} | ||
|
||
setup(cmdclass=cmdclass) |