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

No output from clang2py even for simple headers - CLANG compatibility issues #119

Closed
lbureau-billettiqueservices opened this issue Apr 14, 2023 · 6 comments
Assignees
Labels
bug Confirmed bug

Comments

@lbureau-billettiqueservices

I have been stuck with clang2py for a few hours now, absolutely no output is given even for extremely simple header files.

Here is the docker environment i'm working with that can reproduce the problem:

FROM python:3.8.16

RUN apt-get update && apt-get install lsb-release wget software-properties-common -y

WORKDIR /tmp
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh
RUN ./llvm.sh 11

RUN pip3 install ctypeslib2
RUN rm -r /tmp/*

RUN mkdir /workspace

WORKDIR /workspace

It just starts from the python 3.8.16 official image, install some minor packages to then install llvm/clang 11, which should allow proper support for clang2py.

I then install ctypeslib2 via pip. Nothing extraordinary.

I then try to pass it this extremely simple header file, just to test if something is working

#pragma once

#define AVALUE 10

typedef enum {
    something,
    somethingelse,
} anEnum;

but clang2py does not give any output whatsoever. Using the -v flag doesnt give any information about what could be the problem either.

I must be doing something wrong somewhere, because i used to be able to reliably use clang2py for much more complex header files, actively used in a python wrapper around a C library, but i can't get it working at all right now.

Any help would be appreciated.

@trolldbois
Copy link
Owner

What is the clang2py full command line you are using?

@lbureau-billettiqueservices
Copy link
Author

lbureau-billettiqueservices commented Apr 14, 2023

What is the clang2py full command line you are using?

clang2py demo.h.

I also tried clang2py -o demo.py demo.h but the resulting demo.py file is just as empty.

edit: demo.h is the header file as given in the opening message.

@lbureau-billettiqueservices
Copy link
Author

side note: clang2py exits with exit code 0. There is just no output whatsoever.

Here is a full output for reference:

root@1c9918f0e4cd:/workspace# cat demo.h
#pragma once

#define AVALUE 10

typedef enum {
    something,
    somethingelse,
} anEnum;
root@1c9918f0e4cd:/workspace# clang2py demo.h
root@1c9918f0e4cd:/workspace# 

@trolldbois
Copy link
Owner

trolldbois commented Apr 14, 2023

@lbureau-billettiqueservices bottom line it's a dependency issue with the python bindings from clang.

Solution
pending a better error message in the next release, uses this to install ctypeslib2
pip install clang==11 ctypeslib2

Explainer
docker.io/python:3.8.16 will default to python3.8 installed in /usr/local/bin/python3.8
on the same container, there is a /usr/bin/python3.9

  • When you run llvm.sh it does not apt install a python package for clang.
    you could install it, but that won't solve your issue - apt install python3-clang-11
    if you installed that, it would install the clang 11 package in /usr/lib/python3.9/site-packages.
    That won't help you , because the container would run /usr/local/bin/python3.8

  • When you install ctypeslib2, the current version is 2.3.2 from pypi, it has a loose dependency on python-clang
    the latest version of the python-clang package on pypi is clang16 released recently.
    the ctypeslib2 v2.3.2 package doesn't like that apparently and errors out silently.
    if you force the installation of the v11 python-clang package, it will properly work.

  • If you install the latest code from this repo, the error is a bit clearer.

Conclusion: I need to push a new ctypeslib package on pypi

@trolldbois trolldbois added the bug Confirmed bug label Apr 14, 2023
@trolldbois trolldbois self-assigned this Apr 14, 2023
@trolldbois trolldbois changed the title No output from clang2py even for simple headers No output from clang2py even for simple headers - CLANG compatibility issues Apr 14, 2023
@trolldbois
Copy link
Owner

warning messages are added in v2.3.3, it does not silently fail

@lbureau-billettiqueservices
Copy link
Author

Thanks for the fantastic support @trolldbois , i'm going to test your solution asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants