Skip to content

Decoupling graphics requirements from libraries #902

Open
@RobPasMue

Description

@RobPasMue

After the discussions occuring on the PyAnsys Dev meeting, we thought it would be important to decouple the usage of graphics from the main installation of our libraries by defining a "graphics" target for that purpose. See ansys/pyansys-dev-guide#577 and ansys/pyansys-dev-guide#576

By doing a quick analysis of the metapackage and using this script where the variable target_package can be easily tweaked... I obtained the following results:

Note

In order to run it, one must:
1 - clone the repo
2 - create a venv and activate it
3 - install the repo: pip install .
4 - install the following: pip install pyvis pipdeptree

import subprocess
import json
import networkx as nx
from pyvis.network import Network

def get_dependency_tree():
    result = subprocess.run(["pipdeptree", "--json"], capture_output=True, text=True)
    return json.loads(result.stdout)

def build_reverse_dependency_graph(dependencies, target_package):
    graph = nx.DiGraph()
    package_map = {pkg["package"]["key"]: pkg for pkg in dependencies}
    
    for pkg_name, pkg in package_map.items():
        for dep in pkg.get("dependencies", []):
            if dep["key"] == target_package:
                graph.add_node(pkg_name, label=pkg_name, color="blue")
                graph.add_edge(pkg_name, target_package)
    
    return graph

def visualize_graph(graph):
    net = Network(notebook=True, directed=True, cdn_resources='remote')
    net.from_nx(graph)
    net.show("dependency_graph.html")

if __name__ == "__main__":
    target_package = "pyvista"  # Change this to the package you want to track
    dependencies = get_dependency_tree()
    graph = build_reverse_dependency_graph(dependencies, target_package)
    visualize_graph(graph)
    print(f"{len(graph.nodes) - 1} packages depend on {target_package}.")
    print("Dependency graph generated: Open 'dependency_graph.html' in your browser.")

Visualization shows that only 5 packages depend on it directly:

The first 4 should be adapted to use the ansys-tools-visualization-interface package if possible, and make it an optional dependency.

Now, after investigating the packages that depend on ansys-tools-visualization-interface, we get the following list:

This means that, only 5 PyAnsys libraries are the ones forcing the installation of PyVista "by default". We should contact each of these repos and push for its separation into a graphics target as described in ansys/pyansys-dev-guide#576

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