kopia lustrzana https://github.com/jupyterhub/repo2docker
Support setup.py in Python buildpacks
rodzic
02eb7970b6
commit
821514c474
|
@ -117,20 +117,28 @@ class PythonBuildPack(BaseImage):
|
||||||
# will be installed in python3 venv. This is less of a
|
# will be installed in python3 venv. This is less of a
|
||||||
# surprise than requiring python2 to be requirements2.txt tho.
|
# surprise than requiring python2 to be requirements2.txt tho.
|
||||||
assemble_scripts = super().get_assemble_scripts()
|
assemble_scripts = super().get_assemble_scripts()
|
||||||
|
setup_py = self.binder_path('setup.py')
|
||||||
try:
|
try:
|
||||||
with open(self.binder_path('runtime.txt')) as f:
|
with open(self.binder_path('runtime.txt')) as f:
|
||||||
runtime = f.read().strip()
|
runtime = f.read().strip()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
runtime = 'python-3.5'
|
runtime = 'python-3.5'
|
||||||
if runtime == 'python-2.7':
|
if runtime == 'python-2.7':
|
||||||
|
pip = "pip2"
|
||||||
requirements_file = self.binder_path('requirements3.txt')
|
requirements_file = self.binder_path('requirements3.txt')
|
||||||
else:
|
else:
|
||||||
|
pip = "pip3"
|
||||||
requirements_file = self.binder_path('requirements.txt')
|
requirements_file = self.binder_path('requirements.txt')
|
||||||
if os.path.exists(requirements_file):
|
if os.path.exists(requirements_file):
|
||||||
assemble_scripts.append((
|
assemble_scripts.append((
|
||||||
'${NB_USER}',
|
'${NB_USER}',
|
||||||
'pip3 install --no-cache-dir -r "{}"'.format(requirements_file)
|
'pip3 install --no-cache-dir -r "{}"'.format(requirements_file)
|
||||||
))
|
))
|
||||||
|
if os.path.exists(setup_py):
|
||||||
|
assemble_scripts.append((
|
||||||
|
'${NB_USER}',
|
||||||
|
'{} install . "{}"'.format(pip, setup_py)
|
||||||
|
))
|
||||||
return assemble_scripts
|
return assemble_scripts
|
||||||
|
|
||||||
def detect(self):
|
def detect(self):
|
||||||
|
@ -138,6 +146,7 @@ class PythonBuildPack(BaseImage):
|
||||||
"""
|
"""
|
||||||
requirements_txt = self.binder_path('requirements.txt')
|
requirements_txt = self.binder_path('requirements.txt')
|
||||||
runtime_txt = self.binder_path('runtime.txt')
|
runtime_txt = self.binder_path('runtime.txt')
|
||||||
|
setup_py = 'setup.py'
|
||||||
|
|
||||||
if os.path.exists(runtime_txt):
|
if os.path.exists(runtime_txt):
|
||||||
with open(runtime_txt) as f:
|
with open(runtime_txt) as f:
|
||||||
|
@ -146,6 +155,8 @@ class PythonBuildPack(BaseImage):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
if not os.path.exists('binder') and os.path.exists(setup_py):
|
||||||
|
return True
|
||||||
return os.path.exists(requirements_txt)
|
return os.path.exists(requirements_txt)
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,7 +261,7 @@ class Python2BuildPack(PythonBuildPack):
|
||||||
requirements_txt = self.binder_path('requirements.txt')
|
requirements_txt = self.binder_path('requirements.txt')
|
||||||
assemble_scripts = super().get_assemble_scripts()
|
assemble_scripts = super().get_assemble_scripts()
|
||||||
if os.path.exists(requirements_txt):
|
if os.path.exists(requirements_txt):
|
||||||
assemble_scripts.append((
|
assemble_scripts.insert(0, (
|
||||||
'${NB_USER}',
|
'${NB_USER}',
|
||||||
'pip2 install --no-cache-dir -r "{}"'.format(requirements_txt)
|
'pip2 install --no-cache-dir -r "{}"'.format(requirements_txt)
|
||||||
))
|
))
|
||||||
|
|
Ładowanie…
Reference in New Issue