|
11 | 11 |
|
12 | 12 | @click.command(help="Generate sollya python based files") |
13 | 13 | @click.option("-f", "--force", is_flag=True, help="Force regenerate all files") |
14 | | -@click.option("-s", "--sollya-path", help="Path to sollya") |
15 | | -def generate(*, force, sollya_path): |
| 14 | +def generate(*, force): |
16 | 15 | spin.util.run( |
17 | | - ["python", str(rootdir / "tools" / "generator.py")] |
| 16 | + ["python", str(rootdir / "tools" / "sollya" / "generate.py")] |
18 | 17 | + (["--force"] if force else []), |
19 | 18 | ) |
20 | | - |
21 | | - |
22 | | -@spin.util.extend_command(spin.cmds.meson.build) |
23 | | -def build(*, parent_callback, **kwargs): |
24 | | - parent_callback(**kwargs) |
25 | | - |
26 | | - |
27 | | -@click.option( |
28 | | - "-m", |
29 | | - "markexpr", |
30 | | - metavar="MARKEXPR", |
31 | | - default="", |
32 | | - help="Run tests with the given markers", |
33 | | -) |
34 | | -@click.option( |
35 | | - "-m", |
36 | | - "markexpr", |
37 | | - metavar="MARKEXPR", |
38 | | - default="", |
39 | | - help="Run tests with the given markers", |
40 | | -) |
41 | | -@spin.util.extend_command(spin.cmds.meson.test) |
42 | | -def test(*, parent_callback, pytest_args, tests, markexpr, **kwargs): |
43 | | - """ |
44 | | - By default, spin will run `-m 'not slow'`. To run the full test suite, use |
45 | | - `spin test -m full` |
46 | | - """ # noqa: E501 |
47 | | - if (not pytest_args) and (not tests): |
48 | | - pytest_args = ( |
49 | | - "--pyargs", |
50 | | - "numpy_sr", |
51 | | - ) |
52 | | - |
53 | | - if "-m" not in pytest_args: |
54 | | - if markexpr != "full": |
55 | | - pytest_args = ("-m", markexpr) + pytest_args |
56 | | - |
57 | | - kwargs["pytest_args"] = pytest_args |
58 | | - parent_callback(**{"pytest_args": pytest_args, "tests": tests, **kwargs}) |
59 | | - |
60 | | - |
61 | | -@spin.util.extend_command(meson.python) |
62 | | -def python(*, parent_callback, **kwargs): |
63 | | - env = os.environ |
64 | | - env["PYTHONWARNINGS"] = env.get("PYTHONWARNINGS", "all") |
65 | | - |
66 | | - parent_callback(**kwargs) |
67 | | - |
68 | | - |
69 | | -@click.command(context_settings={"ignore_unknown_options": True}) |
70 | | -@click.argument("ipython_args", metavar="", nargs=-1) |
71 | | -@meson.build_dir_option |
72 | | -def ipython(*, ipython_args, build_dir): |
73 | | - """π» Launch IPython shell with PYTHONPATH set |
74 | | -
|
75 | | - OPTIONS are passed through directly to IPython, e.g.: |
76 | | -
|
77 | | - spin ipython -i myscript.py |
78 | | - """ |
79 | | - env = os.environ |
80 | | - env["PYTHONWARNINGS"] = env.get("PYTHONWARNINGS", "all") |
81 | | - |
82 | | - ctx = click.get_current_context() |
83 | | - ctx.invoke(spin.cmds.meson.build) |
84 | | - |
85 | | - ppath = meson._set_pythonpath(build_dir) |
86 | | - |
87 | | - print(f'π» Launching IPython with PYTHONPATH="{ppath}"') |
88 | | - |
89 | | - # In spin >= 0.13.1, can replace with extended command, setting `pre_import` |
90 | | - preimport = ( |
91 | | - r"import numpy_sr as sr; " |
92 | | - r"print(f'\nPreimported NumPy SIMD Routines Tests {sr.__version__} as sr')" |
93 | | - ) |
94 | | - spin.util.run( |
95 | | - ["ipython", "--ignore-cwd", f"--TerminalIPythonApp.exec_lines={preimport}"] |
96 | | - + list(ipython_args) |
97 | | - ) |
0 commit comments