Mark py3 venv as default buildpack

pull/42/head
yuvipanda 2017-07-29 17:14:49 -07:00
rodzic b23f088ae8
commit b187df0637
3 zmienionych plików z 30 dodań i 13 usunięć

Wyświetl plik

@ -19,7 +19,7 @@ import escapism
from traitlets.config import Application, LoggingConfigurable from traitlets.config import Application, LoggingConfigurable
from traitlets import Type, Bool, Unicode, Dict, List, default from traitlets import Type, Bool, Unicode, Dict, List, default, Tuple
import docker import docker
from docker.utils import kwargs_from_env from docker.utils import kwargs_from_env
@ -81,6 +81,15 @@ class Repo2Docker(Application):
""" """
) )
default_buildpack = Tuple(
(BaseImage, PythonBuildPack),
config=True,
help="""
The build pack to use when no buildpacks are found
"""
)
cleanup_checkout = Bool( cleanup_checkout = Bool(
True, True,
config=True, config=True,
@ -299,11 +308,16 @@ class Repo2Docker(Application):
) )
os.chdir(checkout_path) os.chdir(checkout_path)
picked_buildpack = c(self.default_buildpack)
for bp_spec in self.buildpacks: for bp_spec in self.buildpacks:
bp = c(bp_spec) bp = c(bp_spec)
if bp.detect(): if bp.detect():
picked_buildpack = bp
break
self.log.info('Using %s builder\n', bp.name, extra=dict(phase='building')) self.log.info('Using %s builder\n', bp.name, extra=dict(phase='building'))
for l in bp.build(self.output_image_spec): for l in picked_buildpack.build(self.output_image_spec):
if 'stream' in l: if 'stream' in l:
self.log.info(l['stream'], extra=dict(phase='building')) self.log.info(l['stream'], extra=dict(phase='building'))
elif 'error' in l: elif 'error' in l:
@ -311,9 +325,6 @@ class Repo2Docker(Application):
sys.exit(1) sys.exit(1)
else: else:
self.log.info(json.dumps(l), extra=dict(phase='building')) self.log.info(json.dumps(l), extra=dict(phase='building'))
break
else:
raise Exception("No builder found!")
if self.repo_type != 'local' and self.cleanup_checkout: if self.repo_type != 'local' and self.cleanup_checkout:
shutil.rmtree(checkout_path) shutil.rmtree(checkout_path)

Wyświetl plik

@ -537,7 +537,7 @@ class PythonBuildPack(BuildPack):
return [] return []
def detect(self): def detect(self):
return os.path.exists('requirements.txt') and super() return os.path.exists('requirements.txt') and super().detect()
class CondaBuildPack(BuildPack): class CondaBuildPack(BuildPack):
name = "conda" name = "conda"

Wyświetl plik

@ -0,0 +1,6 @@
#!/usr/bin/env python
# Verify that the default just provides a py3 environment with jupyter
import sys
assert sys.version_info[:2] == (3, 5)
import jupyter