INNER CODE UNIT · Python

is_package_installed

pairinteraction/pairinteraction · src/pairinteraction/__init__.py:26

    def is_package_installed(package: str) -> bool:
        """Check whether a package is installed."""
        try:
            version(package)
        except PackageNotFoundError:
            return False
        else:
            return True

    def is_running_under_pyinstaller() -> bool:
        return getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")

    def find_library_file_in_package(substring: str, package: str) -> Path | None:
        """Find the library file if it got installed together with the package."""
        if (package_files := files(package)) is not None:
            for p in package_files:
                if substring in p.stem:
                    return Path(p.locate()).resolve()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…