poly-hammer-utils 0.0.28__py3-none-any.whl → 0.0.30__py3-none-any.whl

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.
@@ -7,7 +7,7 @@ from pathlib import Path
7
7
  from poly_hammer_utils.constants import ENVIRONMENT
8
8
  from poly_hammer_utils.utilities import download_and_unzip_to_folder, download_release_file
9
9
  from poly_hammer_utils.github.release import GitHubRelease
10
- from poly_hammer_utils.extension.packager import package_extension, get_addon_version
10
+ from poly_hammer_utils.extension.packager import package_extension, get_addon_version, rename_addon
11
11
  from poly_hammer_utils.extension.server import update_extension_index, sync_extensions_from_s3
12
12
 
13
13
  BLENDER_EXTENSION_SERVER_S3_BUCKET = 'poly-hammer-portal-staging-app-data'
@@ -16,6 +16,13 @@ if ENVIRONMENT == 'production':
16
16
 
17
17
  BLENDER_EXTENSION_SERVER_S3_FOLDER = 'products/blender-extensions/meta_human_dna'
18
18
 
19
+ IGNORE_PATTERNS = [
20
+ "__pycache__",
21
+ ".git",
22
+ ".venv",
23
+ "*.pyc"
24
+ ]
25
+
19
26
  logger = logging.getLogger(__name__)
20
27
 
21
28
  PREFIX = 'meta_human_dna_core.'
@@ -122,9 +129,35 @@ def get_meta_human_dna_core(addon_version: str, auth_token: str) -> list[Path]:
122
129
  file_paths.append(save_path)
123
130
  return file_paths
124
131
 
132
+ def copy_and_rename(addon_folder: Path, pro: bool = False) -> Path:
133
+ temp_addon_folder = Path(tempfile.mkdtemp()) / addon_folder.name
134
+ if pro:
135
+ temp_addon_folder = Path(tempfile.mkdtemp()) / f"{addon_folder.name}_pro"
136
+
137
+ shutil.copytree(
138
+ addon_folder,
139
+ temp_addon_folder,
140
+ ignore=shutil.ignore_patterns(*IGNORE_PATTERNS)
141
+ )
142
+
143
+ if pro:
144
+ rename_addon(
145
+ toml_file_path=temp_addon_folder / 'blender_manifest.toml',
146
+ constants_file_path=temp_addon_folder / 'constants.py',
147
+ addon_id='meta_human_dna',
148
+ new_addon_id='meta_human_dna_pro',
149
+ new_addon_name="MetaHuman DNA Pro"
150
+ )
151
+ else:
152
+ shutil.rmtree(temp_addon_folder / 'resources' / 'dna', ignore_errors=True)
153
+
154
+ return temp_addon_folder
155
+
125
156
  def create_release(addon_folder: Path, releases_folder: Path, pro: bool = False):
126
157
  token = os.environ['GH_PAT']
127
158
 
159
+ temp_addon_folder = copy_and_rename(addon_folder=addon_folder, pro=pro)
160
+
128
161
  addon_version = get_addon_version(source_folder=addon_folder)
129
162
 
130
163
  s3_prefix = BLENDER_EXTENSION_SERVER_S3_FOLDER
@@ -139,10 +172,9 @@ def create_release(addon_folder: Path, releases_folder: Path, pro: bool = False)
139
172
  s3_prefix=s3_prefix,
140
173
  )
141
174
 
142
-
143
175
  # Create the new .zip files for the addon's various platforms
