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

Make Latexrun work on Windows #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions latexrun
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class DB:
json.dump(self.__val, fp, indent=2, separators=(',', ': '))
fp.flush()
os.fsync(fp.fileno())
os.rename(tmp_filename, self.__filename)
os.replace(tmp_filename, self.__filename)

def get_summary(self, task_id):
"""Return the recorded summary for the given task or None."""
Expand Down Expand Up @@ -833,6 +833,8 @@ class LaTeX(Task):
data = os.read(stdout.fileno(), 4096)
if not data:
break
if os.name == 'nt':
data = data.replace(b'\r', b'')
# See "A note about encoding" above
data = data.decode('ascii', errors='surrogateescape')
buf.append(data)
Expand Down Expand Up @@ -911,7 +913,7 @@ class LaTeX(Task):
if parts[0] == 'PWD':
pwd = parts[1]
elif parts[0] in ('INPUT', 'OUTPUT'):
if parts[1].startswith('/'):
if os.path.isabs(parts[1]):
path = parts[1]
else:
# Try to make "nice" paths, especially for clean
Expand Down Expand Up @@ -1042,7 +1044,7 @@ class LaTeXCommit(Task):
else:
debug('commiting {} to {}', outname, commit)
shutil.copy(outname, outname + '~')
os.rename(outname + '~', commit)
os.replace(outname + '~', commit)
except OSError as e:
raise TaskError('error committing latex output: {}'.format(e)) from e
self._input('file', outname)
Expand Down Expand Up @@ -1683,7 +1685,7 @@ class BibTeX(Task):
# If this path is relative to the source directory,
# clean it up for error reporting and portability of
# the dependency DB
if filename.startswith('/'):
if os.path.isabs(filename):
relname = os.path.relpath(filename)
if '../' not in relname:
filename = relname
Expand Down