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

Fix warnings (C and cython) #217

Merged
merged 10 commits into from
Jan 23, 2025
Merged

Fix warnings (C and cython) #217

merged 10 commits into from
Jan 23, 2025

Conversation

tornaria
Copy link
Contributor

This PR fixes warnings when building and testing

  • avoid C warnings
  • cython warnings: disable performance hints in tests.pyx
  • cython warnings: enable -Wextra
  • cython warnings: avoid unused variables
  • cython warnings: avoid maybe uninitialized
  • reload cysignals handlers in tests.pyx
  • tests::c_test_sig_on_cython: should not be noexcept
  • alarm::setitimer_real: doesn't raise exceptions

@tornaria tornaria requested a review from tobiasdiez January 14, 2025 15:19
@tornaria
Copy link
Contributor Author

@tobiasdiez Is it possible to show the pytest output?

Right now all that is shown is:

Run meson test --print-errorlogs -C builddir
ninja: Entering directory `/home/runner/work/cysignals/cysignals/builddir'
ninja: no work to do.
1/2 example OK               5.31s
2/2 pytest  OK              27.17s

Ok:                 2   
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /home/runner/work/cysignals/cysignals/builddir/meson-logs/testlog.txt

I can look at the file locally, but not on CI. Since pytest output is already brief, just showing it in the output would be nice, and also gives a better progress report.


Also, what is the suggested workflow to build and test "in place"?

I would expect something like this:

meson setup builddir
ninja -C builddir
meson test -C builddir

but this in fact tests the cysignals installed in the system. I shouldn't be required to install before testing.

Something like

PYTHONPATH=$(cd builddir/src && pwd) meson test -C builddir

or even

PYTHONPATH=$(cd builddir/src && pwd) pytest

fails because building doesn't create a complete package in builddir/src/cysignals, since python files are not copied (at least __init__.py is necessary).

Ideally, a simple way to run pytest directly would be nice (because it gives much more control on what to test, is more useful for developing).

@tobiasdiez
Copy link
Contributor

I don't think there is an easy way to print the test output directly (https://mesonbuild.com/Unit-tests.html#test-outputs). Either we could run pytest manually or afterwards just ̀ cat` the log file in the CI.

For editable install, the simplest would be the classical pip install -e ..

I shouldn't be required to install before testing.

You do need to install (eg into a local venv) since the build directory contains the compiled cython code but no python files, and it's the opposite for the source folder.

@tornaria
Copy link
Contributor Author

I don't think there is an easy way to print the test output directly (https://mesonbuild.com/Unit-tests.html#test-outputs). Either we could run pytest manually or afterwards just ̀ cat` the log file in the CI.

For CI, cat is good. For local, is not (I want to see pytest output while it's happening)

For editable install, the simplest would be the classical pip install -e ..

I don't trust pip, I'm always afraid it will break my system. I provide the dependencies, I only want to build cysignals and test it.

I shouldn't be required to install before testing.

You do need to install (eg into a local venv) since the build directory contains the compiled cython code but no python files, and it's the opposite for the source folder.

Isn't it possible that a complete package is built in the build directory?

I was hoping meson-python had something figured out for the normal build / test cycle.

@tornaria tornaria force-pushed the warnings branch 2 times, most recently from 67b5ce7 to 5fcb398 Compare January 17, 2025 16:44
@tornaria
Copy link
Contributor Author

Thanks for the review. I just pushed a couple empty lines to make flake8 happy.

@tornaria
Copy link
Contributor Author

The last commit may be unnecessary after #220.

@tornaria
Copy link
Contributor Author

The last commit may be unnecessary after #220.

Indeed. I removed the last commit from this PR.

@tornaria
Copy link
Contributor Author

I rebased on top of #220, and I added a new commit to add "-v" to the build command. This way we can see the output of meson setup and of the compilation (warnings, etc)

@dimpase dimpase merged commit d54ee91 into sagemath:main Jan 23, 2025
23 checks passed
@tornaria tornaria deleted the warnings branch January 24, 2025 13:43
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.

3 participants