AdaCore / langkit

Language creation framework.
https://www.adacore.com
Other
78 stars 35 forks source link

libadalang can't find module liblktlang #656

Closed simonjwright closed 1 week ago

simonjwright commented 1 week ago

I have adasat, langkit and libadalang, all at v25.0.0, sources in parallel directories. The libadalang build shares the langkit venv.

I build langkit with

    # Don't really want to clone adasat at <uncontrolled> version.
    rm -rf langkit/adasat
    ln -s $ADASAT_SRC langkit/adasat

    rm -rf build

    pip install -r requirements-pypi.txt

    pip install .

    # This is for the 25.0.0 branch, like 25.1, as used in ada_language_parser
    python                                      \
        manage.py                               \
        make                                    \
        --no-mypy                               \
        --generate-auto-dll-dirs                \
        --library-types=relocatable             \
        --gargs '-cargs -fPIC'

    # no --force in install-langkit-support
    gprinstall --prefix=$PREFIX --uninstall langkit_support || true

    python manage.py                        \
           install-langkit-support          \
           --library-types=relocatable      \
           $PREFIX

and libadalang with

    rm -rf build

    pip install --upgrade pip

    pip install wheel

    pip install -r requirements-pypi.txt

    python manage.py generate

    python manage.py                            \
           build                                \
           --build-mode=prod                    \
           --library-types=relocatable          \
           --disable-java

    python manage.py                            \
           install                              \
           --build-mode=prod                    \
           --force                              \
           --library-types=relocatable          \
           $PREFIX

which fails with

Successfully installed jsonschema-4.23.0 jsonschema-specifications-2024.10.1 referencing-0.35.1 rpds-py-0.20.1
Traceback (most recent call last):
  File "/Volumes/Miscellaneous3/aarch64/14.2.0-3/langkit/venv/lib/python3.9/site-packages/langkit/libmanage.py", line 736, in run_no_exit
    parsed_args.func(parsed_args, unknown_args)
  File "/Volumes/Miscellaneous3/aarch64/14.2.0-3/langkit/venv/lib/python3.9/site-packages/langkit/libmanage.py", line 333, in wrapper
    self.set_context(parsed_args)
  File "/Volumes/Miscellaneous3/aarch64/14.2.0-3/langkit/venv/lib/python3.9/site-packages/langkit/libmanage.py", line 779, in set_context
    self.context = self.create_context(parsed_args)
  File "/Volumes/Miscellaneous3/src/libadalang/manage.py", line 80, in create_context
    ctx = CompileCtx(
  File "/Volumes/Miscellaneous3/aarch64/14.2.0-3/langkit/venv/lib/python3.9/site-packages/langkit/compile_context.py", line 542, in __init__
    from langkit.lkt_lowering import load_lkt
  File "/Volumes/Miscellaneous3/aarch64/14.2.0-3/langkit/venv/lib/python3.9/site-packages/langkit/lkt_lowering.py", line 62, in <module>
    import liblktlang as L
ModuleNotFoundError: No module named 'liblktlang'

I note that, in spite of building them, the langkit build didn't install the python or lkt dynamic libraries; is that the problem? I do see the installed langkit_support.relocatable/liblangkit_support.dylib.

pmderodat commented 1 week ago

Hello Simon,

Libadalang now indeed requires a full Langkit build (it is written using the Lkt language instead of the obsolete Python DSL). See Langkit’s README for the missing bits:

Install the Libpythonlang and Liblktlang support libraries:

$ (cd contrib/python && ./manage.py install $PREFIX --library-types=static,static-pic,relocatable --disable-all-mains)
$ (cd contrib/lkt && ./manage.py install $PREFIX --library-types=static,static-pic,relocatable --disable-all-mains)
$ pip install contrib/python/build/python
$ pip install contrib/lkt/build/python

I’ll close this for now, but please let us know if you need more help on this.