{"id":20326736,"url":"https://github.com/infeeeee/dyn2py","last_synced_at":"2025-07-01T00:03:13.326Z","repository":{"id":118788822,"uuid":"607843884","full_name":"infeeeee/dyn2py","owner":"infeeeee","description":"Extract python code from Dynamo graphs","archived":false,"fork":false,"pushed_at":"2024-09-06T10:25:14.000Z","size":134,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T20:06:58.219Z","etag":null,"topics":["dynamo","dynamobim","python"],"latest_commit_sha":null,"homepage":"https://infeeeee.github.io/dyn2py/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infeeeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-28T19:41:52.000Z","updated_at":"2024-09-06T10:25:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"55318ead-6660-483e-992f-7d4fbc1adb92","html_url":"https://github.com/infeeeee/dyn2py","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/infeeeee/dyn2py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infeeeee%2Fdyn2py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infeeeee%2Fdyn2py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infeeeee%2Fdyn2py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infeeeee%2Fdyn2py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infeeeee","download_url":"https://codeload.github.com/infeeeee/dyn2py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infeeeee%2Fdyn2py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870852,"owners_count":23377309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamo","dynamobim","python"],"created_at":"2024-11-14T19:45:00.954Z","updated_at":"2025-07-01T00:03:13.293Z","avatar_url":"https://github.com/infeeeee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub release (latest by date)](https://img.shields.io/github/v/release/infeeeee/dyn2py?style=flat-square)](https://github.com/infeeeee/dyn2py/releases/latest)\n[![PyPI](https://img.shields.io/pypi/v/dyn2py?style=flat-square)](https://pypi.org/project/dyn2py/)\n[![GitHub Release Date](https://img.shields.io/github/release-date/infeeeee/dyn2py?style=flat-square)](https://github.com/infeeeee/dyn2py/releases/latest)\n[![GitHub last commit (branch)](https://img.shields.io/github/last-commit/infeeeee/dyn2py/main?style=flat-square)](https://github.com/infeeeee/dyn2py/commits/main)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/infeeeee/dyn2py/unittests.yml?label=tests\u0026style=flat-square)](https://github.com/infeeeee/dyn2py/actions/workflows/unittests.yml)\n[![GitHub](https://img.shields.io/github/license/infeeeee/dyn2py?style=flat-square)](https://github.com/infeeeee/dyn2py/blob/main/LICENSE)\n\n# dyn2py\n\nExtract python code from Dynamo graphs\n\nUse cases:\n\n- Track changes in python nodes in source control systems like git\n- Work on python code in your favorite code editor outside Dynamo. `dyn2py` can also update Dynamo graphs from previously exported python files.\n\n## Installation\n\n### Windows portable and installer\n\nPrebuilt portable exe and installer available from github releases.\n\nNo requirements, just download `dyn2py.exe` or `dyn2py-installer.exe` from release assets:\n\nhttps://github.com/infeeeee/dyn2py/releases/latest\n\nInstaller automatically adds the install folder to the path, so simply `dyn2py` can be called from anywhere.\n\n### With pip\n\nFor usage as a module or as a command line program\n\nRequirements: python, pip\n\n```\npip install dyn2py\n```\n\n## Usage\n\n### As a standalone command line program\n\n```\n\u003e dyn2py --help\nusage: dyn2py [-h] [-v] [-l LOGLEVEL] [-n] [-F] [-b] [-f {py,dyn}] [-u] [-p path/to/folder] [source ...]\n\nExtract python code from Dynamo graphs\n\npositional arguments:\n  source                path to a Dynamo graph, a python script or a folder containing them\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --version         show program's version number and exit\n  -l LOGLEVEL, --loglevel LOGLEVEL\n                        set log level, possible options: HEADLESS, CRITICAL, ERROR, WARNING, INFO, DEBUG\n  -n, --dry-run         do not modify files, only show log\n  -F, --force           overwrite even if the files are older\n  -b, --backup          create a backup for updated files\n  -f {py,dyn}, --filter {py,dyn}\n                        only check python or Dynamo graphs, skip the others, useful for folders\n\ndynamo options, only for processing Dynamo graphs:\n  -u, --update          update Dynamo graph from python scripts in the same folder\n  -p path/to/folder, --python-folder path/to/folder\n                        extract python scripts to this folder, read python scripts from here with --update\n\nThe script by default overwrites older files with newer files.\nDo not move the source Dynamo graphs, or update won't work with them later.\nMultiple sources are supported, separate them by spaces.\nHEADLESS loglevel only prints modified filenames.\n```\n\n#### Examples\n\n*Notes: In Windows cmd use backward slashes as path separators, in any other shells use forward slashes. Powershell accepts both of them. Wrap paths with spaces in double quotes.*\n\n```shell\n# Extract all nodes next to a Dynamo file:\ndyn2py path/to/dynamofile.dyn\n\n# Update a Dynamo file from previously exported and modified python files:\ndyn2py --update path/to/dynamofile.dyn\n\n# Extract python nodes to a specific folder, process multiple Dynamo files:\ndyn2py --python-folder path/to/pythonfiles path/to/dynamofile1.dyn path/to/dynamofile2.dyn\n\n# Update Dynamo files from python files from a folder. Only check python files, create backups:\ndyn2py --filter py --backup path/to/pythonfiles\n```\n\n#### Git hooks\n\nGit hooks are a built-in feature of Git that allow developers to automate tasks throughout the Git workflow. Read more here: https://githooks.com/\n\nWith the `pre-commit` hook it's possible to add more files to the currently initialized commit.\n\nYou can find an example pre-commit hook here: [pre-commit](pre-commit). Copy this file to the `.git/hooks` folder of your repo of Dynamo graphs. This folder is hidden by default, but it should exist in all initialized git repo. Do not rename this file.\n\nThis script will go through staged `.dyn` files and export python scripts from them, and add them to the current commit. Now you can check changed lines in a diff tool, you can see changed python code in a PR!\n\n### As a python module\n\nFull API documentation available here: https://infeeeee.github.io/dyn2py\n\n#### Examples\n\nExtract all nodes from python nodes next to a Dynamo file:\n\n```python\nimport dyn2py\n\n# Open a Dynamo graph:\ndynamo_file = dyn2py.DynamoFile(\"path/to/dynamofile.dyn\")\n\n# Extract python nodes:\ndynamo_file.extract_python()\n\n# Save all python nodes as separate files:\ndyn2py.PythonFile.write_open_files()\n```\n\nUpdate python node from a python file:\n\n```python\nimport dyn2py\n\n# Open a python file:\npython_file = dyn2py.PythonFile(\"path/to/pythonfile.py\")\n\n# Update the node in the graph:\npython_file.update_dynamo()\n\n# Save modified Dynamo graph:\ndyn2py.DynamoFile.write_open_files()\n```\n\nUpdate all python nodes of a Dynamo grapg from a different folder, save backups:\n\n```python\nimport dyn2py\n\n# open a Dynamo graph:\ndynamo_file = dyn2py.DynamoFile(\"path/to/dynamofile.dyn\")\n\n# Get python files from a dofferent folder:\npython_files = dynamo_file.get_related_python_files(python_folder=\"path/to/pythonfiles\")\n\n# Read python files and update the graph:\n[python_file.update_dynamo() for python_file in python_files]\n\n# Save open Dynamo graphs:\ndyn2py.DynamoFile.write_open_files(backup=True)\n```\n\nFor more examples check tests in the [tests folder on Github](https://github.com/infeeeee/dyn2py/tree/main/tests)\n\nThey should work in Dynamo, inside CPython3 nodes.\n\n## Troubleshooting\n\nIf you have a problem, open an [issue on Github](https://github.com/infeeeee/dyn2py/issues)\n\nYou can also ask about this project on [Dynamo Forum](https://forum.dynamobim.com/), don't forget to ping me: [@infeeeee](https://forum.dynamobim.com/u/infeeeee)\n\n## Limitations\n\nOnly supports Dynamo 2 files, Dynamo 1 files are reported and ignored. Please update them to Dynamo 2 by opening them in Dynamo 2.\n\nBoth IronPython2 and CPython3 nodes are supported! IronPython2 nodes won't be updated to CPython3, they will be imported as-is.\n\nCannot create new python nodes, only existing ones can be updated.\n\n## Development\n\n### Installation\n\nRequirements: git, python, pip\n\n```\ngit clone https://github.com/infeeeee/dyn2py\ncd dyn2py\npip install -e .\n```\n\nWith venv:\n\n```\ngit clone https://github.com/infeeeee/dyn2py\ncd dyn2py\npython -m venv .venv\n. ./.venv/bin/activate\npip install -e .\n```\n\n### Build for Windows\n\n```\npip install -e .[build]\npyinstaller dyn2py.spec\n```\n\n### Create installer for Windows\n\n- Install Inno Setup: https://jrsoftware.org/isdl.php\n- Build an exe\n- Run `dyn2py-installer.ps1` in powershell\n\n### Live module documentation\n\n```\npip install -e .[doc]\npdoc -d google dyn2py\n```\n\n### Unit tests\n\nVSCode should automatically discover unit tests. \n\nTo run them manually:\n\n```\npython -m unittest discover -v -s ./tests -p \"test_*.py\"\n```\n\n### New release\n\n1. Update version number in `pyproject.toml`\n2. Create and publish a git tag with that number\n\n## License\n\nGPL-3.0\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfeeeee%2Fdyn2py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfeeeee%2Fdyn2py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfeeeee%2Fdyn2py/lists"}