Skip to content

Question about how to compile dependencies with conan + shared=True #56

@davidsanfal

Description

@davidsanfal

Hi @tttapa!

I've been testing your backend implementation based on the conan branch of py-build-cmake-example. In my case, I added the fmt dependency to try building a package with some dependencies. Honestly, I found it very easy to understand and use.

The problem came up when I tried to compile fmt with the shared=True option.

[tool.py-build-cmake.conan]
args = ["--build=missing", "-o fmt/*:shared=True", "-o fmt/*:header_only=False"]

In this case, the wheel seems to build successfully.

pip install .               
Processing /Users/davidsanfal/repos/pep517/pep517-conan/example
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: py-conan-add
  Building wheel for py-conan-add (pyproject.toml) ... done
  Created wheel for py-conan-add: filename=py_conan_add-0.6.0a2.dev0-cp313-cp313-macosx_10_13_x86_64.whl size=59290 sha256=5b248b4e10c758fda42a9fc09a6c07427dea787441840c7a1d826429969e050f
  Stored in directory: /private/var/folders/x8/4lczj5ps1hzdb_3_f7h70wlm0000gn/T/pip-ephem-wheel-cache-qfudjm05/wheels/e9/2a/fb/a19497391fa407f6efa60fc550acb8f6bfd4bc5a71b2cca970
Successfully built py-conan-add
Installing collected packages: py-conan-add
  Attempting uninstall: py-conan-add
    Found existing installation: py-conan-add 0.6.0a2.dev0
    Uninstalling py-conan-add-0.6.0a2.dev0:
      Successfully uninstalled py-conan-add-0.6.0a2.dev0
Successfully installed py-conan-add-0.6.0a2.dev0

but it hasn't actually copied the fmt library into it, so it fails when using the package.

pytest                      
=================================================================================================================== test session starts ====================================================================================================================
platform darwin -- Python 3.13.4, pytest-8.4.2, pluggy-1.6.0
rootdir: /Users/davidsanfal/pep517-conan/example
configfile: pyproject.toml
collected 0 items / 1 error                                                                                                                                                                                                                                

========================================================================================================================== ERRORS ==========================================================================================================================
_________________________________________________________________________________________________________ ERROR collecting test/test_add_module.py _________________________________________________________________________________________________________
ImportError while importing test module '/Users/davidsanfal/pep517-conan/example/test/test_add_module.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/test_add_module.py:2: in <module>
    from py_conan_add.add_module import add
../../venv/lib/python3.13/site-packages/py_conan_add/add_module.py:6: in <module>
    from py_conan_add._add_module import *
E   ImportError: dlopen(/Users/davidsanfal/venv/lib/python3.13/site-packages/py_conan_add/_add_module.cpython-313-darwin.so, 0x0002): Library not loaded: @rpath/libfmt.12.dylib
E     Referenced from: <D376EC0A-7EFC-3A7D-B59B-B99640E1D02C> /Users/davidsanfal/venv/lib/python3.13/site-packages/py_conan_add/_add_module.cpython-313-darwin.so
E     Reason: no LC_RPATH's found
================================================================================================================= short test summary info ==================================================================================================================
ERROR test/test_add_module.py

I guess there's some step I'm missing or some setting I'm adding incorrectly. I have created a test repository with the example I am using in case it can help to reproduce my issue. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions