Skip to content

find_package interferes with existing installation #860

@LecrisUT

Description

@LecrisUT

This is a quick but rather subtle issue. My CMake list file goes like:

if (NOT TARGET Spglib::symspg)
    find_package(Spglib CONFIG)
    if (NOT Spglib_FOUND)
        message(STATUS "Using bundled spglib sources")
        add_subdirectory(${PROJECT_SOURCE_DIR}/.. _deps/spglib-build)
    endif ()
endif ()

If I pip install from scratch it works just fine, i.e. the add_subdirectory is used. But if I run pip install again, then it picks up the current installation and it goes through find_package even though it is later removed at the install stage when the previous version is uninstalled.

I think the issue is with working around NO_CMAKE_INSTALL_PREFIX, but it is weird, shouldn't that point to tmp folder that would not interfere? Otherwise I did not configure any prefix for it to use. Any clues on what's happening here and how to work around it?

I believe the issue is with:

# Add site-packages to the prefix path for CMake
site_packages = Path(sysconfig.get_path("purelib"))
self.config.prefix_dirs.append(site_packages)
logger.debug("SITE_PACKAGES: {}", site_packages)
if site_packages != DIR.parent.parent:
self.config.prefix_dirs.append(DIR.parent.parent)
logger.debug("Extra SITE_PACKAGES: {}", site_packages)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions