Skip to content

Commit 634d70d

Browse files
authored
Release 0.0.7 and fix error related to --outputdirectory. (#10)
1 parent c2b96d5 commit 634d70d

File tree

6 files changed

+50
-7
lines changed

6 files changed

+50
-7
lines changed

Diff for: CHANGES.rst

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ all releases are available on `Anaconda.org
77
<https://anaconda.org/pytask/pytask-latex>`_.
88

99

10+
0.0.7 - 2020-10-14
11+
------------------
12+
13+
- :gh:`10` fixes error that ``outputdirectory`` has to be relative to latex document due
14+
to security problems.
15+
16+
1017
0.0.6 - 2020-10-14
1118
------------------
1219

Diff for: setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.6
2+
current_version = 0.0.7
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
44
serialize =
55
{major}.{minor}.{patch}dev{dev}

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="pytask-latex",
6-
version="0.0.6",
6+
version="0.0.7",
77
packages=find_packages(where="src"),
88
package_dir={"": "src"},
99
entry_points={"pytask": ["pytask_latex = pytask_latex.plugin"]},

Diff for: src/pytask_latex/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.6"
1+
__version__ = "0.0.7"

Diff for: src/pytask_latex/collect.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""Collect tasks."""
22
import copy
33
import functools
4+
import os
45
import subprocess
6+
from pathlib import Path
57
from typing import Iterable
68
from typing import Optional
79
from typing import Union
@@ -61,14 +63,15 @@ def compile_latex_document(depends_on, produces, latex):
6163
latex.append(f"--jobname={compiled_document.stem}")
6264

6365
# See comment in doc string.
64-
out_relative_to_latex_source = compiled_document.parent.relative_to(
65-
latex_document.parent
66-
)
66+
out_relative_to_latex_source = Path(
67+
os.path.relpath(compiled_document.parent, latex_document.parent)
68+
).as_posix()
69+
6770
subprocess.run(
6871
[
6972
"latexmk",
7073
*latex,
71-
f"--output-directory={out_relative_to_latex_source.as_posix()}",
74+
f"--output-directory={out_relative_to_latex_source}",
7275
f"{latex_document.as_posix()}",
7376
],
7477
check=True,

Diff for: tests/test_execute.py

+33
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,39 @@ def task_compile_document():
9797
assert tmp_path.joinpath("document.pdf").exists()
9898

9999

100+
@needs_latexmk
101+
@skip_on_github_actions_with_win
102+
@pytest.mark.end_to_end
103+
def test_compile_latex_document_w_relative(runner, tmp_path):
104+
"""Test simple compilation."""
105+
task_source = f"""
106+
import pytask
107+
108+
@pytask.mark.latex
109+
@pytask.mark.depends_on("document.tex")
110+
@pytask.mark.produces("{tmp_path.joinpath("bld", "document.pdf").as_posix()}")
111+
def task_compile_document():
112+
pass
113+
114+
"""
115+
tmp_path.joinpath("bld").mkdir()
116+
tmp_path.joinpath("src").mkdir()
117+
tmp_path.joinpath("src", "task_dummy.py").write_text(textwrap.dedent(task_source))
118+
119+
latex_source = r"""
120+
\documentclass{report}
121+
\begin{document}
122+
I was tired of my lady
123+
\end{document}
124+
"""
125+
tmp_path.joinpath("src", "document.tex").write_text(textwrap.dedent(latex_source))
126+
127+
result = runner.invoke(cli, [tmp_path.as_posix()])
128+
129+
assert result.exit_code == 0
130+
assert tmp_path.joinpath("bld", "document.pdf").exists()
131+
132+
100133
@needs_latexmk
101134
@skip_on_github_actions_with_win
102135
@pytest.mark.end_to_end

0 commit comments

Comments
 (0)