diff --git a/CHANGELOG.md b/CHANGELOG.md index aa46d1b..a8f24e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Bugfix] Fix Dockerfile parsing on Windows + ## v10.5.0 (2020-11-19) - 💥[Improvement] Remove `dev/local pullimages`. Instead, run `dev/local dc pull`. diff --git a/tutor/commands/plugins.py b/tutor/commands/plugins.py index be2ee1d..f9d8775 100644 --- a/tutor/commands/plugins.py +++ b/tutor/commands/plugins.py @@ -117,7 +117,7 @@ def install(location): # Save file if not os.path.exists(plugins.DictPlugin.ROOT): os.makedirs(plugins.DictPlugin.ROOT) - with open(plugin_path, "w") as f: + with open(plugin_path, "w", newline="\n") as f: f.write(content) fmt.echo_info("Plugin installed at {}".format(plugin_path)) diff --git a/tutor/env.py b/tutor/env.py index 2a765cf..d8cabec 100644 --- a/tutor/env.py +++ b/tutor/env.py @@ -227,13 +227,15 @@ def write_to(content, path): """ Write some content to a path. Content can be either str or bytes. """ - open_mode = "w" - encoding = "utf8" + open_kwargs = {"mode": "w"} if isinstance(content, bytes): - open_mode += "b" - encoding = None + open_kwargs["mode"] += "b" + else: + # Make files readable by Docker on Windows + open_kwargs["encoding"] = "utf8" + open_kwargs["newline"] = "\n" utils.ensure_file_directory_exists(path) - with open(path, open_mode, encoding=encoding) as of: + with open(path, **open_kwargs) as of: of.write(content)