144
176
  addon_zip_files = package_extension(
145
- source_folder=addon_folder,
177
+ source_folder=temp_addon_folder,
146
178
  output_folder=releases_folder,
147
179
  blender_version=os.environ['BLENDER_VERSION'],
148
180
  split_platforms=True,
@@ -163,26 +195,6 @@ def create_release(addon_folder: Path, releases_folder: Path, pro: bool = False)
163
195
  platform, arch = parse_blender_extension_zip_info(url=addon_zip_file)
164
196
  files_to_zip = rig_logic_files + core_files
165
197
 
166
- # If pro version, remove the resources/dna folder from the zip before adding bindings
167
- if not pro:
168
- files_removed = []
169
- dna_folder_prefix = 'resources/dna/'
170
- temp_zip_path = Path(str(addon_zip_file) + '.tmp')
171
- with zipfile.ZipFile(addon_zip_file, 'r') as zip_read:
172
- with zipfile.ZipFile(temp_zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zip_write:
173
- for item in zip_read.infolist():
174
- if not item.filename.startswith(dna_folder_prefix):
175
- zip_write.writestr(item, zip_read.read(item.filename))
176
- else:
177
- logger.info(f"Removed {item.filename} from pro version")
178
- files_removed.append(item.filename)
179
-
180
- # Only replace the original zip if we removed files
181
- if files_removed:
182
- temp_zip_path.replace(addon_zip_file)
183
- else:
184
- temp_zip_path.unlink()
185
-
186
198
  # Now add the bindings to the addon .zip
187
199
  with zipfile.ZipFile(addon_zip_file, mode="a", compression=zipfile.ZIP_DEFLATED) as zip_file_handle:
188
200
  for file_path in files_to_zip:
@@ -67,4 +67,39 @@ def package_extension(
67
67
 
68
68
  shell(command, cwd=source_folder)
69
69
 
70
- return list(output_folder.glob(f'{addon_id}-{addon_version}-*.zip'))
70
+ return list(output_folder.glob(f'{addon_id}-{addon_version}-*.zip'))
71
+
72
+
73
+ def rename_addon(
74
+ toml_file_path: Path,
75
+ constants_file_path: Path,
76
+ addon_id: str,
77
+ new_addon_id: str,
78
+ new_addon_name: str,
79
+ ):
80
+ # Update the id and name in the blender_manifest.toml
81
+ if not toml_file_path.exists():
82
+ raise FileNotFoundError(f'Manifest file not found: {toml_file_path}')
83
+
84
+ manifest_data = tomlkit.parse(toml_file_path.read_text())
85
+ manifest_data['id'] = new_addon_id
86
+ manifest_data['name'] = new_addon_name
87
+ toml_file_path.write_text(tomlkit.dumps(manifest_data))
88
+ logger.info(f'Updated manifest: id="{new_addon_id}", name="{new_addon_name}"')
89
+
90
+ # Update ToolInfo.NAME in constants.py
91
+ if not constants_file_path.exists():
92
+ raise FileNotFoundError(f'Constants file not found: {constants_file_path}')
93
+
94
+ constants_text = constants_file_path.read_text()
95
+ updated_text = constants_text.replace(
96
+ f'NAME: str = "{addon_id}"',
97
+ f'NAME: str = "{new_addon_id}"',
98
+ )
99
+ if updated_text == constants_text:
100
+ logger.warning(f'Could not find ToolInfo.NAME with value "{addon_id}" in {constants_file_path}')
101
+ else:
102
+ constants_file_path.write_text(updated_text)
103
+ logger.info(f'Updated ToolInfo.NAME to "{new_addon_id}" in {constants_file_path}')
104
+
105
+
@@ -175,7 +175,7 @@ def trigger_poly_hammer_portal_extension_index_refresh() -> httpx.Response:
175
175
  """Trigger sync of all extensions from S3."""
176
176
  logger.info("Triggering extension sync...")
177
177
 
178
- url = f"{BASE_URL}/api/v1/admin/extensions/sync"
178
+ url = f"{BASE_URL}/v1/admin/extensions/sync"
179
179
  headers = {"X-Admin-API-Key": PORTAL_API_KEY}
180
180
 
181
181
  response = httpx.post(url, headers=headers, timeout=60.0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: poly-hammer-utils
3
- Version: 0.0.28
3
+ Version: 0.0.30
4
4
  Summary:
5
5
  Author: Poly Hammer
6
6
  Author-email: info@polyhammer.com
@@ -2,15 +2,15 @@ poly_hammer_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
2
2
  poly_hammer_utils/addon/packager.py,sha256=apoZhQpd2QeRucFq53u-L1FPmN4MYuiNrjTETAE9NQg,8435
3
3
  poly_hammer_utils/addon/release.py,sha256=EZirS8_c9S1OEZoOHStgciu_C7vMxBc_-O5P1fM9Qu4,9074
4
4
  poly_hammer_utils/constants.py,sha256=4XGiwn7ip50V1zvmpVD9YZYmE6wPhj2Ark2AXQuJvSc,228
5
- poly_hammer_utils/extension/meta_human_dna.py,sha256=fX2QoDTOVReFDusm2LYA0cDIepW3bRPgZyJpPogk4R4,9238
6
- poly_hammer_utils/extension/packager.py,sha256=LyThqLWgvlQOrcn9OSChrV675iiwHTvcMCeXwAab_vM,2365
7
- poly_hammer_utils/extension/server.py,sha256=vuDMqEehgFiFiUy-R28oKzijHo5wIJzW0l66wwPU6I8,8072
5
+ poly_hammer_utils/extension/meta_human_dna.py,sha256=_fAmEqUpAF6SU8qv-SV05A08KyWoV6ywcwInlKqACHo,9179
6
+ poly_hammer_utils/extension/packager.py,sha256=ba2_vEoBKv5WojdcaZTvw-YPTrp3jZUnGa6M1k87dL4,3646
7
+ poly_hammer_utils/extension/server.py,sha256=_sh6_M79eKGAp9nKH9Gu6h84iBbKXWNwrqmbt4enMXk,8068
8
8
  poly_hammer_utils/github/release.py,sha256=P4vrNvdgWuzJI0mRye09BP6vL5b7kQ5fpuDDnEqJbwg,9951
9
9
  poly_hammer_utils/helpers.py,sha256=f_2fNrydsbIvwD2LuoBj2gjETMP7dFzJtq1_7WMBwNI,1655
10
10
  poly_hammer_utils/launch.py,sha256=Nc9FlFuGtMSjgSLsk6MMMj-FECsOGtfUQlZaUZt_rGU,469
11
11
  poly_hammer_utils/resources/scripts/blender/startup.py,sha256=eUd0VwAHjTwIscVKCbk_0-F7p0jgIEsVYdzpIjlzOK0,2282
12
12
  poly_hammer_utils/resources/scripts/unreal/init_unreal.py,sha256=1-d9IU8ZSAIS3MUANrsGx4ZmqNJ5f8S2k8XJVg0Bghs,693
13
13
  poly_hammer_utils/utilities.py,sha256=7dmZo02HXbWhfmwDHkgVUE_gyq4e-gqb4OdBc2bokbs,6491
14
- poly_hammer_utils-0.0.28.dist-info/METADATA,sha256=3fc4GpufAb8P2I45sdbhWFl4htIcMCbGshAEf28w91A,934
15
- poly_hammer_utils-0.0.28.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
16
- poly_hammer_utils-0.0.28.dist-info/RECORD,,
14
+ poly_hammer_utils-0.0.30.dist-info/METADATA,sha256=yMDgbSfpyUPeClA3e_VEDVsLZlyl77xfeIk_lpOYpgw,934
15
+ poly_hammer_utils-0.0.30.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
16
+ poly_hammer_utils-0.0.30.dist-info/RECORD,,