Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing entrypoint accounting for WORKDIR #115

Merged
merged 3 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The client here will eventually be released as "spython" (and eventually to
singularity on pypi), and the versions here will coincide with these releases.

## [master](https://github.com/singularityhub/singularity-cli/tree/master)
- working directory, the last one defined, should be added to runscript (0.0.61)
- adding deprecation message for image.export (0.0.60)
- adding --force option to build
- fixing warning for files, only relevant for sources (0.0.59)
Expand Down
10 changes: 8 additions & 2 deletions spython/main/parse/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def create_runscript(self, default="/bin/bash", force=False):

# Entrypoint should use exec
if not entrypoint.startswith('exec'):
entrypoint = "exec %s" %entrypoint
entrypoint = "exec %s" % entrypoint

# Should take input arguments into account
if not re.search('"?[$]@"?', entrypoint):
entrypoint = '%s "$@"' %entrypoint
entrypoint = '%s "$@"' % entrypoint
return entrypoint


Expand Down Expand Up @@ -209,6 +209,12 @@ def docker2singularity(self, runscript="/bin/bash", force=False):

# Take preference for user, entrypoint, command, then default
runscript = self._create_runscript(runscript, force)

# If a working directory was used, add it as a cd
if self.workdir != None:
vsoch marked this conversation as resolved.
Show resolved Hide resolved
runscript = [self.workdir] + [runscript]

# Finish the recipe
recipe += finish_section(runscript, 'runscript')

if self.test is not None:
Expand Down
9 changes: 6 additions & 3 deletions spython/main/parse/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class DockerRecipe(Recipe):

def __init__(self, recipe=None):
'''a Docker recipe parses a Docker Recipe into the expected fields of
labels, environment, and install/runtime commands
labels, environment, and install/runtime commands. We save working
directory as we parse, and the last one can be added to the runscript
of a Singularity recipe.

Parameters
==========
Expand Down Expand Up @@ -203,7 +205,7 @@ def expandPath(path):
return os.getcwd() if path == "." else path

# Warn the user Singularity doesn't support expansion
if source.contains('*'):
if '*' in source:
bot.warning("Singularity doesn't support expansion, * found in %s" % source)

# Warning if file/folder (src) doesn't exist
Expand Down Expand Up @@ -318,8 +320,9 @@ def _workdir(self, line):
line: the line from the recipe file to parse for WORKDIR

'''
# Save the last working directory to add to the runscript
workdir = self._setup('WORKDIR', line)
line = "cd %s" %(''.join(workdir))
self.workdir = "cd %s" %(''.join(workdir))
self.install.append(line)
vsoch marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
1 change: 1 addition & 0 deletions spython/main/parse/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def parse(self):
self.ports = []
self.test = None
self.volumes = []
self.workdir = None

if self.recipe:

Expand Down
2 changes: 1 addition & 1 deletion spython/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.


__version__ = "0.0.60"
__version__ = "0.0.61"
AUTHOR = 'Vanessa Sochat'
AUTHOR_EMAIL = 'vsochat@stanford.edu'
NAME = 'spython'
Expand Down