pymss 2.3.0__tar.gz → 2.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.
Files changed (179) hide show
  1. {pymss-2.3.0 → pymss-2.3.2}/PKG-INFO +3 -1
  2. {pymss-2.3.0 → pymss-2.3.2}/README.md +2 -0
  3. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/install.py +31 -1
  4. pymss-2.3.2/pymss/plugins/marketplace.py +111 -0
  5. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/PKG-INFO +3 -1
  6. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/SOURCES.txt +3 -0
  7. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/_engine.py +5 -2
  8. {pymss-2.3.0 → pymss-2.3.2}/pyproject.toml +1 -1
  9. pymss-2.3.2/test/test_plugin_macos_attributes.py +82 -0
  10. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_management.py +70 -0
  11. pymss-2.3.2/test/test_plugin_marketplace.py +114 -0
  12. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_sources.py +11 -0
  13. {pymss-2.3.0 → pymss-2.3.2}/LICENSE +0 -0
  14. {pymss-2.3.0 → pymss-2.3.2}/pymss/__init__.py +0 -0
  15. {pymss-2.3.0 → pymss-2.3.2}/pymss/__main__.py +0 -0
  16. {pymss-2.3.0 → pymss-2.3.2}/pymss/_builtin_node_types.py +0 -0
  17. {pymss-2.3.0 → pymss-2.3.2}/pymss/_identifiers.py +0 -0
  18. {pymss-2.3.0 → pymss-2.3.2}/pymss/audio_io.py +0 -0
  19. {pymss-2.3.0 → pymss-2.3.2}/pymss/audio_services.py +0 -0
  20. {pymss-2.3.0 → pymss-2.3.2}/pymss/cli.py +0 -0
  21. {pymss-2.3.0 → pymss-2.3.2}/pymss/config.py +0 -0
  22. {pymss-2.3.0 → pymss-2.3.2}/pymss/ensemble.py +0 -0
  23. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/__init__.py +0 -0
  24. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/builtin_nodes.py +0 -0
  25. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/comfy_loader.py +0 -0
  26. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/core.py +0 -0
  27. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/nodes.py +0 -0
  28. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/runner.py +0 -0
  29. {pymss-2.3.0 → pymss-2.3.2}/pymss/graph/yaml_compiler.py +0 -0
  30. {pymss-2.3.0 → pymss-2.3.2}/pymss/logger.py +0 -0
  31. {pymss-2.3.0 → pymss-2.3.2}/pymss/model_download.py +0 -0
  32. {pymss-2.3.0 → pymss-2.3.2}/pymss/model_registry.py +0 -0
  33. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/__init__.py +0 -0
  34. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/_core_shims.py +0 -0
  35. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/__init__.py +0 -0
  36. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/common_separator.py +0 -0
  37. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/uvr_lib_v5/__init__.py +0 -0
  38. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/uvr_lib_v5/spec_utils.py +0 -0
  39. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/vr_mlx.py +0 -0
  40. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/vr_models.py +0 -0
  41. {pymss-2.3.0 → pymss-2.3.2}/pymss/modules/vocal_remover/vr_separator.py +0 -0
  42. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/__init__.py +0 -0
  43. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/_command_bootstrap.py +0 -0
  44. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/_command_process.py +0 -0
  45. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/_profile_lock.py +0 -0
  46. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/_python_entry.py +0 -0
  47. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/_rpc_session.py +0 -0
  48. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/builtins.py +0 -0
  49. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/command.py +0 -0
  50. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/files.py +0 -0
  51. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/graph_bridge.py +0 -0
  52. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/host_services.py +0 -0
  53. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/kit_builtins.py +0 -0
  54. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/python_profiles.py +0 -0
  55. {pymss-2.3.0 → pymss-2.3.2}/pymss/operations/rpc_process.py +0 -0
  56. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/__init__.py +0 -0
  57. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/builtins.py +0 -0
  58. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/codecs.py +0 -0
  59. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/graph_ops.py +0 -0
  60. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/kit.py +0 -0
  61. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/lifecycle.py +0 -0
  62. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/loader.py +0 -0
  63. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/manifest.py +0 -0
  64. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/registry.py +0 -0
  65. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/service.py +0 -0
  66. {pymss-2.3.0 → pymss-2.3.2}/pymss/plugins/sources.py +0 -0
  67. {pymss-2.3.0 → pymss-2.3.2}/pymss/progress.py +0 -0
  68. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/model_catalog.json +0 -0
  69. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr16000_hl512.json +0 -0
  70. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr32000_hl512.json +0 -0
  71. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr33075_hl384.json +0 -0
  72. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr44100_hl1024.json +0 -0
  73. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr44100_hl256.json +0 -0
  74. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr44100_hl512.json +0 -0
  75. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr44100_hl512_cut.json +0 -0
  76. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/1band_sr44100_hl512_nf1024.json +0 -0
  77. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/2band_32000.json +0 -0
  78. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/2band_44100_lofi.json +0 -0
  79. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/2band_48000.json +0 -0
  80. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/3band_44100.json +0 -0
  81. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/3band_44100_mid.json +0 -0
  82. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/3band_44100_msb2.json +0 -0
  83. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100.json +0 -0
  84. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100_mid.json +0 -0
  85. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100_msb.json +0 -0
  86. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100_msb2.json +0 -0
  87. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100_reverse.json +0 -0
  88. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_44100_sw.json +0 -0
  89. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_v2.json +0 -0
  90. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_v2_sn.json +0 -0
  91. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_v3.json +0 -0
  92. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_v3_sn.json +0 -0
  93. {pymss-2.3.0 → pymss-2.3.2}/pymss/resources/vr_modelparams/4band_v4_ms_fullband.json +0 -0
  94. {pymss-2.3.0 → pymss-2.3.2}/pymss/separator.py +0 -0
  95. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/__init__.py +0 -0
  96. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/app.py +0 -0
  97. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/audio.py +0 -0
  98. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/config.py +0 -0
  99. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/errors.py +0 -0
  100. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/models.py +0 -0
  101. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/state.py +0 -0
  102. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui.py +0 -0
  103. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/index-C2f3RgYK.js +0 -0
  104. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/index-Dd_kG96D.css +0 -0
  105. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-cyrillic-ext-wght-normal-DSNfmdVt.woff2 +0 -0
  106. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-cyrillic-wght-normal-B2hlT84T.woff2 +0 -0
  107. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-devanagari-wght-normal-Cv-Vwajv.woff2 +0 -0
  108. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-greek-ext-wght-normal-12T8GTDR.woff2 +0 -0
  109. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-greek-wght-normal-Ymb6dZNd.woff2 +0 -0
  110. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-latin-ext-wght-normal-W1qJv59z.woff2 +0 -0
  111. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-latin-wght-normal-BYSzYMf3.woff2 +0 -0
  112. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/assets/noto-sans-vietnamese-wght-normal-DLTJy58D.woff2 +0 -0
  113. {pymss-2.3.0 → pymss-2.3.2}/pymss/server/webui_static/index.html +0 -0
  114. {pymss-2.3.0 → pymss-2.3.2}/pymss/user_models.py +0 -0
  115. {pymss-2.3.0 → pymss-2.3.2}/pymss/utils.py +0 -0
  116. {pymss-2.3.0 → pymss-2.3.2}/pymss/workflow.py +0 -0
  117. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/dependency_links.txt +0 -0
  118. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/entry_points.txt +0 -0
  119. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/requires.txt +0 -0
  120. {pymss-2.3.0 → pymss-2.3.2}/pymss.egg-info/top_level.txt +0 -0
  121. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/LICENSE +0 -0
  122. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/NOTICE +0 -0
  123. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/__init__.py +0 -0
  124. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/cli.py +0 -0
  125. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/context.py +0 -0
  126. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/environment.py +0 -0
  127. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/inventory.py +0 -0
  128. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/leases.py +0 -0
  129. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/locks.py +0 -0
  130. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/profiles.py +0 -0
  131. {pymss-2.3.0 → pymss-2.3.2}/pymss_plugin_manager/service.py +0 -0
  132. {pymss-2.3.0 → pymss-2.3.2}/setup.cfg +0 -0
  133. {pymss-2.3.0 → pymss-2.3.2}/test/test_all.py +0 -0
  134. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_downmix.py +0 -0
  135. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_formats.py +0 -0
  136. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_layout_metadata.py +0 -0
  137. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_materialization.py +0 -0
  138. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_resample.py +0 -0
  139. {pymss-2.3.0 → pymss-2.3.2}/test/test_audio_services.py +0 -0
  140. {pymss-2.3.0 → pymss-2.3.2}/test/test_builtin_capabilities.py +0 -0
  141. {pymss-2.3.0 → pymss-2.3.2}/test/test_builtin_operations.py +0 -0
  142. {pymss-2.3.0 → pymss-2.3.2}/test/test_codec_capabilities.py +0 -0
  143. {pymss-2.3.0 → pymss-2.3.2}/test/test_command_bootstrap.py +0 -0
  144. {pymss-2.3.0 → pymss-2.3.2}/test/test_command_operations.py +0 -0
  145. {pymss-2.3.0 → pymss-2.3.2}/test/test_command_process.py +0 -0
  146. {pymss-2.3.0 → pymss-2.3.2}/test/test_core_shims.py +0 -0
  147. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph.py +0 -0
  148. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_audio_merge.py +0 -0
  149. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_custom_models.py +0 -0
  150. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_execution_events.py +0 -0
  151. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_lifecycle.py +0 -0
  152. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_resample_service.py +0 -0
  153. {pymss-2.3.0 → pymss-2.3.2}/test/test_graph_runner_lifecycle.py +0 -0
  154. {pymss-2.3.0 → pymss-2.3.2}/test/test_kit_builtins.py +0 -0
  155. {pymss-2.3.0 → pymss-2.3.2}/test/test_legacy_loudnorm_node.py +0 -0
  156. {pymss-2.3.0 → pymss-2.3.2}/test/test_mlx_warmup.py +0 -0
  157. {pymss-2.3.0 → pymss-2.3.2}/test/test_model_catalog_overrides.py +0 -0
  158. {pymss-2.3.0 → pymss-2.3.2}/test/test_model_detection.py +0 -0
  159. {pymss-2.3.0 → pymss-2.3.2}/test/test_model_download_progress.py +0 -0
  160. {pymss-2.3.0 → pymss-2.3.2}/test/test_npu_runtime.py +0 -0
  161. {pymss-2.3.0 → pymss-2.3.2}/test/test_operation_graph_bridge.py +0 -0
  162. {pymss-2.3.0 → pymss-2.3.2}/test/test_operation_invocation.py +0 -0
  163. {pymss-2.3.0 → pymss-2.3.2}/test/test_operations.py +0 -0
  164. {pymss-2.3.0 → pymss-2.3.2}/test/test_overlap_finalize.py +0 -0
  165. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_environment.py +0 -0
  166. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_kit.py +0 -0
  167. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_node_contract.py +0 -0
  168. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_protocol.py +0 -0
  169. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugin_protocol_posix.py +0 -0
  170. {pymss-2.3.0 → pymss-2.3.2}/test/test_plugins.py +0 -0
  171. {pymss-2.3.0 → pymss-2.3.2}/test/test_polarformer.py +0 -0
  172. {pymss-2.3.0 → pymss-2.3.2}/test/test_progress.py +0 -0
  173. {pymss-2.3.0 → pymss-2.3.2}/test/test_python_profiles.py +0 -0
  174. {pymss-2.3.0 → pymss-2.3.2}/test/test_rpc_declarations.py +0 -0
  175. {pymss-2.3.0 → pymss-2.3.2}/test/test_rpc_process.py +0 -0
  176. {pymss-2.3.0 → pymss-2.3.2}/test/test_separator_channels.py +0 -0
  177. {pymss-2.3.0 → pymss-2.3.2}/test/test_separator_device_defaults.py +0 -0
  178. {pymss-2.3.0 → pymss-2.3.2}/test/test_use_amp.py +0 -0
  179. {pymss-2.3.0 → pymss-2.3.2}/test/test_workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymss
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: Python package for music source separation.
5
5
  Author-email: KitsuneX07 <ghast1085654218@163.com>
