Skip to content

copy __init__.py to build dir#208

Open
tornaria wants to merge 2 commits into
sagemath:mainfrom
tornaria:init
Open

copy __init__.py to build dir#208
tornaria wants to merge 2 commits into
sagemath:mainfrom
tornaria:init

Conversation

@tornaria

@tornaria tornaria commented Apr 6, 2026

Copy link
Copy Markdown
Member

This allows one to use something like

meson setup build && ninja -C build
PYTHONPATH=build make check

to check using the current build.

Without the __init__.py file in there, the system installation of cypari takes precedence.

I also added a (trivial) commit to print a message before starting autogen, which takes a long time.

tornaria added 2 commits April 5, 2026 23:00
This allows one to use something like
```
meson setup build && ninja -C build
PYTHONPATH=build make check
```
to check using the current build.

Without the `__init__.py` file in there, the system installation of
cypari takes precedence.
Since this step takes significant time, so one knows what is going on.
Note that while the autogen prints output as it goes, running it from
`run_command()` hides the output. It is possible to capture the output
and show it but only after it's finished.

See: https://mesonbuild.com/Reference-manual_functions_run_command.html

Note starting with meson 1.11 (unreleased) we could use `console: true`,
but most likely we don't want to bump the meson requirement so soon.
@tornaria

tornaria commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

@tobiasdiez does this look ok to you? My workflow is simpler with this.

@tornaria

tornaria commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

Also, perhaps we should move cypari2 directory to src/cypari2 so it doesn't interfere.

As it is, running PYTHONPATH=build pytest but running PYTHONPATH=build python -m pytest gives an error (loads cypari2/__init__.py from ., because running this way adds an implicit . in the front of PYTHONPATH; the problem is that when cypari2/__init__.py is loaded from . the submodules are searched in the same path, but the *.so files are not there)

@tornaria

tornaria commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

BTW, is there a way so that running pytest will run the tests from tests/rundoctests.py, so one doesn't need to run make check for that?

@tobiasdiez

Copy link
Copy Markdown
Contributor

Also, perhaps we should move cypari2 directory to src/cypari2 so it doesn't interfere.

This is a good idea, and then you most likely don't need to copy the init file.

BTW, is there a way so that running pytest will run the tests from tests/rundoctests.py, so one doesn't need to run make check for that?

Yes, pytest can run doctests see https://docs.pytest.org/en/stable/how-to/doctest.html and https://github.com/lgpage/pytest-cython. But that likely requires a bit of tinkering. You can of course just run the rundoctests.py script manually, without make.

@tornaria

tornaria commented Apr 6, 2026

Copy link
Copy Markdown
Member Author

Also, perhaps we should move cypari2 directory to src/cypari2 so it doesn't interfere.

This is a good idea, and then you most likely don't need to copy the init file.

I think we still need __init__.py in the build directory (we need a directory

BTW, is there a way so that running pytest will run the tests from tests/rundoctests.py, so one doesn't need to run make check for that?

Yes, pytest can run doctests see https://docs.pytest.org/en/stable/how-to/doctest.html and https://github.com/lgpage/pytest-cython. But that likely requires a bit of tinkering. You can of course just run the rundoctests.py script manually, without make.

Sure, but this means I need to know to run rundoctests.py. Ideally, I just run pytest and all the tests are run, since this is the usual way to test python packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants