dawnbeen / c_formatter_42

C language formatter for 42 norminette
GNU General Public License v3.0
163 stars 16 forks source link

clang-format executable not found in pypi package #25

Closed keyhr closed 2 years ago

keyhr commented 2 years ago

I installed the formatter from pypi (pip3 install --user c-formatter-42), and it doesn't include clang-format executable. I checked the c_formatter_42/data directory and both clang-format-darwin and clang-format-linux was not there.

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/dist-packages/c_formatter_42/__main__.py", line 61, in <module>
    main()
  File "/usr/local/lib/python3.8/dist-packages/c_formatter_42/__main__.py", line 42, in main
    print(run_all(content), end="")
  File "/usr/local/lib/python3.8/dist-packages/c_formatter_42/run.py", line 29, in run_all
    content = clang_format(content)
  File "/usr/local/lib/python3.8/dist-packages/c_formatter_42/formatters/clang_format.py", line 67, in clang_format
    process = subprocess.Popen(
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/dist-packages/c_formatter_42/data/clang-format-linux'
$ ls -a /usr/local/lib/python3.8/dist-packages/c_formatter_42/data/
. .. __init__.py
keyhr commented 2 years ago

@cacharle do you happen to have any idea why this is happening?

keyhr commented 2 years ago

Looking into the pypi source package, there are neither .clang-format nor both executables, while github release source package has both.

cacharle commented 2 years ago

It's supposed to include any files that are in the data/ directory

which is declared in the setup.cfg: https://github.com/dawnbeen/c_formatter_42/blob/6b534098756260d2bb6d2a3e97d15252808f2878/setup.cfg#L26

was it already missing in previous release on pipy?

I remember testing it a long time ago and it was working.

Maybe a bug with the CD?

keyhr commented 2 years ago

I couldn't find executables in any versions as well. But I also remember it had been working when I created the first issue, which I installed from pypi. Maybe I missed something. Is the files in data moved from the data directory when packaged?

The error arose in Docker container. I've just tried to install from pypi in my host mac, it worked without exception, though I cannot find those clang format binaries. Not working on mac too, with pypi package.

keyhr commented 2 years ago

Fixed 🎉

cacharle commented 2 years ago

Nice catch! I'm wondering why it didn't took them anymore tho

keyhr commented 2 years ago

^^ Yeah, I'm also wondering why does it need data/.* to specify .clang-format.