You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+102Lines changed: 102 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,108 @@ git add .gitmodules
48
48
git commit -m "Remove a submodule name"
49
49
```
50
50
51
+
---
52
+
# Python
53
+
DiffCheck is distributed as a Python Grasshopperr plug-in via yak and its source code via PyPI. The plug-in is composed by a series of `.ghuser` components.
54
+
55
+
There are 3 ways you can contribute to the Python GH plug-in:
56
+
1. By adding new components to the plug-in.
57
+
2. By fixing bugs of existing components in the plug-in.
58
+
3. By adding new functionalities to existing components in the plug-in.
59
+
60
+
Before committing to the repository you need to have tested the components in the Grasshopper environment and be sure that this is working correctly. Also, provide a sufficient documentation in the PR (for now) please.
61
+
62
+
Follow these steps to develop and test the Python GH plug-in:
63
+
-[GHPy: A) preparation](#ghpy-a-preparation)
64
+
-[GHPy: B) development/debug](#ghpy-b-developmentdebug)
> note that if you drop an official released diffCheck component from yak, this one will have the `#r : diffCheck==<version_number>` notation at the top of the script. Get rid of all these release components before to start and be sur to erase again the previous folders (they recreated each time `#r : diffCheck` is called).
79
+
80
+
Lastly, install the pip pacakge from the repository in editable mode. This way, all the modifications made to the source code of the repository will be reflected in the installed package. Open a terminal and run the following command (replace the path with where you download the repository):
For your info the packages is installed in `C:\Users\andre\.rhinocode\py39-rh8\Lib\site-packages`.
86
+
87
+
That's it you are now a contributor to the diffCheck! We raccomand to not download anymore from yak package but rather use the source code in the repository. If you want the latest diffCheck, checkout and pull the main.
88
+
89
+
## GHPy: B) development/debug
90
+
91
+
### B.1) Code structure
92
+
For DiffCheck there are 2 main folders in the repository:
93
+
*`src/gh/diffCheck/components` here you can add new components or modify existing ones (for more info on how to create one we point you to [this documentation](https://github.com/compas-dev/compas-actions.ghpython_components)). Here we call the
94
+
*`src/gh/diffCheck/diffCheck` this is our package where the core functionalities are implemented.
95
+
96
+
### B.2) Developing component's content
97
+
The idea is to start by developing the content of the component in the file `src/gh/diffCheck/diffCgeck_app.py`. This would be a simple script that contains the logic of the component. Once the script `diffCheck_app.py` is working correctly, you can move the code to the component file in the `src/gh/diffCheck/components` folder. This is because the component file is the one that will be componentized and distributed via yak.
98
+
99
+
We reccomand to use `VSCode` as IDE for developing the components. This is because it has a good integration with the `Grasshopper` environment and it is easy to debug the components. To set up the IDE follow these steps:
100
+
1. Install the `ScriptSync` extension for `VSCode`.
101
+
2. Install the `ScriptSync` from the yak manager in Rhino.
102
+
3. Open the `diffCheckApp.py` from the `src/gh/diffCheck/components` folder you are working on in `VSCode`, and set its path to the ScriptSync ghcomponent.
103
+
4. If you modify the code in `VSCode`, the changes will be reflected in the Grasshopper component as soon as you save in `VSCode` again the `code.py`.
104
+
5. Once your code is working, prepare the code and componentize it.
105
+
106
+
If you want to use the GHEditor it's ok but everytime you modify the pakcage or the component's code, after any modifications you need to restart the Python interpreter from the ScriptEditor (`Tools > Reload Python3 (CPython) Engine`) and recompute the solution in Grasshopper.
107
+
108
+
### B.3) Componentize the code
109
+
Prepare your component as explained here. You can componentize it locally and test it in Grasshopper. Here's how to componentize:
> Note that you need to find the path to your GHIO folder. This is the folder where the `Grasshopper.dll` is located. E.g. You can find it in the `nuget` folder in the Rhino installation directory.
114
+
115
+
Once you are sure that the component is working correctly, you can push the changes to the repository.
116
+
117
+
## GHPy: C) Release
118
+
The release will be made via CI from main. As a contributor you don't need to worry about this. The plug-in is componentized, pushed to yak/PyPI and the user can download the latest version from yak.
119
+
120
+
## GHPy: D) Documentation
121
+
More to come.
122
+
123
+
124
+
<!-- ## PyPI
125
+
To push the package to PyPI, you need to:
126
+
1. Install the package `twine`:
127
+
```bash
128
+
pip install twine
129
+
```
130
+
2. Build the package:
131
+
```bash
132
+
python setup.py sdist bdist_wheel
133
+
```
134
+
3. Check the package:
135
+
```bash
136
+
twine check dist/*
137
+
```
138
+
4. Upload the package:
139
+
```bash
140
+
twine upload dist/*
141
+
```
142
+
Be sure to have the right to upload the package to the PyPI repository.
143
+
To do so you need to set the `~/.pypirc` file with the following content:
0 commit comments