Skip to content

Add optional libraries#179

Merged
szymonlopaciuk merged 8 commits into
xsuite:mainfrom
freddieknets:AddOptionalLibraries
Jul 24, 2026
Merged

Add optional libraries#179
szymonlopaciuk merged 8 commits into
xsuite:mainfrom
freddieknets:AddOptionalLibraries

Conversation

@freddieknets

@freddieknets freddieknets commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR allows declaring C libraries using entry points, similarly to how include directories are declared.

In a package that depends on xobjects, you can register C source and library paths using the entry point xobjects.build_info. These paths will be added to the C include path and the library path when building kernels. For example, the following will allow to write #include <xcoll/path/to/some/header.h> in kernel sources, and allow to use functions from the library xcoll/lib/libFlukaIO.a:

In the pyproject.toml:

[project.entry-points.xobjects]
build_info = "xcoll._xobjects:get_build_info"

and in the file xcoll/_xobjects.py:

from ..general import _pkg_root
def get_build_info():
    return {
        "include_dirs": [_pkg_root.parent],
        "libraries": ["FlukaIO"],
        "library_dirs": [_pkg_root / "lib"],
    }

Checklist

Mandatory:

  • I have added tests to cover my changes
  • All the tests are passing, including my new ones
  • I described my changes in this PR description

Optional:

  • The code I wrote follows good style practices (see PEP 8 and PEP 20).
  • I have updated the docs in relation to my changes, if applicable
  • I have tested also GPU contexts

@szymonlopaciuk szymonlopaciuk mentioned this pull request Jul 24, 2026
@szymonlopaciuk
szymonlopaciuk merged commit 29e9732 into xsuite:main Jul 24, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants