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

[Bug]: pylcs wheel fails to install when running make build #5793

Open
1 task done
autonomousit opened this issue Dec 25, 2024 · 11 comments
Open
1 task done

[Bug]: pylcs wheel fails to install when running make build #5793

autonomousit opened this issue Dec 25, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@autonomousit
Copy link

autonomousit commented Dec 25, 2024

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Describe the bug and reproduction steps

When running make build (using latest commit to main #5784) it fails to install with a single error for the Python dependency pylcs. This issue seems related to not being able to find pybind11 bindings. This may be an upstream issue with pylcs (see this Github Issue).

Deleting the poetry.lock file and adding pybind11 to pyproject.toml didn't resolve the issue. Instead I manually downloaded the wheel file for pylcs from piwheels.org and modified pyproject.toml to point to the local wheel file for pylcs as shown below:

pylcs = { file = "/path/to/wheel/pylcs-0.1.1-cp39-cp39-linux_armv7l.whl" }

Everything then installed correctly and I can run make setup-config no problems however when I then run make run it fails due to not finding _pylcs. I can run also make start-frontend without errors but make start-backend results in another, different error.

OpenHands Installation

Development workflow

OpenHands Version

main

Operating System

Linux

Logs, Errors, Screenshots, and Additional Context

Original install error

 - Updating pylcs (0.1.1 /home/ben/Downloads/pylcs-0.1.1-cp39-cp39-linux_armv7l.whl -> 0.1.1): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke build_wheel
  
  running bdist_wheel
  running build
  running build_py
  creating build/lib.linux-x86_64-cpython-312/pylcs
  copying pylcs/__init__.py -> build/lib.linux-x86_64-cpython-312/pylcs
  running build_ext
  creating tmp
  x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/tmp3j44iaag/.venv/include -I/usr/include/python3.12 -c /tmp/tmp1g44e4ph.cpp -o tmp/tmp1g44e4ph.o -std=c++14
  x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/tmp3j44iaag/.venv/include -I/usr/include/python3.12 -c /tmp/tmpsojz3poa.cpp -o tmp/tmpsojz3poa.o -fvisibility=hidden
  building '_pylcs' extension
  creating build/temp.linux-x86_64-cpython-312/src
  x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include -I/tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include -I/tmp/tmp3j44iaag/.venv/include -I/usr/include/python3.12 -c src/main.cpp -o build/temp.linux-x86_64-cpython-312/src/main.o -DVERSION_INFO=\"0.1.1\" -std=c++14 -fvisibility=hidden
  In file included from /tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include/pybind11/attr.h:13,
                   from /tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include/pybind11/detail/class.h:12,
                   from /tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include/pybind11/pybind11.h:12,
                   from src/main.cpp:1:
  /tmp/tmp3j44iaag/.venv/lib/python3.12/site-packages/pybind11/include/pybind11/detail/common.h:274:10: fatal error: Python.h: No such file or directory
    274 | #include <Python.h>
        |          ^~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/x86_64-linux-gnu-g++' failed with exit code 1
  

  at ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with pylcs (0.1.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pylcs (==0.1.1)"'.

make[1]: *** [Makefile:129: install-python-dependencies] Error 1
make: *** [Makefile:26: build] Error 2

Make Run Error

Running the app...
Starting backend server...
Waiting for the backend to start...
ERROR:root:  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/main.py", line 412, in main
    run(
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/main.py", line 579, in run
    server.run()
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 66, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 70, in serve
    await self._serve(sockets)
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 77, in _serve
    config.load()
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/config.py", line 435, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/ben/Documents/OpenHands/openhands/server/listen.py", line 3, in <module>
    from openhands.server.app import app as base_app
  File "/home/ben/Documents/OpenHands/openhands/server/app.py", line 11, in <module>
    import openhands.agenthub  # noqa F401 (we import this to get the agents registered)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/Documents/OpenHands/openhands/agenthub/__init__.py", line 3, in <module>
    from openhands.agenthub.micro.agent import MicroAgent
  File "/home/ben/Documents/OpenHands/openhands/agenthub/micro/agent.py", line 5, in <module>
    from openhands.controller.agent import Agent
  File "/home/ben/Documents/OpenHands/openhands/controller/__init__.py", line 1, in <module>
    from openhands.controller.agent_controller import AgentController
  File "/home/ben/Documents/OpenHands/openhands/controller/agent_controller.py", line 10, in <module>
    from openhands.controller.agent import Agent
  File "/home/ben/Documents/OpenHands/openhands/controller/agent.py", line 13, in <module>
    from openhands.runtime.plugins import PluginRequirement
  File "/home/ben/Documents/OpenHands/openhands/runtime/__init__.py", line 3, in <module>
    from openhands.runtime.impl.eventstream.eventstream_runtime import (
  File "/home/ben/Documents/OpenHands/openhands/runtime/impl/eventstream/eventstream_runtime.py", line 37, in <module>
    from openhands.runtime.base import (
  File "/home/ben/Documents/OpenHands/openhands/runtime/base.py", line 38, in <module>
    from openhands.runtime.utils.edit import FileEditRuntimeMixin
  File "/home/ben/Documents/OpenHands/openhands/runtime/utils/edit.py", line 22, in <module>
    from openhands.utils.chunk_localizer import Chunk, get_top_k_chunk_matches
  File "/home/ben/Documents/OpenHands/openhands/utils/chunk_localizer.py", line 7, in <module>
    import pylcs
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/pylcs/__init__.py", line 2, in <module>
    from _pylcs import *

ERROR:root:<class 'ModuleNotFoundError'>: No module named '_pylcs'

Different make start-backend erro

Starting backend...
Traceback (most recent call last):
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/bin/uvicorn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/main.py", line 412, in main
    run(
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/main.py", line 516, in run
    config = Config(
             ^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/config.py", line 293, in __init__
    self.reload_excludes, self.reload_dirs_excludes = resolve_reload_patterns(reload_excludes, [])
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/config.py", line 146, in resolve_reload_patterns
    for match in current_working_directory.glob(pattern):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1090, in glob
    raise NotImplementedError("Non-relative patterns are unsupported")
NotImplementedError: Non-relative patterns are unsupported
make: *** [Makefile:193: start-backend] Error 1
@enyst
Copy link
Collaborator

enyst commented Dec 25, 2024

@autonomousit
Copy link
Author

@enyst - thanks for the quick response, wasn't expecting it over the holidays :-)

I implemented that fix and now make start-backend results in the same pylcs related error as when using make run which is what I would have expected. When the behaviour drifted like that I didn't do a proper check for other issues.

Just for the record here's the error I now get for make start-backend

Starting backend...
INFO:     Will watch for changes in these directories: ['/home/ben/Documents/OpenHands']
INFO:     Uvicorn running on http://127.0.0.1:3000 (Press CTRL+C to quit)
INFO:     Started reloader process [50464] using WatchFiles
Process SpawnProcess-1:
Traceback (most recent call last):
  File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
    target(sockets=sockets)
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 66, in run
    return asyncio.run(self.serve(sockets=sockets))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 70, in serve
    await self._serve(sockets)
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 77, in _serve
    config.load()
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/config.py", line 435, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/importer.py", line 22, in import_from_string
    raise exc from None
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/ben/Documents/OpenHands/openhands/server/listen.py", line 3, in <module>
    from openhands.server.app import app as base_app
  File "/home/ben/Documents/OpenHands/openhands/server/app.py", line 11, in <module>
    import openhands.agenthub  # noqa F401 (we import this to get the agents registered)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ben/Documents/OpenHands/openhands/agenthub/__init__.py", line 3, in <module>
    from openhands.agenthub.micro.agent import MicroAgent
  File "/home/ben/Documents/OpenHands/openhands/agenthub/micro/agent.py", line 5, in <module>
    from openhands.controller.agent import Agent
  File "/home/ben/Documents/OpenHands/openhands/controller/__init__.py", line 1, in <module>
    from openhands.controller.agent_controller import AgentController
  File "/home/ben/Documents/OpenHands/openhands/controller/agent_controller.py", line 10, in <module>
    from openhands.controller.agent import Agent
  File "/home/ben/Documents/OpenHands/openhands/controller/agent.py", line 13, in <module>
    from openhands.runtime.plugins import PluginRequirement
  File "/home/ben/Documents/OpenHands/openhands/runtime/__init__.py", line 3, in <module>
    from openhands.runtime.impl.eventstream.eventstream_runtime import (
  File "/home/ben/Documents/OpenHands/openhands/runtime/impl/eventstream/eventstream_runtime.py", line 44, in <module>
    from openhands.runtime.base import Runtime
  File "/home/ben/Documents/OpenHands/openhands/runtime/base.py", line 41, in <module>
    from openhands.runtime.utils.edit import FileEditRuntimeMixin
  File "/home/ben/Documents/OpenHands/openhands/runtime/utils/edit.py", line 28, in <module>
    from openhands.utils.chunk_localizer import Chunk, get_top_k_chunk_matches
  File "/home/ben/Documents/OpenHands/openhands/utils/chunk_localizer.py", line 7, in <module>
    import pylcs
  File "/home/ben/.cache/pypoetry/virtualenvs/openhands-ai-7a98SNbC-py3.12/lib/python3.12/site-packages/pylcs/__init__.py", line 2, in <module>
    from _pylcs import *
ModuleNotFoundError: No module named '_pylcs'

@enyst
Copy link
Collaborator

enyst commented Dec 25, 2024

That is weird, but this is suspicious:

pipx/venvs/poetry/lib/python3.10

We are using 3.12+, 3.12 is minimum. Where did python 3.10 come from? Maybe you can see if you can upgrade poetry?

@autonomousit
Copy link
Author

@enyst - I'm running on an Ubuntu derivative (pop-os) where python 3.10.x is the system default, I've installed 3.12.8 and poetry should have everything pointing to that. It should just be poetry running on the native system python version and everything in the openhands virtual environment should be on 3.12.8.

P.S. I'm headed to bed shortly so don't stress about getting me a quick answer now as I won't see it.

@enyst
Copy link
Collaborator

enyst commented Dec 25, 2024

The log looks like it was trying to install this library on 3.10, and that would not be useful. It

What version is poetry, is it up to date?

@autonomousit
Copy link
Author

Hey @enyst, Poetry is latest but I've done a bit more digging this morning and this looks like an upstream issue with pylcs. I can replicate the issue outside of the Openhands project simply using pip. I will continue to work on this and find how to resolve it and post the results here in case others hit the same problem but I don't think this has anything to do with Openhands (see below). Thanks again for your quick help.

If I create a simple venv using my system default python 3.10 and pip the pylcs package installs correctly and the dependency on pybind11 is automatically resolved. See below

(pylcs_test_local) ben@local:~/Documents/pylcs_test_local$ pip3 install pylcs
Collecting pylcs
  Downloading pylcs-0.1.1.tar.gz (11 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pybind11>=2.2
  Using cached pybind11-2.13.6-py3-none-any.whl (243 kB)
Building wheels for collected packages: pylcs
  Building wheel for pylcs (pyproject.toml) ... done
  Created wheel for pylcs: filename=pylcs-0.1.1-cp310-cp310-linux_x86_64.whl size=1082092 sha256=7b4eeb5d1cffd40a967e5a3e8d249a4fc58ba8886c185712a92731dbc5df8ae6
  Stored in directory: /home/ben/.cache/pip/wheels/eb/64/e8/c902162e883f432251466566e011016795ea03b95d4350d0ee
Successfully built pylcs
Installing collected packages: pybind11, pylcs
Successfully installed pybind11-2.13.6 pylcs-0.1.1

If I try and do the same using python 3.12.8 I get the pybind11 error. If I then manually install pybind11 into the venv I still get the same build error for pylcs.

First install of pylcs without pybind11 installed

(pylcs_test) ben@local-pc:~/Documents/pylcs_test$ python3.12 -m pip install pylcs
Collecting pylcs
  Downloading pylcs-0.1.1.tar.gz (11 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pybind11>=2.2 (from pylcs)
  Using cached pybind11-2.13.6-py3-none-any.whl.metadata (9.5 kB)
Using cached pybind11-2.13.6-py3-none-any.whl (243 kB)
Building wheels for collected packages: pylcs
  Building wheel for pylcs (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pylcs (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312/pylcs
      copying pylcs/__init__.py -> build/lib.linux-x86_64-cpython-312/pylcs
      running build_ext
      creating tmp
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c /tmp/tmppd20sw4q.cpp -o tmp/tmppd20sw4q.o -std=c++14
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c /tmp/tmph8p_2zae.cpp -o tmp/tmph8p_2zae.o -fvisibility=hidden
      building '_pylcs' extension
      creating build/temp.linux-x86_64-cpython-312/src
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include -I/tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c src/main.cpp -o build/temp.linux-x86_64-cpython-312/src/main.o -DVERSION_INFO=\"0.1.1\" -std=c++14 -fvisibility=hidden
      In file included from /tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/attr.h:13,
                       from /tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/detail/class.h:12,
                       from /tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/pybind11.h:12,
                       from src/main.cpp:1:
      /tmp/pip-build-env-npfp6a1d/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/detail/common.h:274:10: fatal error: Python.h: No such file or directory
        274 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-g++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pylcs
Failed to build pylcs
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pylcs)

Second install attempt for python3.12.8 after installing pybind11 manually

(pylcs_test) ben@local-pc:~/Documents/pylcs_test$ python3.12 -m pip install pybind11
Collecting pybind11
  Using cached pybind11-2.13.6-py3-none-any.whl.metadata (9.5 kB)
Using cached pybind11-2.13.6-py3-none-any.whl (243 kB)
Installing collected packages: pybind11
Successfully installed pybind11-2.13.6
(pylcs_test) ben@local-pc:~/Documents/pylcs_test$ python3.12 -m pip install pylcs
Collecting pylcs
  Using cached pylcs-0.1.1.tar.gz (11 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pybind11>=2.2 in ./lib/python3.12/site-packages (from pylcs) (2.13.6)
Building wheels for collected packages: pylcs
  Building wheel for pylcs (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pylcs (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312/pylcs
      copying pylcs/__init__.py -> build/lib.linux-x86_64-cpython-312/pylcs
      running build_ext
      creating tmp
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c /tmp/tmpds1j6h_g.cpp -o tmp/tmpds1j6h_g.o -std=c++14
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c /tmp/tmpap9deoqm.cpp -o tmp/tmpap9deoqm.o -fvisibility=hidden
      building '_pylcs' extension
      creating build/temp.linux-x86_64-cpython-312/src
      x86_64-linux-gnu-g++ -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include -I/tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include -I/home/ben/Documents/pylcs_test/include -I/usr/include/python3.12 -c src/main.cpp -o build/temp.linux-x86_64-cpython-312/src/main.o -DVERSION_INFO=\"0.1.1\" -std=c++14 -fvisibility=hidden
      In file included from /tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/attr.h:13,
                       from /tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/detail/class.h:12,
                       from /tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/pybind11.h:12,
                       from src/main.cpp:1:
      /tmp/pip-build-env-w8a1dhso/overlay/lib/python3.12/site-packages/pybind11/include/pybind11/detail/common.h:274:10: fatal error: Python.h: No such file or directory
        274 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-g++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pylcs
Failed to build pylcs
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pylcs)

@autonomousit
Copy link
Author

@enyst you won't believe how stupid this was. When I installed Python 3.12 on my system I did apt install python3.12 instead of apt install python3.12-dev :-P

Sorry for wasting your time.

@gordicaleksa
Copy link

I've hit this same issue, and i confirm that the installation of dev solved it! :)

I wouldn't say it's stupid, it's not at all obvious that one should install python3.12-dev (?) why?

@enyst
Copy link
Collaborator

enyst commented Dec 26, 2024

pylcs is written in cpp, it's not just a python library. Building it from source needs the headers.

Thank you for the follow-ups! We may want to remember this for the future. Is your system also a Linux system, @gordicaleksa ?

@rbren
Copy link
Collaborator

rbren commented Dec 26, 2024

May or may not be helpful, but I have to run sudo apt-get install python3-dev -y to get pylcs to work

@autonomousit
Copy link
Author

@gordicaleksa - glad my comments helped.

@enyst - since multiple people have stumbled on this step, perhaps a small hint in the Development.md requirements section would help in future.

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

No branches or pull requests

4 participants