Skip to content

Commit 3927e90

Browse files
authored
Release 0.0.3 and transition to pytask 0.0.5. (#3)
1 parent 064b2eb commit 3927e90

File tree

14 files changed

+95
-50
lines changed

14 files changed

+95
-50
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ all releases are available on `Anaconda.org
77
<https://anaconda.org/pytask/pytask-latex>`_.
88

99

10+
0.0.3 - 2020-08-12
11+
------------------
12+
13+
- :gh:`3` prepares pytask-latex for pytask v0.0.5 and releases v0.0.3.
14+
15+
1016
0.0.2 - 2020-07-22
1117
------------------
1218

README.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,25 @@ via the ``@pytask.mark.latex`` marker. The default is the following.
7878

7979
.. code-block:: python
8080
81-
@pytask.mark.latex("--pdf", "--interaction=nonstopmode", "--synctex=1")
81+
@pytask.mark.latex(["--pdf", "--interaction=nonstopmode", "--synctex=1"])
8282
def task_compile_latex_document():
8383
pass
8484
8585
For example, to compile your document with XeLaTeX, use
8686

8787
.. code-block:: python
8888
89-
@pytask.mark.latex("--xelatex", "--interaction=nonstopmode")
89+
@pytask.mark.latex(["--xelatex", "--interaction=nonstopmode"])
9090
def task_compile_latex_document():
9191
pass
9292
9393
The options ``jobname``, ``output-directory`` and the ``.tex`` file which will be
9494
compiled are handled by the ``@pytask.mark.depends_on`` and ``@pytask.mark.produces``
9595
markers and cannot be changed.
9696

97+
You can either pass a string or a list of strings to the ``@pytask.mark.latex``
98+
decorator.
99+
97100

98101
Parametrization
99102
~~~~~~~~~~~~~~~
@@ -124,8 +127,8 @@ to include the latex decorator in the parametrization just like with
124127
@pytask.mark.parametrize(
125128
"produces, latex",
126129
[
127-
("document.pdf", ["--pdf", "interaction=nonstopmode"]),
128-
("document.dvi", ["--dvi", "interaction=nonstopmode"]),
130+
("document.pdf", (["--pdf", "interaction=nonstopmode"],)),
131+
("document.dvi", (["--dvi", "interaction=nonstopmode"],)),
129132
],
130133
)
131134
def task_compile_latex_document():

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.0.2
2+
current_version = 0.0.3
33
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))(\-?((dev)?(?P<dev>\d+))?)
44
serialize =
55
{major}.{minor}.{patch}dev{dev}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

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

src/pytask_latex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.2"
1+
__version__ = "0.0.3"

src/pytask_latex/collect.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import copy
22
import functools
33
import subprocess
4+
from typing import Iterable
5+
from typing import Optional
6+
from typing import Union
47

5-
import pytask
6-
from pytask.mark import get_markers_from_task
7-
from pytask.mark import has_marker
8-
from pytask.nodes import PythonFunctionTask
9-
from pytask.parametrize import _copy_func
10-
from pytask.shared import to_list
8+
from _pytask.config import hookimpl
9+
from _pytask.mark import get_specific_markers_from_task
10+
from _pytask.mark import has_marker
11+
from _pytask.nodes import PythonFunctionTask
12+
from _pytask.parametrize import _copy_func
13+
from _pytask.shared import to_list
14+
15+
16+
def latex(options: Optional[Union[str, Iterable[str]]] = None):
17+
"""Specify command line options for latexmk.
18+
19+
Parameters
20+
----------
21+
options : Optional[Union[str, Iterable[str]]]
22+
One or multiple command line options passed to latexmk.
23+
24+
"""
25+
if options is None:
26+
options = ["--pdf", "--interaction=nonstopmode", "--synctex=1"]
27+
elif isinstance(options, str):
28+
options = [options]
29+
return options
1130

1231

1332
def compile_latex_document(depends_on, produces, latex):
@@ -26,7 +45,7 @@ def compile_latex_document(depends_on, produces, latex):
2645
)
2746

2847

29-
@pytask.hookimpl
48+
@hookimpl
3049
def pytask_collect_task(session, path, name, obj):
3150
"""Collect a task which is a function.
3251
@@ -40,7 +59,7 @@ def pytask_collect_task(session, path, name, obj):
4059
path, name, obj, session
4160
)
4261
latex_function = _copy_func(compile_latex_document)
43-
latex_function.pytestmark = copy.deepcopy(task.function.pytestmark)
62+
latex_function.pytaskmark = copy.deepcopy(task.function.pytaskmark)
4463

4564
args = _create_command_line_arguments(task)
4665
latex_function = functools.partial(latex_function, latex=args)
@@ -57,10 +76,11 @@ def pytask_collect_task(session, path, name, obj):
5776

5877

5978
def _create_command_line_arguments(task):
60-
args = get_markers_from_task(task, "latex")[0].args
61-
if args:
62-
out = list(args)
63-
else:
64-
out = ["--pdf", "--interaction=nonstopmode", "--synctex=1"]
79+
latex_marks = get_specific_markers_from_task(task, "latex")
80+
mark = latex_marks[0]
81+
for mark_ in latex_marks[1:]:
82+
mark = mark.combine_with(mark_)
83+
84+
options = latex(*mark.args, **mark.kwargs)
6585

66-
return out
86+
return options

src/pytask_latex/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from _pytask.config import hookimpl
2+
3+
4+
@hookimpl
5+
def pytask_parse_config(config):
6+
config["markers"]["latex"] = "latex: Tasks which compile LaTeX documents."

src/pytask_latex/execute.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import shutil
22

3-
import pytask
4-
from pytask.mark import get_markers_from_task
5-
from pytask.nodes import FilePathNode
3+
from _pytask.config import hookimpl
4+
from _pytask.mark import get_specific_markers_from_task
5+
from _pytask.nodes import FilePathNode
66

77

8-
@pytask.hookimpl
8+
@hookimpl
99
def pytask_execute_task_setup(task):
10-
if get_markers_from_task(task, "latex"):
10+
if get_specific_markers_from_task(task, "latex"):
1111
if shutil.which("latexmk") is None:
1212
raise RuntimeError(
1313
"latexmk is needed to compile LaTeX documents, but it is not found on "

src/pytask_latex/parametrize.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import pytask
1+
from _pytask.config import hookimpl
2+
from _pytask.mark import MARK_GEN as mark # noqa: N811
23

34

4-
@pytask.hookimpl
5-
def pytask_generate_tasks_add_marker(obj, kwargs):
5+
@hookimpl
6+
def pytask_parametrize_kwarg_to_marker(obj, kwargs):
67
if callable(obj):
78
if "latex" in kwargs:
8-
pytask.mark.__getattr__("latex")(*kwargs.pop("latex"))(obj)
9+
mark.latex(*kwargs.pop("latex"))(obj)

src/pytask_latex/plugin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import pytask
1+
from _pytask.config import hookimpl
22
from pytask_latex import collect
3+
from pytask_latex import config
34
from pytask_latex import execute
45
from pytask_latex import parametrize
56

67

7-
@pytask.hookimpl
8+
@hookimpl
89
def pytask_add_hooks(pm):
910
pm.register(collect)
11+
pm.register(config)
1012
pm.register(execute)
1113
pm.register(parametrize)

0 commit comments

Comments
 (0)