mirror of
https://github.com/infeeeee/dyn2py
synced 2025-12-16 22:16:18 +01:00
Compare commits
8 Commits
0.3.0
...
14e1a3b7a2
| Author | SHA1 | Date | |
|---|---|---|---|
| 14e1a3b7a2 | |||
| a71979c6ac | |||
| 7ec513feb4 | |||
| f7a2dc2d41 | |||
| 025b50ecf3 | |||
| 2553d84d91 | |||
| 6ee8c7fe75 | |||
| 6675c003e7 |
60
.github/workflows/release.yml
vendored
60
.github/workflows/release.yml
vendored
@@ -9,29 +9,75 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
test:
|
||||||
runs-on: windows-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
uses: ./.github/workflows/test.yml
|
||||||
|
with:
|
||||||
|
python-version: ${{ vars.PYTHON_VERSION}}
|
||||||
|
os: ${{ matrix.os }}
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
needs: test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
name: Checkout
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
|
name: Setup Python
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: ${{ vars.PYTHON_VERSION}}
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install .[build]
|
pip install .[build]
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pyinstaller dyn2py.spec
|
run: pyinstaller dyn2py.spec
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
|
name: Upload artifact
|
||||||
with:
|
with:
|
||||||
name: dyn2py.exe
|
name: dyn2py.exe
|
||||||
path: dist/dyn2py.exe
|
path: dist/dyn2py.exe
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
name: Checkout
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
uses: metcalfc/changelog-generator@v4.1.0
|
||||||
|
with:
|
||||||
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: dyn2py.exe
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: dist/dyn2py.exe
|
files: dyn2py.exe
|
||||||
|
body: ${{ steps.modified.outputs.log }}
|
||||||
|
|
||||||
|
pip:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: release
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
name: Checkout
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
name: Setup Python
|
||||||
|
with:
|
||||||
|
python-version: ${{ vars.PYTHON_VERSION}}
|
||||||
|
- name: Install deps
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install build
|
||||||
|
- name: Build package
|
||||||
|
run: python -m build
|
||||||
|
- name: Publish to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
|||||||
25
.github/workflows/test.yml
vendored
Normal file
25
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
python-version:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
os:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ${{ inputs.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up Python ${{ inputs.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ inputs.python-version }}
|
||||||
|
- name: Install deps
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install .
|
||||||
|
- name: Test
|
||||||
|
run: python -m unittest discover -v -s ./tests -p "test_*.py"
|
||||||
22
.github/workflows/unittests.yml
vendored
22
.github/workflows/unittests.yml
vendored
@@ -14,21 +14,9 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest]
|
os: [ubuntu-latest, windows-latest]
|
||||||
python-version: [3.8, 3.9, "3.10", 3.11]
|
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
uses: ./.github/workflows/test.yml
|
||||||
- uses: actions/checkout@v3
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
os: ${{ matrix.os }}
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Install deps
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install .
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: python -m unittest discover -v -s ./tests -p "test_*.py"
|
|
||||||
|
|||||||
5
.github/workflows/website.yml
vendored
5
.github/workflows/website.yml
vendored
@@ -2,9 +2,8 @@ name: Deploy website
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Only build for tags.
|
branches:
|
||||||
tags:
|
- main
|
||||||
- "*"
|
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|||||||
90
README.md
90
README.md
@@ -1,3 +1,11 @@
|
|||||||
|
[](https://github.com/infeeeee/dyn2py/releases/latest)
|
||||||
|
[](https://pypi.org/project/dyn2py/)
|
||||||
|
[](https://github.com/infeeeee/dyn2py/releases/latest)
|
||||||
|
[](https://github.com/infeeeee/dyn2py/commits/main)
|
||||||
|
[](https://github.com/infeeeee/dyn2py/actions/workflows/unittests.yml)
|
||||||
|

|
||||||
|
[](https://github.com/infeeeee/dyn2py/blob/main/LICENSE)
|
||||||
|
|
||||||
# dyn2py
|
# dyn2py
|
||||||
|
|
||||||
Extract python code from Dynamo graphs
|
Extract python code from Dynamo graphs
|
||||||
@@ -5,19 +13,28 @@ Extract python code from Dynamo graphs
|
|||||||
Use cases:
|
Use cases:
|
||||||
|
|
||||||
- Track changes in python nodes in source control systems like git
|
- Track changes in python nodes in source control systems like git
|
||||||
- Work on python code in your favorite code editor outside Dynamo. `dyn2py` can also update Dynamo graphs from the previously exported python files.
|
- Work on python code in your favorite code editor outside Dynamo. `dyn2py` can also update Dynamo graphs from previously exported python files.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### With pip from Github
|
### Windows portable
|
||||||
|
|
||||||
Requirements: git, python, pip
|
Prebuilt exe available from github releases.
|
||||||
|
|
||||||
|
No requirements, just download `dyn2py.exe` from release assets:
|
||||||
|
|
||||||
|
https://github.com/infeeeee/dyn2py/releases/latest
|
||||||
|
|
||||||
|
### With pip
|
||||||
|
|
||||||
|
For usage as a module or as a command line program
|
||||||
|
|
||||||
|
Requirements: python, pip
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install "dyn2py @ git+https://github.com/infeeeee/dyn2py"
|
pip install dyn2py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### As a standalone command line program
|
### As a standalone command line program
|
||||||
@@ -52,11 +69,39 @@ Do not move the source Dynamo graphs, or update won't work with them later.
|
|||||||
Multiple sources are supported, separate them by spaces.
|
Multiple sources are supported, separate them by spaces.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
*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.*
|
||||||
|
|
||||||
|
Extract all nodes next to a Dynamo file:
|
||||||
|
|
||||||
|
```
|
||||||
|
dyn2py path/to/dynamofile.dyn
|
||||||
|
```
|
||||||
|
|
||||||
|
Update a Dynamo file from previously exported and modified python files:
|
||||||
|
|
||||||
|
```
|
||||||
|
dyn2py --update path/to/dynamofile.dyn
|
||||||
|
```
|
||||||
|
|
||||||
|
Extract python nodes to a specific folder, process multiple Dynamo files:
|
||||||
|
|
||||||
|
```
|
||||||
|
dyn2py --python-folder path/to/pythonfiles path/to/dynamofile1.dyn path/to/dynamofile2.dyn
|
||||||
|
```
|
||||||
|
|
||||||
|
Update Dynamo files from python files from a folder. Only check python files, create backups:
|
||||||
|
|
||||||
|
```
|
||||||
|
dyn2py --filter py --backup path/to/pythonfiles
|
||||||
|
```
|
||||||
|
|
||||||
### As a python module
|
### As a python module
|
||||||
|
|
||||||
Full API documentation available here: https://infeeeee.github.io/dyn2py
|
Full API documentation available here: https://infeeeee.github.io/dyn2py
|
||||||
|
|
||||||
Most basic example to extract all nodes next to a dynamo file:
|
Most basic example to extract all nodes next to a Dynamo file:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import dyn2py
|
import dyn2py
|
||||||
@@ -86,11 +131,27 @@ python_files = dynamo_file.get_related_python_files(options)
|
|||||||
dynamo_file.write(options)
|
dynamo_file.write(options)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For more examples check tests in the [tests folder on Github](https://github.com/infeeeee/dyn2py/tree/main/tests)
|
||||||
|
|
||||||
|
They should work in Dynamo, inside CPython3 nodes.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If you have a problem, open an [issue on Github](https://github.com/infeeeee/dyn2py/issues)
|
||||||
|
|
||||||
|
You 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)
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
Only supports Dynamo 2 files, Dynamo 1 files are reported and ignored. Please update them to Dynamo 2 by opening them in Dynamo 2.
|
||||||
|
|
||||||
|
Both IronPython2 and CPython3 nodes are supported! IronPython2 nodes won't be updated to CPython3, they will be imported as-is.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
Requirements: git, pip
|
Requirements: git, python, pip
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/infeeeee/dyn2py
|
git clone https://github.com/infeeeee/dyn2py
|
||||||
@@ -121,3 +182,18 @@ pyinstaller dyn2py.spec
|
|||||||
pip install -e .[doc]
|
pip install -e .[doc]
|
||||||
pdoc -d google dyn2py
|
pdoc -d google dyn2py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
VSCode should automatically discover unit tests.
|
||||||
|
|
||||||
|
To run them manually:
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m unittest discover -v -s ./tests -p "test_*.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GPL-3.0
|
||||||
|
|
||||||
|
|||||||
6
TODO.md
6
TODO.md
@@ -14,13 +14,13 @@
|
|||||||
- [x] Tests on Linux
|
- [x] Tests on Linux
|
||||||
- [x] Tests on Windows
|
- [x] Tests on Windows
|
||||||
- [x] Windows Build
|
- [x] Windows Build
|
||||||
- [ ] Pip
|
- [x] Pip
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [x] API docs
|
- [x] API docs
|
||||||
- [ ] Installation in readme
|
- [x] Installation in readme
|
||||||
- [ ] Terminal examples in readme
|
- [x] Terminal examples in readme
|
||||||
- [ ] About git hooks in readme
|
- [ ] About git hooks in readme
|
||||||
|
|
||||||
## Extra features maybe later
|
## Extra features maybe later
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ class PythonFile(File):
|
|||||||
"""A Python file, subclass of File()"""
|
"""A Python file, subclass of File()"""
|
||||||
|
|
||||||
code: list[str]
|
code: list[str]
|
||||||
"""The python code."""
|
"""The python code. Lines as list items, without newlines."""
|
||||||
header_data: dict
|
header_data: dict
|
||||||
"""Parsed dict from the header of a python file."""
|
"""Parsed dict from the header of a python file."""
|
||||||
text: str
|
text: str
|
||||||
@@ -564,7 +564,7 @@ class PythonNode():
|
|||||||
engine: str
|
engine: str
|
||||||
"""The engine of the node, IronPython2 or CPython3"""
|
"""The engine of the node, IronPython2 or CPython3"""
|
||||||
code: list[str]
|
code: list[str]
|
||||||
"""The full code"""
|
"""The full code. Lines as list items, without newlines."""
|
||||||
checksum: str
|
checksum: str
|
||||||
"""The checksum of the code, for checking changes"""
|
"""The checksum of the code, for checking changes"""
|
||||||
name: str
|
name: str
|
||||||
@@ -572,7 +572,7 @@ class PythonNode():
|
|||||||
filename: pathlib.Path | str
|
filename: pathlib.Path | str
|
||||||
"""The filename the node should be saved as, including the .py extension"""
|
"""The filename the node should be saved as, including the .py extension"""
|
||||||
filepath: pathlib.Path
|
filepath: pathlib.Path
|
||||||
"""The path is shoul"""
|
"""The full path the node should be saved as"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
node_dict_from_dyn: dict = {},
|
node_dict_from_dyn: dict = {},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "dyn2py"
|
name = "dyn2py"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
description = "Extract python code from Dynamo graphs"
|
description = "Extract python code from Dynamo graphs"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
@@ -11,7 +11,7 @@ license = { file = "LICENSE" }
|
|||||||
authors = [{ name = "infeeeee", email = "gyetpet@mailbox.org" }]
|
authors = [{ name = "infeeeee", email = "gyetpet@mailbox.org" }]
|
||||||
maintainers = [{ name = "infeeeee", email = "gyetpet@mailbox.org" }]
|
maintainers = [{ name = "infeeeee", email = "gyetpet@mailbox.org" }]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 4 - Beta",
|
||||||
"Environment :: Console",
|
"Environment :: Console",
|
||||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||||
]
|
]
|
||||||
@@ -23,7 +23,6 @@ build = ["pyinstaller"]
|
|||||||
doc = ["pdoc"]
|
doc = ["pdoc"]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
homepage = "https://github.com/infeeeee/dyn2py"
|
|
||||||
documentation = "https://infeeeee.github.io/dyn2py"
|
documentation = "https://infeeeee.github.io/dyn2py"
|
||||||
repository = "https://github.com/infeeeee/dyn2py"
|
repository = "https://github.com/infeeeee/dyn2py"
|
||||||
changelog = "https://github.com/infeeeee/dyn2py/releases"
|
changelog = "https://github.com/infeeeee/dyn2py/releases"
|
||||||
|
|||||||
Reference in New Issue
Block a user