compas-invocations2 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {compas_invocations2-0.3.0/src/compas_invocations2.egg-info → compas_invocations2-0.3.2}/PKG-INFO +2 -1
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/pyproject.toml +1 -1
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/requirements-dev.txt +2 -1
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/__init__.py +1 -1
- compas_invocations2-0.3.2/src/compas_invocations2/grasshopper.py +198 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2/src/compas_invocations2.egg-info}/PKG-INFO +2 -1
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/SOURCES.txt +1 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/requires.txt +1 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/LICENSE +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/README.md +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/requirements.txt +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/setup.cfg +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/build.py +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/console.py +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/docs.py +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/style.py +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2/tests.py +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/dependency_links.txt +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/not-zip-safe +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/top_level.txt +0 -0
- {compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/tests/test_placeholder.py +0 -0
{compas_invocations2-0.3.0/src/compas_invocations2.egg-info → compas_invocations2-0.3.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: compas_invocations2
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: A collection of reusable pyinvoke tasks.
|
|
5
5
|
Author-email: Li Chen <li.chen@arch.ethz.ch>
|
|
6
6
|
License: MIT License
|
|
@@ -49,6 +49,7 @@ Requires-Dist: ruff; extra == "dev"
|
|
|
49
49
|
Requires-Dist: sphinx_compas2_theme; extra == "dev"
|
|
50
50
|
Requires-Dist: twine; extra == "dev"
|
|
51
51
|
Requires-Dist: wheel; extra == "dev"
|
|
52
|
+
Requires-Dist: tomlkit; extra == "dev"
|
|
52
53
|
|
|
53
54
|
# compas_invocations2
|
|
54
55
|
|
|
@@ -72,7 +72,7 @@ doctest_optionflags = [
|
|
|
72
72
|
# ============================================================================
|
|
73
73
|
|
|
74
74
|
[tool.bumpversion]
|
|
75
|
-
current_version = "0.3.
|
|
75
|
+
current_version = "0.3.2"
|
|
76
76
|
message = "Bump version to {new_version}"
|
|
77
77
|
commit = true
|
|
78
78
|
tag = true
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Adapted from: https://github.com/diffCheckOrg/diffCheck/blob/main/invokes/yakerize.py
|
|
3
|
+
|
|
4
|
+
Yakerize.py was originally developed as part of the DiffCheck plugin by
|
|
5
|
+
Andrea Settimi, Damien Gilliard, Eleni Skevaki, Marirena Kladeftira (IBOIS, CRCL, EPFL) in 2024.
|
|
6
|
+
It is distributed under the MIT License, provided this attribution is retained.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import shutil
|
|
11
|
+
import tempfile
|
|
12
|
+
|
|
13
|
+
import invoke
|
|
14
|
+
import requests
|
|
15
|
+
import tomlkit
|
|
16
|
+
|
|
17
|
+
from compas_invocations2.console import chdir
|
|
18
|
+
|
|
19
|
+
YAK_URL = r"https://files.mcneel.com/yak/tools/latest/yak.exe"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _download_yak_executable(target_dir: str):
|
|
23
|
+
response = requests.get(YAK_URL)
|
|
24
|
+
if response.status_code != 200:
|
|
25
|
+
raise ValueError(f"Failed to download the yak.exe from url:{YAK_URL} with error : {response.status_code}")
|
|
26
|
+
|
|
27
|
+
target_path = os.path.join(target_dir, "yak.exe")
|
|
28
|
+
with open(target_path, "wb") as f:
|
|
29
|
+
f.write(response.content)
|
|
30
|
+
return target_path
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _set_version_in_manifest(manifest_path: str, version: str):
|
|
34
|
+
with open(manifest_path, "r") as f:
|
|
35
|
+
lines = f.readlines()
|
|
36
|
+
|
|
37
|
+
new_lines = []
|
|
38
|
+
for line in lines:
|
|
39
|
+
if "{{ version }}" in line:
|
|
40
|
+
new_lines.append(line.replace("{{ version }}", version))
|
|
41
|
+
else:
|
|
42
|
+
new_lines.append(line)
|
|
43
|
+
|
|
44
|
+
with open(manifest_path, "w") as f:
|
|
45
|
+
f.writelines(new_lines)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _clear_directory(path_to_dir):
|
|
49
|
+
for f in os.listdir(path_to_dir):
|
|
50
|
+
file_path = os.path.join(path_to_dir, f)
|
|
51
|
+
try:
|
|
52
|
+
if os.path.isfile(file_path) or os.path.islink(file_path):
|
|
53
|
+
os.unlink(file_path)
|
|
54
|
+
elif os.path.isdir(file_path):
|
|
55
|
+
shutil.rmtree(file_path)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
raise invoke.Exit(f"Failed to delete {file_path}: {e}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _get_version_from_toml(toml_file: str) -> str:
|
|
61
|
+
with open(toml_file, "r") as f:
|
|
62
|
+
pyproject_data = tomlkit.load(f)
|
|
63
|
+
if not pyproject_data:
|
|
64
|
+
raise invoke.Exit("Failed to load pyproject.toml.")
|
|
65
|
+
|
|
66
|
+
version = pyproject_data.get("tool", {}).get("bumpversion", {}).get("current_version", None)
|
|
67
|
+
if not version:
|
|
68
|
+
raise invoke.Exit("Failed to get version from pyproject.toml. Please provide a version number.")
|
|
69
|
+
return version
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _get_user_object_path(context):
|
|
73
|
+
if hasattr(context, "ghuser_cpython"):
|
|
74
|
+
print("checking ghuser_cpython")
|
|
75
|
+
return os.path.join(context.base_folder, context.ghuser_cpython.target_dir)
|
|
76
|
+
elif hasattr(context, "ghuser"):
|
|
77
|
+
print("checking ghuser")
|
|
78
|
+
return os.path.join(context.base_folder, context.ghuser.target_dir)
|
|
79
|
+
else:
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@invoke.task(
|
|
84
|
+
help={
|
|
85
|
+
"manifest_path": "Path to the manifest file.",
|
|
86
|
+
"logo_path": "Path to the logo file.",
|
|
87
|
+
"gh_components_dir": "(Optional) Path to the directory containing the .ghuser files.",
|
|
88
|
+
"readme_path": "(Optional) Path to the readme file.",
|
|
89
|
+
"license_path": "(Optional) Path to the license file.",
|
|
90
|
+
"version": "(Optional) The version number to set in the manifest file.",
|
|
91
|
+
"target_rhino": "(Optional) The target Rhino version for the package. Defaults to 'rh8'.",
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
def yakerize(
|
|
95
|
+
ctx,
|
|
96
|
+
manifest_path: str,
|
|
97
|
+
logo_path: str,
|
|
98
|
+
gh_components_dir: str = None,
|
|
99
|
+
readme_path: str = None,
|
|
100
|
+
license_path: str = None,
|
|
101
|
+
version: str = None,
|
|
102
|
+
target_rhino: str = "rh8",
|
|
103
|
+
) -> bool:
|
|
104
|
+
"""Create a Grasshopper YAK package from the current project."""
|
|
105
|
+
# https://developer.rhino3d.com/guides/yak/the-anatomy-of-a-package/
|
|
106
|
+
if target_rhino.split("_")[0] not in ["rh6", "rh7", "rh8"]:
|
|
107
|
+
raise invoke.Exit(
|
|
108
|
+
f"""Invalid target Rhino version `{target_rhino}`. Must be one of: rh6, rh7, rh8.
|
|
109
|
+
Minor version is optional and can be appended with a '_' (e.g. rh8_15)."""
|
|
110
|
+
)
|
|
111
|
+
gh_components_dir = gh_components_dir or _get_user_object_path(ctx)
|
|
112
|
+
if not gh_components_dir:
|
|
113
|
+
raise invoke.Exit("Please provide the path to the directory containing the .ghuser files.")
|
|
114
|
+
|
|
115
|
+
readme_path = readme_path or os.path.join(ctx.base_folder, "README.md")
|
|
116
|
+
if not os.path.exists(readme_path):
|
|
117
|
+
raise invoke.Exit(f"Readme file not found at {readme_path}. Please provide a valid path.")
|
|
118
|
+
|
|
119
|
+
license_path = license_path or os.path.join(ctx.base_folder, "LICENSE")
|
|
120
|
+
if not os.path.exists(license_path):
|
|
121
|
+
raise invoke.Exit(f"License file not found at {license_path}. Please provide a valid path.")
|
|
122
|
+
|
|
123
|
+
version = version or _get_version_from_toml(os.path.join(ctx.base_folder, "pyproject.toml"))
|
|
124
|
+
target_dir = os.path.join(ctx.base_folder, "dist", "yak_package")
|
|
125
|
+
|
|
126
|
+
#####################################################################
|
|
127
|
+
# Copy manifest, logo, misc folder (readme, license, etc)
|
|
128
|
+
#####################################################################
|
|
129
|
+
# if target dit exists, make sure it's empty
|
|
130
|
+
if os.path.exists(target_dir) and os.path.isdir(target_dir):
|
|
131
|
+
_clear_directory(target_dir)
|
|
132
|
+
else:
|
|
133
|
+
os.makedirs(target_dir, exist_ok=False)
|
|
134
|
+
|
|
135
|
+
manifest_target = shutil.copy(manifest_path, target_dir)
|
|
136
|
+
_set_version_in_manifest(manifest_target, version)
|
|
137
|
+
shutil.copy(logo_path, target_dir)
|
|
138
|
+
|
|
139
|
+
path_miscdir: str = os.path.join(target_dir, "misc")
|
|
140
|
+
os.makedirs(path_miscdir, exist_ok=False)
|
|
141
|
+
shutil.copy(readme_path, path_miscdir)
|
|
142
|
+
shutil.copy(license_path, path_miscdir)
|
|
143
|
+
|
|
144
|
+
for f in os.listdir(gh_components_dir):
|
|
145
|
+
if f.endswith(".ghuser"):
|
|
146
|
+
shutil.copy(os.path.join(gh_components_dir, f), target_dir)
|
|
147
|
+
|
|
148
|
+
#####################################################################
|
|
149
|
+
# Yak exe
|
|
150
|
+
#####################################################################
|
|
151
|
+
|
|
152
|
+
# yak executable shouldn't be in the target directory, otherwise it will be included in the package
|
|
153
|
+
target_parent = os.sep.join(target_dir.split(os.sep)[:-1])
|
|
154
|
+
try:
|
|
155
|
+
yak_exe_path = _download_yak_executable(target_parent)
|
|
156
|
+
except ValueError:
|
|
157
|
+
raise invoke.Exit("Failed to download the yak executable")
|
|
158
|
+
else:
|
|
159
|
+
yak_exe_path = os.path.abspath(yak_exe_path)
|
|
160
|
+
|
|
161
|
+
with chdir(target_dir):
|
|
162
|
+
try:
|
|
163
|
+
# not using `ctx.run()` here to get properly formatted output (unicode+colors)
|
|
164
|
+
os.system(f"{yak_exe_path} build --platform any")
|
|
165
|
+
except Exception as e:
|
|
166
|
+
raise invoke.Exit(f"Failed to build the yak package: {e}")
|
|
167
|
+
if not any([f.endswith(".yak") for f in os.listdir(target_dir)]):
|
|
168
|
+
raise invoke.Exit("No .yak file was created in the build directory.")
|
|
169
|
+
|
|
170
|
+
# filename is what tells YAK the target Rhino version..?
|
|
171
|
+
taget_file = next((f for f in os.listdir(target_dir) if f.endswith(".yak")))
|
|
172
|
+
new_filename = taget_file.replace("any-any", f"{target_rhino}-any")
|
|
173
|
+
os.rename(taget_file, new_filename)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@invoke.task(
|
|
177
|
+
help={"yak_file": "Path to the .yak file to publish.", "test_server": "True to publish to the test server."}
|
|
178
|
+
)
|
|
179
|
+
def publish_yak(ctx, yak_file: str, test_server: bool = False):
|
|
180
|
+
"""Publish a YAK package to the YAK server."""
|
|
181
|
+
|
|
182
|
+
if not os.path.exists(yak_file) or not os.path.isfile(yak_file):
|
|
183
|
+
raise invoke.Exit(f"Yak file not found at {yak_file}. Please provide a valid path.")
|
|
184
|
+
if not yak_file.endswith(".yak"):
|
|
185
|
+
raise invoke.Exit("Invalid file type. Must be a .yak file.")
|
|
186
|
+
|
|
187
|
+
with chdir(ctx.base_folder):
|
|
188
|
+
with tempfile.TemporaryDirectory("actions.publish_yak") as action_dir:
|
|
189
|
+
try:
|
|
190
|
+
_download_yak_executable(action_dir)
|
|
191
|
+
except ValueError:
|
|
192
|
+
raise invoke.Exit("Failed to download the yak executable")
|
|
193
|
+
|
|
194
|
+
yak_exe_path: str = os.path.join(action_dir, "yak.exe")
|
|
195
|
+
if test_server:
|
|
196
|
+
ctx.run(f"{yak_exe_path} push --source https://test.yak.rhino3d.com {yak_file}")
|
|
197
|
+
else:
|
|
198
|
+
ctx.run(f"{yak_exe_path} push {yak_file}")
|
{compas_invocations2-0.3.0 → compas_invocations2-0.3.2/src/compas_invocations2.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: compas_invocations2
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: A collection of reusable pyinvoke tasks.
|
|
5
5
|
Author-email: Li Chen <li.chen@arch.ethz.ch>
|
|
6
6
|
License: MIT License
|
|
@@ -49,6 +49,7 @@ Requires-Dist: ruff; extra == "dev"
|
|
|
49
49
|
Requires-Dist: sphinx_compas2_theme; extra == "dev"
|
|
50
50
|
Requires-Dist: twine; extra == "dev"
|
|
51
51
|
Requires-Dist: wheel; extra == "dev"
|
|
52
|
+
Requires-Dist: tomlkit; extra == "dev"
|
|
52
53
|
|
|
53
54
|
# compas_invocations2
|
|
54
55
|
|
{compas_invocations2-0.3.0 → compas_invocations2-0.3.2}/src/compas_invocations2.egg-info/SOURCES.txt
RENAMED
|
@@ -7,6 +7,7 @@ src/compas_invocations2/__init__.py
|
|
|
7
7
|
src/compas_invocations2/build.py
|
|
8
8
|
src/compas_invocations2/console.py
|
|
9
9
|
src/compas_invocations2/docs.py
|
|
10
|
+
src/compas_invocations2/grasshopper.py
|
|
10
11
|
src/compas_invocations2/style.py
|
|
11
12
|
src/compas_invocations2/tests.py
|
|
12
13
|
src/compas_invocations2.egg-info/PKG-INFO
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|