-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from pybee/topic/im
Initial cut for django briefcase target
- Loading branch information
Showing
3 changed files
with
107 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import shutil | ||
import subprocess | ||
|
||
try: | ||
from urllib.request import urlopen | ||
except ImportError: # Python 2 compatibility | ||
from urllib2 import urlopen | ||
|
||
import pip | ||
|
||
from .app import app | ||
|
||
|
||
class django(app): | ||
description = "Create a django app to wrap this project" | ||
|
||
def finalize_options(self): | ||
# Copy over all the options from the base 'app' command | ||
finalized = self.get_finalized_command('app') | ||
for attr in ('formal_name', 'bundle', 'icon', 'guid', 'description', 'class_name', 'secret_key'): | ||
if getattr(self, attr) is None: | ||
setattr(self, attr, getattr(finalized, attr)) | ||
|
||
# Set platform-specific options | ||
self.platform = 'Django' | ||
|
||
if self.dir is None: | ||
self.dir = "django" | ||
|
||
self.resource_dir = self.dir | ||
|
||
# Django has no support package | ||
self.skip_support_pkg = True | ||
|
||
@property | ||
def app_dir(self): | ||
return os.path.join(os.getcwd(), self.dir) | ||
|
||
def install_icon(self): | ||
raise RuntimeError("Django doesn't support icons.") | ||
|
||
def install_splash(self): | ||
raise RuntimeError("Django doesn't support splash screens.") | ||
|
||
def install_support_package(self): | ||
pass | ||
|
||
def install_platform_requirements(self): | ||
print(" * Installing plaform requirements...") | ||
|
||
if self.app_requires: | ||
pip.main([ | ||
'install', | ||
'--upgrade', | ||
'--force-reinstall', | ||
] + self.app_requires | ||
) | ||
else: | ||
print("No platform requirements.") | ||
|
||
def install_extras(self): | ||
# Install additional elements required for Django | ||
print(" * Installing extras...") | ||
print(" - Installing NPM requirements...") | ||
|
||
npm = shutil.which("npm") | ||
subprocess.Popen([npm, "install"], cwd=os.path.abspath(self.dir)).wait() | ||
|
||
print(" - Building Webpack assets...") | ||
subprocess.Popen([npm, "run", "build"], cwd=os.path.abspath(self.dir)).wait() |
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