6
6
  Maintainer-email: baicai1145 <3423714059@qq.com>
@@ -254,6 +254,8 @@ See [server CLI docs](./docs/server/cli.md), [server API docs](./docs/server/api
254
254
 
255
255
  ### Plugin system
256
256
 
257
+ The official marketplace supports GitHub and GitCode. By default it compares usable sources and selects the faster synchronized source. Set `PYMSS_PLUGINS_SOURCE` to `github` or `gitcode` to select one explicitly. GitCode acquisition requires Git; without Git, automatic mode uses GitHub. Catalog entries and downloaded packages use the same immutable commit.
258
+
257
259
  pymss has a plugin system for extending capabilities — audio DSP operations, audio codecs, and workflow nodes. Built-in functionality (23 capabilities: 15 DSP/channel ops + 8 codecs) is registered through the same mechanism plugins use, so core and extensions share one pool.
258
260
 
259
261
  **Install a plugin** — use pymss 2.2 or later and specify a full plugin id from the official registry, a repository URL, or a local path. Append `#subdir` to install from a monorepo subdirectory:
@@ -214,6 +214,8 @@ See [server CLI docs](./docs/server/cli.md), [server API docs](./docs/server/api
214
214
 
215
215
  ### Plugin system
216
216
 
217
+ The official marketplace supports GitHub and GitCode. By default it compares usable sources and selects the faster synchronized source. Set `PYMSS_PLUGINS_SOURCE` to `github` or `gitcode` to select one explicitly. GitCode acquisition requires Git; without Git, automatic mode uses GitHub. Catalog entries and downloaded packages use the same immutable commit.
218
+
217
219
  pymss has a plugin system for extending capabilities — audio DSP operations, audio codecs, and workflow nodes. Built-in functionality (23 capabilities: 15 DSP/channel ops + 8 codecs) is registered through the same mechanism plugins use, so core and extensions share one pool.
218
220
 
219
221
  **Install a plugin** — use pymss 2.2 or later and specify a full plugin id from the official registry, a repository URL, or a local path. Append `#subdir` to install from a monorepo subdirectory:
@@ -56,6 +56,21 @@ class InstallError(Exception):
56
56
  """Raised when a plugin install fails."""
57
57
 
58
58
 
59
+ def _clear_macos_attributes(plugin_dir: Path) -> None:
60
+ """Clear attributes on the acquired copy before it can be loaded or published."""
61
+ if sys.platform != "darwin":
62
+ return
63
+ try:
64
+ # -s operates on symlinks themselves so recursive cleanup stays in this copy.
65
+ subprocess.run(
66
+ ["/usr/bin/xattr", "-rc", "-s", str(plugin_dir.absolute())],
67
+ check=True, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30,
68
+ )
69
+ except (OSError, subprocess.SubprocessError) as error:
70
+ detail = (error.stderr or str(error)) if isinstance(error, subprocess.CalledProcessError) else str(error)
71
+ raise InstallError(f"macOS plugin attribute cleanup failed: {detail.strip()}") from error
72
+
73
+
59
74
  @dataclass
60
75
  class InstallResult:
61
76
  name: str
@@ -70,13 +85,27 @@ def _is_url(arg: str) -> bool:
70
85
 
71
86
 
72
87
  def _git_available() -> bool:
73
- return shutil.which("git") is not None
88
+ executable = shutil.which("git")
89
+ if executable is None:
90
+ return False
91
+ if sys.platform == "darwin" and Path(executable).resolve() == Path("/usr/bin/git").resolve():
92
+ # macOS ships a Git shim even without developer tools. Query their
93
+ # availability without invoking the shim's interactive installer.
94
+ try:
95
+ return subprocess.run(["xcode-select", "-p"], stdout=subprocess.DEVNULL,
96
+ stderr=subprocess.DEVNULL, timeout=3).returncode == 0
97
+ except (OSError, subprocess.SubprocessError):
98
+ return False
99
+ return True
74
100
 
75
101
 
76
102
  def _fetch_registry(registry_url: str | None = None) -> dict[str, str]:
77
103
  """Fetch and parse the registry JSON. Raises InstallError on failure."""
78
104
  url = _registry_url(registry_url)
79
105
  try:
106
+ from .marketplace import fetch_official_catalog, is_official_registry
107
+ if is_official_registry(url):
108
+ return fetch_official_catalog(url)
80
109
  req = urllib.request.Request(url, headers={"User-Agent": "pymss"})
81
110
  with urllib.request.urlopen(req, timeout=15) as resp: # noqa: S310
82
111
  data = json.loads(resp.read().decode("utf-8"))
@@ -385,6 +414,7 @@ def install(
385
414
  _write_install_manifest(staged, name=name, source=source, url=url,
386
415
  subpath=subpath, ref=ref, meta=meta, registry_url=resolved_registry_url,
387
416
  resolved_commit=source_meta.get("resolved_commit"))
417
+ _clear_macos_attributes(staged)
388
418
  staged.rename(dest)
389
419
  return InstallResult(name=name, path=dest, source=source,
390
420
  version=meta.get("version"), dependencies_installed=installed_deps)
@@ -0,0 +1,111 @@
1
+ """Select an available official catalog and pin its packages to that snapshot."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from concurrent.futures import ThreadPoolExecutor, as_completed
6
+ from contextvars import ContextVar
7
+ from http.client import HTTPException
8
+ import json
9
+ import os
10
+ import re
11
+ import time
12
+ import urllib.parse
13
+ import urllib.request
14
+
15
+ from .sources import SourceError
16
+
17
+
18
+ GITHUB_REPOSITORY = "https://github.com/pymss-project/pymss-plugins"
19
+ GITCODE_REPOSITORY = "https://gitcode.com/pymss-project/pymss-plugins"
20
+ GITHUB_REGISTRY = "https://raw.githubusercontent.com/pymss-project/pymss-plugins/main/registry.json"
21
+ GITCODE_REGISTRY = "https://api.gitcode.com/api/v5/repos/pymss-project/pymss-plugins/raw/registry.json?ref=main"
22
+ _MAX_METADATA_BYTES = 1024 * 1024
23
+ _SOURCE: ContextVar[dict | None] = ContextVar("pymss_official_plugin_source", default=None)
24
+
25
+
26
+ def source_info() -> dict | None:
27
+ value = _SOURCE.get()
28
+ return dict(value) if value else None
29
+
30
+
31
+ def is_official_registry(url: str) -> bool:
32
+ return url in {GITHUB_REGISTRY, GITCODE_REGISTRY}
33
+
34
+
35
+ def _json(url: str) -> object:
36
+ request = urllib.request.Request(url, headers={"User-Agent": "pymss", "Accept": "application/json"})
37
+ with urllib.request.urlopen(request, timeout=3) as response:
38
+ resolved = urllib.parse.urlsplit(response.url)
39
+ if resolved.scheme != "https" or resolved.hostname not in {
40
+ "api.github.com", "raw.githubusercontent.com", "api.gitcode.com",
41
+ }:
42
+ raise SourceError("Official plugin catalog redirected outside its source hosts")
43
+ content = response.read(_MAX_METADATA_BYTES + 1)
44
+ if len(content) > _MAX_METADATA_BYTES:
45
+ raise SourceError("Official plugin catalog metadata exceeds its size limit")
46
+ return json.loads(content)
47
+
48
+
49
+ def _probe(provider: str) -> tuple[dict, dict]:
50
+ started = time.monotonic()
51
+ api = "https://api.github.com/repos" if provider == "github" else "https://api.gitcode.com/api/v5/repos"
52
+ revision = _json(f"{api}/pymss-project/pymss-plugins/commits/main")
53
+ commit = revision.get("sha") if isinstance(revision, dict) else None
54
+ if not isinstance(commit, str) or not re.fullmatch(r"[0-9a-f]{40}", commit):
55
+ raise SourceError("Official plugin source did not return a full commit ID")
56
+ if provider == "github":
57
+ registry = f"https://raw.githubusercontent.com/pymss-project/pymss-plugins/{commit}/registry.json"
58
+ repository = GITHUB_REPOSITORY
59
+ else:
60
+ registry = GITCODE_REGISTRY.removesuffix("main") + commit
61
+ repository = GITCODE_REPOSITORY
62
+ catalog = _json(registry)
63
+ if not isinstance(catalog, dict) or not any(not key.startswith("_") for key in catalog):
64
+ raise SourceError("Official plugin catalog is empty or invalid")
65
+ snapshot = {}
66
+ for name, entry in catalog.items():
67
+ if name.startswith("_"):
68
+ snapshot[name] = entry
69
+ continue
70
+ if not isinstance(entry, dict) or not isinstance(entry.get("url"), str):
71
+ raise SourceError(f"Invalid official plugin catalog entry: {name}")
72
+ entry = dict(entry)
73
+ if entry["url"].rstrip("/").removesuffix(".git") in {GITHUB_REPOSITORY, GITCODE_REPOSITORY}:
74
+ entry.update(url=repository, ref=commit)
75
+ snapshot[name] = entry
76
+ return snapshot, {"provider": provider, "repositoryUrl": repository, "commit": commit,
77
+ "latencyMs": round((time.monotonic() - started) * 1000)}
78
+
79
+
80
+ def fetch_official_catalog(url: str) -> dict:
81
+ """Resolve an explicit provider, or compare usable providers for automatic mode."""
82
+ _SOURCE.set(None)
83
+ if not is_official_registry(url):
84
+ raise SourceError("Unsupported official plugin registry URL")
85
+ preference = "gitcode" if url == GITCODE_REGISTRY else os.environ.get("PYMSS_PLUGINS_SOURCE", "auto")
86
+ if preference not in {"auto", "github", "gitcode"}:
87
+ raise SourceError("Plugin source must be auto, github, or gitcode")
88
+ from .install import _git_available
89
+ git_available = _git_available()
90
+ if preference == "gitcode" and not git_available:
91
+ raise SourceError("GitCode plugin acquisition requires Git. Install Git or select GitHub.")
92
+ providers = (["github", "gitcode"] if git_available else ["github"]) if preference == "auto" else [preference]
93
+ results, errors = {}, []
94
+ with ThreadPoolExecutor(max_workers=len(providers)) as pool:
95
+ requests = {pool.submit(_probe, provider): provider for provider in providers}
96
+ for request in as_completed(requests):
97
+ provider = requests[request]
98
+ try:
99
+ results[provider] = request.result()
100
+ except (SourceError, OSError, ValueError, HTTPException) as error:
101
+ errors.append(f"{provider}: {error}")
102
+ if not results:
103
+ raise SourceError("Official plugin sources are unavailable: " + "; ".join(sorted(errors)))
104
+ # A reachable canonical source takes precedence over a mirror that has not
105
+ # synchronized that revision, even when the older mirror responds faster.
106
+ if len(results) == 2 and results["github"][1]["commit"] != results["gitcode"][1]["commit"]:
107
+ catalog, info = results["github"]
108
+ else:
109
+ catalog, info = min(results.values(), key=lambda result: (result[1]["latencyMs"], result[1]["provider"]))
110
+ _SOURCE.set({**info, "preference": preference, "gitAvailable": git_available})
111
+ return catalog
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymss
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: Python package for music source separation.
5
5
  Author-email: KitsuneX07 <ghast1085654218@163.com>
6
6
  Maintainer-email: baicai1145 <3423714059@qq.com>
@@ -254,6 +254,8 @@ See [server CLI docs](./docs/server/cli.md), [server API docs](./docs/server/api
254
254
 
255
255
  ### Plugin system
256
256
 
257
+ The official marketplace supports GitHub and GitCode. By default it compares usable sources and selects the faster synchronized source. Set `PYMSS_PLUGINS_SOURCE` to `github` or `gitcode` to select one explicitly. GitCode acquisition requires Git; without Git, automatic mode uses GitHub. Catalog entries and downloaded packages use the same immutable commit.
258
+
257
259
  pymss has a plugin system for extending capabilities — audio DSP operations, audio codecs, and workflow nodes. Built-in functionality (23 capabilities: 15 DSP/channel ops + 8 codecs) is registered through the same mechanism plugins use, so core and extensions share one pool.
258
260
 
259
261
  **Install a plugin** — use pymss 2.2 or later and specify a full plugin id from the official registry, a repository URL, or a local path. Append `#subdir` to install from a monorepo subdirectory:
@@ -63,6 +63,7 @@ pymss/plugins/kit.py
63
63
  pymss/plugins/lifecycle.py
64
64
  pymss/plugins/loader.py
65
65
  pymss/plugins/manifest.py
66
+ pymss/plugins/marketplace.py
66
67
  pymss/plugins/registry.py
67
68
  pymss/plugins/service.py
68
69
  pymss/plugins/sources.py
@@ -157,7 +158,9 @@ test/test_operations.py
157
158
  test/test_overlap_finalize.py
158
159
  test/test_plugin_environment.py
159
160
  test/test_plugin_kit.py
161
+ test/test_plugin_macos_attributes.py
160
162
  test/test_plugin_management.py
163
+ test/test_plugin_marketplace.py
161
164
  test/test_plugin_node_contract.py
162
165
  test/test_plugin_protocol.py
163
166
  test/test_plugin_protocol_posix.py
@@ -828,7 +828,7 @@ def _verify_candidate(root: Path, candidate: Path, name: str, *, candidate_depen
828
828
 
829
829
  def _acquire_source(target: str, directory: Path, subpath: str | None = None):
830
830
  from datetime import datetime, timezone
831
- from pymss.plugins.install import InstallResult, install, list_available
831
+ from pymss.plugins.install import InstallResult, install, list_available, _clear_macos_attributes
832
832
 
833
833
  local_root = _LOCAL_SOURCE.get()
834
834
  from_default = bool(local_root and _NAME.fullmatch(target))
@@ -888,6 +888,7 @@ def _acquire_source(target: str, directory: Path, subpath: str | None = None):
888
888
  "defaultRepository": from_default,
889
889
  **({"sourceContext": {"registryUrl": _REGISTRY_URL.get(), "localSource": str(local_root)}} if from_default else {}),
890
890
  }), encoding="utf-8")
891
+ _clear_macos_attributes(destination)
891
892
  return InstallResult(name=name, path=destination, source="path", version=version)
892
893
 
893
894
 
@@ -1100,7 +1101,9 @@ def _check_updates(root: Path, task_id: str | None, *, names: set[str] | None=No
1100
1101
  elif catalog_version is not None:
1101
1102
  from pymss.plugins.sources import github_repository, resolve_github_commit
1102
1103
  remote_commit = None
1103
- if github_repository(meta['url']):
1104
+ if catalog_ref and re.fullmatch(r"[0-9a-f]{40,64}", catalog_ref):
1105
+ remote_commit = catalog_ref
1106
+ elif github_repository(meta['url']):
1104
1107
  key = (meta['url'], catalog_ref)
1105
1108
  if key not in commit_cache:
1106
1109
  commit_cache[key] = resolve_github_commit(*key)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pymss"
7
- version = "2.3.0"
7
+ version = "2.3.2"
8
8
  description = "Python package for music source separation."
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.11"
@@ -0,0 +1,82 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib
4
+ from pathlib import Path
5
+ import shutil
6
+ import subprocess
7
+ from types import SimpleNamespace
8
+ from unittest.mock import Mock
9
+
10
+ import pytest
11
+
12
+ install_mod = importlib.import_module("pymss.plugins.install")
13
+
14
+
15
+ def package(tmp_path):
16
+ source = tmp_path / "source"
17
+ source.mkdir()
18
+ (source / "pyproject.toml").write_text(
19
+ '[project]\nname="provider"\nversion="1.0"\n'
20
+ '[tool.pymss.plugin]\nid="author.provider"\napi_version=2\n', encoding="utf-8")
21
+ (source / "__init__.py").write_text("def setup(plugin): pass\n", encoding="utf-8")
22
+ return source
23
+
24
+
25
+ @pytest.mark.parametrize("remote", [False, True])
26
+ def test_macos_install_clears_only_the_staged_plugin_before_publication(tmp_path, monkeypatch, remote):
27
+ source = package(tmp_path)
28
+ store = tmp_path / "installed"
29
+ calls = []
30
+
31
+ def run(command, **options):
32
+ staged = Path(command[-1])
33
+ assert staged.is_relative_to(store)
34
+ assert staged != source
35
+ assert (staged / "pyproject.toml").is_file()
36
+ assert not (store / "author.provider").exists()
37
+ calls.append((command, options))
38
+ return subprocess.CompletedProcess(command, 0, "", "")
39
+
40
+ def clone(url, destination, **options):
41
+ shutil.copytree(source, destination)
42
+ return {"resolved_commit": "a" * 40}
43
+
44
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform="darwin"))
45
+ monkeypatch.setattr(install_mod.subprocess, "run", run)
46
+ monkeypatch.setattr(install_mod, "_clone", clone)
47
+ result = install_mod.install("https://github.com/author/plugin" if remote else str(source),
48
+ plugins_dir=store, no_deps=True)
49
+ assert result.path == store / "author.provider"
50
+ assert len(calls) == 1
51
+ command, options = calls[0]
52
+ assert command[:3] == ["/usr/bin/xattr", "-rc", "-s"]
53
+ assert options["check"] is True
54
+ assert options["timeout"] == 30
55
+ assert (source / "__init__.py").read_text() == "def setup(plugin): pass\n"
56
+
57
+
58
+ @pytest.mark.parametrize("platform", ["win32", "linux"])
59
+ def test_other_platforms_do_not_run_xattr(tmp_path, monkeypatch, platform):
60
+ source = package(tmp_path)
61
+ run = Mock(side_effect=AssertionError("Unexpected native command"))
62
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform=platform))
63
+ monkeypatch.setattr(install_mod.subprocess, "run", run)
64
+ result = install_mod.install(str(source), plugins_dir=tmp_path / "installed", no_deps=True)
65
+ assert result.path.is_dir()
66
+ run.assert_not_called()
67
+
68
+
69
+ @pytest.mark.parametrize("error", [
70
+ subprocess.CalledProcessError(1, "xattr", stderr="Operation not permitted"),
71
+ subprocess.TimeoutExpired("xattr", 30),
72
+ FileNotFoundError("xattr unavailable"),
73
+ ])
74
+ def test_cleanup_failure_aborts_before_publishing_the_plugin(tmp_path, monkeypatch, error):
75
+ source = package(tmp_path)
76
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform="darwin"))
77
+ monkeypatch.setattr(install_mod.subprocess, "run", Mock(side_effect=error))
78
+ store = tmp_path / "installed"
79
+ with pytest.raises(install_mod.InstallError, match="macOS plugin attribute cleanup failed"):
80
+ install_mod.install(str(source), plugins_dir=store, no_deps=True)
81
+ assert not (store / "author.provider").exists()
82
+ assert (source / "pyproject.toml").is_file()
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import importlib
3
4
  import json
4
5
  import os
5
6
  from concurrent.futures import ThreadPoolExecutor
@@ -45,6 +46,55 @@ def release_leases():
45
46
  release_runtime()
46
47
 
47
48
 
49
+ def test_macos_management_cleans_each_acquired_copy_before_verification(tmp_path, monkeypatch):
50
+ install_mod = importlib.import_module("pymss.plugins.install")
51
+ events = []
52
+ package = source(tmp_path)
53
+
54
+ def cleanup(command, **options):
55
+ assert command[:3] == ["/usr/bin/xattr", "-rc", "-s"]
56
+ candidate = Path(command[-1])
57
+ assert candidate.is_relative_to(tmp_path / "plugins")
58
+ assert candidate != package
59
+ events.append("cleanup")
60
+ return subprocess.CompletedProcess(command, 0, "", "")
61
+
62
+ def probe(root, paths):
63
+ events.append("probe")
64
+ return [{"name": path.name, "managed": True, "loaded": True} for path in (root / "installed").iterdir()]
65
+
66
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform="darwin"))
67
+ monkeypatch.setattr(install_mod.subprocess, "run", cleanup)
68
+ cpu = PluginService(PluginContext(tmp_path / "plugins/cpu"), PluginPolicy(probe=probe))
69
+ cuda = PluginService(PluginContext(tmp_path / "plugins/cuda"), PluginPolicy(probe=probe))
70
+ actions = [lambda: cpu.install(str(package)), lambda: cpu.update("author.provider"),
71
+ lambda: cpu.manage("repair", name="author.provider"), lambda: cuda.prepare("author.provider")]
72
+ for action in actions:
73
+ events.clear()
74
+ action()
75
+ assert events[0] == "cleanup"
76
+ assert events.count("cleanup") == 1
77
+ assert "probe" in events
78
+
79
+
80
+ def test_failed_macos_cleanup_keeps_the_installed_binding_and_skips_verification(tmp_path, monkeypatch):
81
+ install_mod = importlib.import_module("pymss.plugins.install")
82
+ manager = service(tmp_path / "plugins/cpu")
83
+ package = source(tmp_path)
84
+ manager.install(str(package))
85
+ installed = manager.context.root / "installed/author.provider"
86
+ before = {p.relative_to(installed): p.read_bytes() for p in installed.rglob("*") if p.is_file()}
87
+ probe = mock.Mock(side_effect=AssertionError("The candidate must not be loaded"))
88
+ manager.policy.probe = probe
89
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform="darwin"))
90
+ monkeypatch.setattr(install_mod.subprocess, "run", mock.Mock(side_effect=
91
+ subprocess.CalledProcessError(1, "xattr", stderr="Operation not permitted")))
92
+ with pytest.raises(install_mod.InstallError, match="Operation not permitted"):
93
+ manager.update("author.provider")
94
+ assert {p.relative_to(installed): p.read_bytes() for p in installed.rglob("*") if p.is_file()} == before
95
+ probe.assert_not_called()
96
+
97
+
48
98
  def test_inventory_api_import_and_query_do_not_initialize_the_core(tmp_path):
49
99
  repository = Path(__file__).resolve().parents[1]
50
100
  code = (
@@ -410,6 +460,26 @@ def test_catalog_ref_without_a_version_is_used_for_update_checks(tmp_path, ref):
410
460
  fetch.assert_not_called()
411
461
 
412
462
 
463
+ @pytest.mark.parametrize("host", ["github.com", "gitcode.com"])
464
+ @pytest.mark.parametrize("remote_commit", ["a" * 40, "b" * 40])
465
+ def test_immutable_catalog_commits_detect_same_version_updates_on_both_hosts(tmp_path, host, remote_commit):
466
+ manager = PluginService(PluginContext(tmp_path / "plugins/cpu", registry_url="https://example.invalid/registry.json"),
467
+ service(tmp_path / "unused").policy)
468
+ manager.install(str(source(tmp_path)))
469
+ receipt = manager.context.root / "installed/author.provider/.pymss-install.json"
470
+ metadata = json.loads(receipt.read_text(encoding="utf-8"))
471
+ url = f"https://{host}/pymss-project/pymss-plugins"
472
+ metadata.update(defaultRepository=True, url=url, resolved_commit="a" * 40)
473
+ receipt.write_text(json.dumps(metadata), encoding="utf-8")
474
+ entry = {"name": "author.provider", "url": url, "version": "1.0", "ref": remote_commit}
475
+ with mock.patch("pymss.plugins.install.list_available", return_value=[entry]), \
476
+ mock.patch("pymss.plugins.sources.resolve_github_commit", side_effect=AssertionError("Already pinned")):
477
+ result = manager.check_updates()["author.provider"]
478
+ assert result["remote_commit"] == remote_commit
479
+ assert result["up_to_date"] == (remote_commit == "a" * 40)
480
+ assert result["content_changed"] == (remote_commit != "a" * 40)
481
+
482
+
413
483
  def test_cli_check_updates_renders_statuses_and_errors(tmp_path, capsys):
414
484
  from pymss_plugin_manager.cli import run
415
485
 
@@ -0,0 +1,114 @@
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ from http.client import HTTPException
5
+ from unittest import mock
6
+
7
+ import pytest
8
+
9
+ from pymss.plugins import marketplace
10
+ from pymss.plugins import install as install_mod
11
+ from pymss.plugins.sources import SourceError
12
+
13
+
14
+ COMMIT = "a" * 40
15
+
16
+
17
+ @pytest.fixture(autouse=True)
18
+ def clear_source(monkeypatch):
19
+ monkeypatch.delenv("PYMSS_PLUGINS_SOURCE", raising=False)
20
+ monkeypatch.setattr(install_mod, "_git_available", lambda: True)
21
+ marketplace._SOURCE.set(None)
22
+
23
+
24
+ def result(provider, latency=10, commit=COMMIT):
25
+ return {"pymss.example": {}}, {"provider": provider, "commit": commit, "latencyMs": latency}
26
+
27
+
28
+ def test_auto_selects_the_fastest_usable_source(monkeypatch):
29
+ monkeypatch.setattr(marketplace, "_probe", lambda provider: result(provider, 20 if provider == "github" else 5))
30
+ marketplace.fetch_official_catalog(marketplace.GITHUB_REGISTRY)
31
+ assert marketplace.source_info()["provider"] == "gitcode"
32
+
33
+
34
+ def test_auto_rejects_an_outdated_mirror_even_when_it_is_faster(monkeypatch):
35
+ monkeypatch.setattr(marketplace, "_probe", lambda provider: result(provider, 20 if provider == "github" else 5,
36
+ COMMIT if provider == "github" else "b" * 40))
37
+ marketplace.fetch_official_catalog(marketplace.GITHUB_REGISTRY)
38
+ assert marketplace.source_info()["provider"] == "github"
39
+
40
+
41
+ @pytest.mark.parametrize("error", [OSError("unavailable"), ValueError("invalid JSON"), HTTPException("incomplete response")])
42
+ def test_auto_uses_the_other_source_when_a_catalog_fails(monkeypatch, error):
43
+ def probe(provider):
44
+ if provider == "github":
45
+ raise error
46
+ return result(provider)
47
+ monkeypatch.setattr(marketplace, "_probe", probe)
48
+ marketplace.fetch_official_catalog(marketplace.GITHUB_REGISTRY)
49
+ assert marketplace.source_info()["provider"] == "gitcode"
50
+
51
+
52
+ def test_explicit_source_does_not_silently_fall_back(monkeypatch):
53
+ monkeypatch.setenv("PYMSS_PLUGINS_SOURCE", "github")
54
+ probe = mock.Mock(side_effect=OSError("network unavailable"))
55
+ monkeypatch.setattr(marketplace, "_probe", probe)
56
+ with pytest.raises(SourceError, match="network unavailable"):
57
+ marketplace.fetch_official_catalog(marketplace.GITHUB_REGISTRY)
58
+ probe.assert_called_once_with("github")
59
+ assert marketplace.source_info() is None
60
+
61
+
62
+ def test_gitcode_is_not_selected_without_git(monkeypatch):
63
+ monkeypatch.setattr(install_mod, "_git_available", lambda: False)
64
+ probe = mock.Mock(side_effect=lambda provider: result(provider))
65
+ monkeypatch.setattr(marketplace, "_probe", probe)
66
+ marketplace.fetch_official_catalog(marketplace.GITHUB_REGISTRY)
67
+ probe.assert_called_once_with("github")
68
+ assert not marketplace.source_info()["gitAvailable"]
69
+ with pytest.raises(SourceError, match="requires Git"):
70
+ marketplace.fetch_official_catalog(marketplace.GITCODE_REGISTRY)
71
+
72
+
73
+ @pytest.mark.parametrize("provider", ["github", "gitcode"])
74
+ def test_catalog_and_package_ref_share_the_same_commit(monkeypatch, provider):
75
+ catalog = {
76
+ "_comment": "official catalog",
77
+ "pymss.example": {"url": marketplace.GITHUB_REPOSITORY, "ref": "main", "version": "1.0"},
78
+ "external.plugin": {"url": "https://example.com/plugins", "ref": "stable"},
79
+ }
80
+ requests = []
81
+ def read(url):
82
+ requests.append(url)
83
+ return {"sha": COMMIT} if "/commits/" in url else catalog
84
+ monkeypatch.setattr(marketplace, "_json", read)
85
+ snapshot, info = marketplace._probe(provider)
86
+ assert COMMIT in requests[1]
87
+ assert snapshot["pymss.example"]["ref"] == info["commit"] == COMMIT
88
+ expected = marketplace.GITHUB_REPOSITORY if provider == "github" else marketplace.GITCODE_REPOSITORY
89
+ assert snapshot["pymss.example"]["url"] == expected
90
+ assert snapshot["external.plugin"] == catalog["external.plugin"]
91
+ assert catalog["pymss.example"]["ref"] == "main"
92
+
93
+
94
+ @pytest.mark.parametrize("revision,catalog", [
95
+ ({"sha": "main"}, {}), ({"sha": COMMIT}, []),
96
+ ({"sha": COMMIT}, {"_comment": "empty"}), ({"sha": COMMIT}, {"bad": {}}),
97
+ ])
98
+ def test_invalid_source_metadata_is_rejected(monkeypatch, revision, catalog):
99
+ monkeypatch.setattr(marketplace, "_json", lambda url: revision if "/commits/" in url else catalog)
100
+ with pytest.raises(SourceError):
101
+ marketplace._probe("gitcode")
102
+
103
+
104
+ @pytest.mark.parametrize("body,url", [
105
+ (b"<html>not a catalog</html>", marketplace.GITHUB_REGISTRY),
106
+ (b"x" * (marketplace._MAX_METADATA_BYTES + 1), marketplace.GITHUB_REGISTRY),
107
+ (b"{}", "https://untrusted.example/catalog.json"),
108
+ ], ids=["html", "oversized", "redirect"])
109
+ def test_source_probe_rejects_html_oversized_data_and_untrusted_redirects(monkeypatch, body, url):
110
+ response = io.BytesIO(body)
111
+ response.url = url
112
+ monkeypatch.setattr(marketplace.urllib.request, "urlopen", lambda *args, **kwargs: response)
113
+ with pytest.raises((SourceError, ValueError)):
114
+ marketplace._json(marketplace.GITHUB_REGISTRY)
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import io
6
6
  import json
7
7
  from pathlib import Path
8
+ from types import SimpleNamespace
8
9
  import stat
9
10
  from unittest.mock import Mock
10
11
  import zipfile
@@ -26,6 +27,16 @@ api_version = 2
26
27
  '''
27
28
 
28
29
 
30
+ @pytest.mark.parametrize("available", [False, True])
31
+ def test_macos_git_shim_requires_developer_tools_without_running_the_installer(monkeypatch, available):
32
+ monkeypatch.setattr(install_mod, "sys", SimpleNamespace(platform="darwin"))
33
+ monkeypatch.setattr(install_mod.shutil, "which", lambda name: "/usr/bin/git")
34
+ probe = Mock(return_value=SimpleNamespace(returncode=0 if available else 1))
35
+ monkeypatch.setattr(install_mod.subprocess, "run", probe)
36
+ assert install_mod._git_available() is available
37
+ assert probe.call_args.args[0] == ["xcode-select", "-p"]
38
+
39
+
29
40
  @pytest.mark.parametrize("ref", ["--upload-pack=untrusted", "", 123])
30
41
  def test_git_source_rejects_unsafe_refs_before_running_git(tmp_path, monkeypatch, ref):
31
42
  run = Mock(side_effect=AssertionError("Unexpected Git execution"))
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
File without changes
File without changes
File without changes
File without changes
File without changes