On 11/08/24 18:09, Martin Blais wrote:
I couldn't reproduce precisely your error (thanks for precise and hermetic steps). However, bringing up your setup with venv, I'm seeing other problems that are related. For example, overriding PYTHONPATH, I was unable to import the *_test.py files (!?) I traced it down to some library called _beancount_editable_loader that seems to mess with importing and it installed in the venv.
You'll find it here:
beancount-install-test/beancount-venv/lib/python3.12/site-packages/_beancount_editable_loader.py
It looks like something that is generated by the meson build.
(I don't know more than that, but it messes with the imports somehow, probably via the pth file) > Maybe Daniele will know - he setup the Meson build - I still work the
"old skool" way (make build, make test, from repo, with PYTHONPATH).

I'm also one of the maintainers of meson-python, the Python wheel build systems used by beancount (at least by default, the old setup.py based build is still in the repository) and many other projects :-)

meson-python uses meson as build system. for very good reasons, meson requires the build artifacts (in the case of beancount the extension modules) to be generated outside the source tree. Therefore it is not possible to use PYTHONPATH or equivalent to load Python modules and Python extension modules from a project that contains both. This would make development very tedious as it would require building and installing a wheel after every edit to test it. For this reason there are editable installs (or editable wheels, same thing).

meson-python implements editable installs using a custom Python module loader that picks the files from the correct location (the build directory for the compiled parts, and the source directory for the pure Python parts).

This works well. Except that when pytest is instructed to execute a test module foo/bar_test.py it expects to be able to import "foo.bar_test" and this fails if the package "foo" does not install foo/bar_test.py.

The last version of pytest could be convinced to import the test modules in a way that did not break in this case, but this does not work anymore since the last major release. The only way I've found to make it work is to install the test modules in the wheel.

Cheers,
Dan

--
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/b6f7d722-6deb-498a-96e4-1d6da69e6b57%40grinta.net.

Reply via email to