Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3409bb2
WIP: setting testing env for ci
9and3 Jan 17, 2024
ced3d73
WIP: testing on cpy_dev ci branch
9and3 Jan 17, 2024
87e10e0
WIP: added also main for ci testing
9and3 Jan 17, 2024
27456c2
WIP-CAP: ironpy to cpy compiling olc cpy
9and3 Jan 17, 2024
b372b93
WIP: notes on xml, next it's testing deserialization on ghuser cpy
9and3 Jan 17, 2024
7d7a1f9
WIP: working on deseriaization
9and3 Jan 19, 2024
80900a4
WIP: test commit
9and3 Jan 19, 2024
f42fba7
FIX: got rid of test in readme
9and3 Jan 19, 2024
dd0d630
WIP: compilationg works but component is C#, why?
9and3 Jan 19, 2024
666e009
WIP-CAP: changed all output guid to no_hint (out parameter is not def…
9and3 Jan 20, 2024
ccd6ffc
FIX: modified and verified guid typeHint compatibility
9and3 Jan 21, 2024
f916e3d
CAP: working marshalling python code
9and3 Jan 21, 2024
fc6f601
MILESTONE: working, rearraning structure for PR
9and3 Jan 21, 2024
ea74a49
WIP: preparing restructure for pr - test commit
9and3 Jan 21, 2024
7c7046e
WIP: testin on local ci
9and3 Jan 21, 2024
24b1bac
FIX: wrong action path from build solved
9and3 Jan 21, 2024
2c6f45a
Merge branch 'restructure_cpy'
9and3 Jan 21, 2024
47d1916
WIP:integrated minor modifications from ccde review
9and3 Jan 23, 2024
214fa46
WIP: testing reformat CI
9and3 Jan 23, 2024
02a4a40
WIP: testing reformat CI x2
9and3 Jan 23, 2024
69e3cad
WIP: testing out dual branch
9and3 Jan 23, 2024
c99d120
WIP: testing out dual branch x2
9and3 Jan 23, 2024
685c868
WIP: testing out dual branch x2
9and3 Jan 23, 2024
bdcb24f
WIP: testing out dual branc, two componentize
9and3 Jan 23, 2024
4b17c47
ADD: seperate examples folder
9and3 Jan 23, 2024
4086218
ADD: new main build
9and3 Jan 23, 2024
2c171c6
FIX: add parameter to action
9and3 Jan 23, 2024
a53037e
FIX: specified different build out directories for artifacts
9and3 Jan 23, 2024
d8c959a
FIX-WIP: testing nuget in action
9and3 Jan 23, 2024
a9665af
FIX: reversed to compas format for build workflow and action isntalls
9and3 Jan 23, 2024
c76d1e5
WIP-CAP: final testing before refactoring readme instructions
9and3 Jan 23, 2024
6295a85
WIP: retesting only one main workflow
9and3 Jan 23, 2024
d16dab8
CAP: final modifications and readme updated
9and3 Jan 23, 2024
27b3bf2
FIX: forgot to set the example action to market ref
9and3 Jan 23, 2024
ac07855
REVIEW: final modifications integrated
9and3 Feb 6, 2024
fc88595
ADD-MINOR: description is used for tooltipping the component
9and3 Feb 7, 2024
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
42 changes: 33 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,46 @@ name: build
on: [push]

jobs:
build:
name: windows-ironpython
build_cpy_ghuser_components:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1.0.5

- name: Install CPython and pythonnet package
run: |
choco install python --version=3.9.10
python -m pip install pythonnet==3.0.3

- name: Run
uses: ./
with:
source: examples/cpy
target: build
interpreter: cpython

- uses: actions/upload-artifact@v2
with:
name: cpy_ghuser-components
path: build

build_ipy_ghuser_components:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1.0.5

- name: Install IronPython
run: |
choco install ironpython --version=2.7.8.1
- name: Install dependencies
run: |
nuget install Grasshopper -OutputDirectory ./lib -source https://api.nuget.org/v3/index.json

- name: Run
run: |
ipy componentize.py examples build
uses: ./
with:
source: examples/ipy
target: build

- uses: actions/upload-artifact@v2
with:
name: ghuser-components
path: build
name: ipy_ghuser-components
path: build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# avoid temp folder
temp/
68 changes: 52 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GHPython Componentizer

> A github action to make Grasshopper development 164% <sup><small>[1]</small></sup> version-control friendlier and 82% more pleasant.
> A github action to make Grasshopper development 165% <sup><small>[1]</small></sup> version-control friendlier and 83% more pleasant.

Imagine if you could write your grasshopper components in Python code in an actual text file with a powerful editor?
Imagine if you could write your grasshopper components in Python code (both IronPython for RhinoV7 and less, or CPython for RhinoV8) in an actual text file with a powerful editor?
Git wouldn't hate you and life would be so much beautiful. 🐵

Well, here's an action for you then! 🦸‍♀️
Expand All @@ -14,25 +14,29 @@ Well, here's an action for you then! 🦸‍♀️
### Usage from Github Actions

The recommended way to use this tool is as a Github Action.
It needs to be run on a windows runner and IronPython/NuGet need to be pre-installed.
It needs to be run on a windows runner and IronPython/NuGet or Python3/pythonnet/Nuget depending of which component you want to build, needs to be pre-installed.

Copy the following workflow code into a `.github/workflows/main.yml` file in your repository.
Make sure you have the components definition (see below for details) stored in a source folder.
Replace the `source` and `target` to match your folder structure.
To specify the interpreter to use, you can define the action parameter `interpreter` to either `ironpython` or `python3` (by default it is `ironpython`).

For IronPython (RhinoV7 and less):

```yaml
on: [push]

jobs:
build_ghuser_components:
build_ipy_ghuser_components:
runs-on: windows-latest
name: Build components
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1.0.5

- name: Install IronPython
run: |
choco install ironpython --version=2.7.8.1

- uses: compas-dev/compas-actions.ghpython_components@v2
with:
source: components
Expand All @@ -43,28 +47,60 @@ jobs:
# upload them as artifacts:
- uses: actions/upload-artifact@v2
with:
name: ghuser-components
name: ipy_ghuser-components
path: build
```

For Python3 (RhinoV8):

```yaml
on: [push]

jobs:
build_cpy_ghuser_components:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: NuGet/setup-nuget@v1.0.5

- name: Install CPython and pythonnet package
run: |
choco install python --version=3.9.10
python -m pip install pythonnet==3.0.3

- uses: compas-dev/compas-actions.ghpython_components@v2
with:
source: components
target: build
interpreter: cpython # optional, defaults to ironpython

- uses: actions/upload-artifact@v2
with:
name: cpy_ghuser-components
path: build
```


Commit, push and enjoy! 🍿

### Usage on the command line

Alternatively, you can also use this tool directly from the command line.
Make sure to have IronPython installed and the `GH_IO.dll` assembly available.
Make sure to have IronPython or Python3/pythonnet installed and the `GH_IO.dll` assembly available.
Then start the script pointing it to a source and target folder, e.g.:

ipy componentize.py examples build
ipy componentize_ipy.py examples/ipy build
python componentize_cpy.py examples/cpy build

Optionally, tag it with a version:

ipy componentize.py examples build --version 0.1.2
ipy componentize_ipy.py examples/ipy build --version 0.1.2
python componentize_cpy.py examples/cpy build --version 0.1.2

An optional name prefix can help tell components apart from other similarly named ones:

ipy componentize.py examples build --prefix "(PACKAGE-NAME)"
ipy componentize_ipy.py examples/ipy build --prefix "(PACKAGE-NAME)"
python componentize_cpy.py examples/cpy build --prefix "(PACKAGE-NAME)"

## How to create components

Expand Down Expand Up @@ -96,8 +132,7 @@ An alternative is to include them in your packaging steps, e.g. calling `python

## Python code

* Supports both procedural and GH_Component SDK modes (see `isAdvancedMode` in metadata)
* Supports a small set of templated variables that can be used in code:
Supports a small set of templated variables that can be used in code:
* `{{version}}`: Gets replaced with the version, if specified in the command-line.
* `{{name}}`: Gets replaced with the name of the component as defined in the metadata file.
* `{{ghuser_name}}`: Gets replaced with the name of the `.ghuser` file being generated.
Expand All @@ -120,10 +155,11 @@ An alternative is to include them in your packaging steps, e.g. calling `python
* `128`: Expose the object in the seventh section on the toolbar.
* `instanceGuid`: **(optional)** Statically define a GUID for this instance. Defaults to a new Guid.
* `ghpython`
* `hideOutput`: **(optional)** Defines whether to hide or not `out` output parameter. Defaults to `True`.
* `hideInput`: **(optional)** Defines whether to hide or not the `code` input parameter. Defaults to `True`.
* `isAdvancedMode`: **(optional)** Defines whether the script is in advanced mode (aka GH_Component SDK mode) or procedural mode. Defaults to `False`.
* `marshalOutGuids`: **(optional)** Defines whether output Guids will be looked up or not. Defaults to `True`. Change to `False` to preserve output Guids.
* `hideOutput`: **(optional ⚠️ only IronPython)** Defines whether to hide or not `out` output parameter. Defaults to `True`.
* `hideInput`: **(optional ⚠️ only IronPython)** Defines whether to hide or not the `code` input parameter. Defaults to `True`.
* `isAdvancedMode`: **(optional ⚠️ only IronPython)** Defines whether the script is in advanced mode (aka GH_Component SDK mode) or procedural mode. Defaults to `False`.
* `marshalOutGuids`: **(optional ⚠️ only IronPython)** Defines whether output Guids will be looked up or not. Defaults to `True`. Change to `False` to preserve output Guids.
* `marshalGuids`: **(optional ⚠️ only CPython)** Defines whether input Guids will be looked up or not. Defaults to `True`. Change to `False` to preserve input Guids.
* `iconDisplay`: **(optional)** Defines whether to display the icon or not. Defaults to `0`.
* `0` : Application setting
* `1` : Text display
Expand Down
24 changes: 19 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,29 @@ inputs:
prefix:
description: 'Add this prefix to the name of each generated component'
required: false
interpreter:
description: 'Python interpreter to use: ironpython, or cpython'
required: false
default: 'ironpython'

runs:
using: 'composite'
steps:
- run: nuget install Grasshopper -OutputDirectory ./lib -source https://api.nuget.org/v3/index.json
- name: Install Grasshopper
run: nuget install Grasshopper -OutputDirectory ./lib -source https://api.nuget.org/v3/index.json
shell: pwsh
- run: |
$command="ipy"
$params="${{ github.action_path }}/componentize.py", "${{ inputs.source }}", "${{ inputs.target }}", "--ghio", "./lib"
$prefix="${{ inputs.prefix }}"

- name: Launch componentizer
run: |
if ("${{ inputs.interpreter }}" -eq "cpython") {
$command="python"
$componentizer="${{ github.action_path }}/componentize_cpy.py"
} else {
$command="ipy"
$componentizer="${{ github.action_path }}/componentize_ipy.py"
}
$params=$componentizer, "${{ inputs.source }}", "${{ inputs.target }}", "--ghio", "./lib"
$prefix="${{ inputs.prefix }}"
if( $prefix )
{
$params=$params + "--prefix", "$prefix"
Expand Down
Loading