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

nx-cugraph: check networkx version #4571

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,27 @@ def get_info():
return d


def _check_networkx_version():
import warnings

import networkx as nx

version_major, version_minor = nx.__version__.split(".")[:2]
if version_major != "3":
warnings.warn(
f"nx-cugraph version {__version__} is only known to work with networkx "
f"versions 3.x, but networkx {nx.__version__} is installed. "
"Perhaps try upgrading your Python environment.",
UserWarning,
stacklevel=2,
)
if len(version_minor) > 1:
raise RuntimeWarning(
f"nx-cugraph version {__version__} does not work with networkx version "
f"{nx.__version__}. Please upgrade (or fix) your Python environment."
)


if __name__ == "__main__":
from pathlib import Path

Expand Down
3 changes: 3 additions & 0 deletions python/nx-cugraph/nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
from .algorithms import *

from _nx_cugraph._version import __git_commit__, __version__
from _nx_cugraph import _check_networkx_version

_check_networkx_version()
Loading