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

Unable to add package with poetry #131

Open
iceotopejs opened this issue Sep 11, 2023 · 5 comments
Open

Unable to add package with poetry #131

iceotopejs opened this issue Sep 11, 2023 · 5 comments

Comments

@iceotopejs
Copy link

I get the following error when trying add this package as a dependency from pypi using poetry add systemd-python.

$ poetry add systemd-python

Using version ^235 for systemd-python

Updating dependencies
Resolving dependencies... (0.1s)

Package operations: 1 install, 0 updates, 0 removals

  • Installing systemd-python (235): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel
  
  Traceback (most recent call last):
    File "/home/user/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/user/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/user/.local/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/tmpj5mp5g_u/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/tmpj5mp5g_u/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
      self.run_setup()
    File "/tmp/tmpj5mp5g_u/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 507, in run_setup
      super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
    File "/tmp/tmpj5mp5g_u/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
      exec(code, locals())
    File "<string>", line 55, in <module>
    File "<string>", line 40, in lib
    File "<string>", line 18, in pkgconfig
    File "<string>", line 6, in call
    File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'
  

  at ~/.local/lib/python3.10/site-packages/poetry/installation/chef.py:147 in _prepare
      143│ 
      144│                 error = ChefBuildError("\n\n".join(message_parts))
      145│ 
      146│             if error is not None:
    → 147│                 raise error from None
      148│ 
      149│             return path
      150│ 
      151│     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 systemd-python (235) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "systemd-python (==235)"'.

The same issue occurs when trying to build a wheel pip wheel "systemd-python (==235)" as the command above describes.

I also can't add this dependency directly via git:

$ poetry add https://github.com/systemd/python-systemd

file could not be opened successfully:
- method gz: ReadError('not a gzip file')
- method bz2: ReadError('not a bzip2 file')
- method xz: ReadError('not an lzma file')
- method tar: ReadError('invalid header')

I'm not familiar with details as to why this is occuring, but all I want to do is add this package as a dependency for my project, preferably with poetry. I am not sure if there are other methods of adding this as a dependency to pyproject.toml that would require its installation.

OS: 22.04.1-Ubuntu
Python version: Python 3.10.12
Pip version: pip 23.2.1
Poetry version: Version: 1.6.1 Poetry-Core Version: 1.7.0

@axoroll7
Copy link

axoroll7 commented Jan 2, 2024

Can you try this : apt update && apt install pkg-config libsystemd-dev python3-dev

@axoroll7
Copy link

axoroll7 commented Jan 2, 2024

This python library, downloaded from pypi, will compile on the fly. To prevent this, install this library with the OS package system (apt, dnf, etc), and allow your virtual environment to interact with the system site-packages directory :

  • venv : --system-site-packages
  • poetry : poetry config virtualenvs.options.system-site-packages true

Many libraries on Linux work that way.

@axoroll7
Copy link

axoroll7 commented Jan 2, 2024

@iceotopejs

@Barnoux
Copy link

Barnoux commented Feb 3, 2024

apt update && apt install pkg-config libsystemd-dev python3-dev

installing the librairies, fixed the issue for me.

@iceotopejs
Copy link
Author

Sorry for the late response.

apt update && apt install pkg-config libsystemd-dev python3-dev

installing the librairies, fixed the issue for me.

This did indeed fix the issue for me.

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

No branches or pull requests

3 participants