diff --git a/.gitignore b/.gitignore index b45cdb38..a74bc767 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ website/package-lock.json # Ignore .swp files .swp +*.whl +dist/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f644a9a..c344a95b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ find . -type f -name "*.svg" -exec bash -c 'inkscape -h 256 --export-filename=" find . -type f -name "*.svg" -exec bash -c 'rm "$0"' {} \; ``` -If you get any errors with autogen, it will probably be a '+' in filename +If you get any errors with autogen, it will probably be a '+' in filename ### Add new provider diff --git a/diagrams/azure/monitor.py b/diagrams/azure/monitor.py index 22788473..ecf02953 100644 --- a/diagrams/azure/monitor.py +++ b/diagrams/azure/monitor.py @@ -38,6 +38,8 @@ class DiagnosticsSettings(_Monitor): class LogAnalyticsWorkspaces(_Monitor): _icon = "log-analytics-workspaces.png" + + class Logs(_Monitor): _icon = "logs.png" diff --git a/poetry.lock b/poetry.lock index dfcbcc05..0c55810b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "astroid" @@ -96,7 +96,7 @@ description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" groups = ["dev"] -markers = "platform_system == \"Windows\" or sys_platform == \"win32\"" +markers = "sys_platform == \"win32\" or platform_system == \"Windows\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -661,5 +661,5 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.1" -python-versions = "^3.9" -content-hash = "f2b4b65c025fa4562d3687d4cfc9a33f0d1a3b8740a4776cf8fb5427167ce7d8" +python-versions = "~=3.9" +content-hash = "a8a90a93b71fbaf7b2c3adc6f9f95b6274285d2c1a218ac58a92697a75df4620" diff --git a/pyproject.toml b/pyproject.toml index 539832ac..6e5e19fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,30 +1,40 @@ -[tool.poetry] +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] name = "diagrams" -version = "0.24.4" +version = "0.25.1" description = "Diagram as Code" -license = "MIT" -authors = ["mingrammer "] +authors = [{ name = "mingrammer", email = "mingrammer@gmail.com" }] +requires-python = "~=3.9" readme = "README.md" -homepage = "https://diagrams.mingrammer.com" -repository = "https://github.com/mingrammer/diagrams" -include = ["resources/**/*"] +license = "MIT" +dependencies = [ + "graphviz>=0.13.2,<0.22.0", + "jinja2>=2.10,<4.0", + "typed-ast>=1.5.5,<2 ; python_version<'3.8'", +] + +[project.scripts] +diagrams = "diagrams.cli:main" -[tool.poetry.scripts] -diagrams="diagrams.cli:main" +[project.urls] +Homepage = "https://diagrams.mingrammer.com" +Repository = "https://github.com/mingrammer/diagrams" -[tool.poetry.dependencies] -python = "^3.9" -graphviz = ">=0.13.2,<0.22.0" -jinja2 = ">=2.10,<4.0" -typed-ast = {version="^1.5.5", markers="python_version<'3.8'"} +[dependency-groups] +dev = [ + "pytest~=8.3", + "pylint~=3.3", + "rope~=1.13", + "isort~=6.0", + "black~=24.4", + "pre-commit~=4.0", +] -[tool.poetry.dev-dependencies] -pytest = "^8.4" -pylint = "^3.3" -rope = "^1.13" -isort = "^6.0" -black = "^24.4" -pre-commit = "^4.3.0" +[tool.hatch.build] +only-include = ["diagrams", "resources"] [tool.black] line-length=120 diff --git a/tests/test_diagram.py b/tests/test_diagram.py index 0760709e..10dc7bd2 100644 --- a/tests/test_diagram.py +++ b/tests/test_diagram.py @@ -393,3 +393,49 @@ class ResourcesTest(unittest.TestCase): _, _ in os.walk(resources_dir)) self.assertLessEqual(max_depth, 2) + + def test_resources_exist_and_render(self): + """ + Test that resources directory exists and icons can be loaded for rendering. + This ensures the package build includes all necessary resource files. + """ + from diagrams.aws.compute import EC2 + from diagrams.aws.database import RDS + + # Verify resources directory exists + resources_dir = pathlib.Path(__file__).parent.parent / "resources" + self.assertTrue(resources_dir.exists(), "resources directory should exist") + + # Verify AWS resources exist (sample check) + aws_compute_dir = resources_dir / "aws" / "compute" + self.assertTrue(aws_compute_dir.exists(), "AWS compute resources should exist") + + # Verify icon files exist + ec2_icon = aws_compute_dir / "ec2.png" + self.assertTrue(ec2_icon.exists(), "EC2 icon should exist") + + # Test that nodes can load their icons + test_diagram_name = "test_resources_render" + try: + with Diagram(test_diagram_name, show=False): + ec2_node = EC2("test-ec2") + rds_node = RDS("test-rds") + + # Verify nodes have icon attributes set + self.assertIsNotNone(ec2_node._icon, "EC2 node should have an icon") + self.assertIsNotNone(rds_node._icon, "RDS node should have an icon") + + # Verify icon paths are valid + ec2_icon_path = ec2_node._load_icon() + rds_icon_path = rds_node._load_icon() + + self.assertTrue(os.path.exists(ec2_icon_path), + f"EC2 icon path should exist: {ec2_icon_path}") + self.assertTrue(os.path.exists(rds_icon_path), + f"RDS icon path should exist: {rds_icon_path}") + finally: + # Clean up generated files + try: + os.remove(test_diagram_name + ".png") + except FileNotFoundError: + pass