@@ -66,6 +66,8 @@ def __init__(self, data={}, debug=False, shallow=False):
66
66
self ._get_source (shallow = shallow )
67
67
self ._get_version ()
68
68
69
+ self ._patch_source ()
70
+
69
71
self .data = {'version' : self .version }
70
72
self .data .update (data )
71
73
@@ -77,7 +79,7 @@ def _get_source(self, shallow=False):
77
79
78
80
if self .source == HERE .parent :
79
81
self ._bld_src = self .source
80
- repo = Repo (self .source )
82
+ self . repo = Repo (self .source )
81
83
else :
82
84
# Determine source and commit
83
85
if self .source is not None :
@@ -97,10 +99,8 @@ def _get_source(self, shallow=False):
97
99
f"Cloning source shallow from tag { self .shallow_ver } ..." )
98
100
else :
99
101
self .logger .info ("Cloning source..." )
100
- repo = Repo .clone_from (remote , ** kwargs )
101
- repo .git .checkout (commit )
102
-
103
- self ._patch_source (repo )
102
+ self .repo = Repo .clone_from (remote , ** kwargs )
103
+ self .repo .git .checkout (commit )
104
104
105
105
# Clone feedstock
106
106
self .logger .info ("Cloning feedstock..." )
@@ -117,7 +117,7 @@ def _get_version(self):
117
117
"""Get source version using setuptools_scm"""
118
118
self .version = get_version (self ._bld_src ).split ('+' )[0 ]
119
119
120
- def _patch_source (self , repo ):
120
+ def _patch_source (self ):
121
121
pass
122
122
123
123
def _patch_meta (self , meta ):
@@ -127,7 +127,12 @@ def _patch_build_script(self):
127
127
pass
128
128
129
129
def patch_recipe (self ):
130
- """Patch conda build recipe"""
130
+ """
131
+ Patch conda build recipe
132
+
133
+ 1. Patch meta.yaml
134
+ 2. Patch build script
135
+ """
131
136
if self ._recipe_patched :
132
137
return
133
138
@@ -161,9 +166,8 @@ def build(self):
161
166
Build the conda package.
162
167
163
168
1. Patch the recipe
164
- 2. Patch the build script
165
- 3. Build the package
166
- 4. Remove cloned repositories
169
+ 2. Build the package
170
+ 3. Remove cloned repositories
167
171
"""
168
172
t0 = time ()
169
173
try :
@@ -193,16 +197,27 @@ class SpyderCondaPkg(BuildCondaPkg):
193
197
feedstock = "https://github.com/conda-forge/spyder-feedstock"
194
198
shallow_ver = "v5.3.2"
195
199
196
- def _patch_source (self , repo ):
200
+ def _patch_source (self ):
197
201
self .logger .info ("Creating Spyder source patch..." )
198
202
199
- patch = repo .git .format_patch ("..origin/installers-conda-patch" ,
200
- "--stdout" )
203
+ patch = self .repo .git .format_patch (
204
+ "..origin/installers-conda-patch" , "--stdout" , "-U3"
205
+ )
201
206
# newline keyword is not added to pathlib until Python>=3.10,
202
207
# so we must use open to ensure LF on Windows
203
208
with open (SPYPATCHFILE , 'w' , newline = '\n ' ) as f :
204
209
f .write (patch )
205
210
211
+ self .logger .info ("Creating Spyder menu file..." )
212
+ _menufile = RESOURCES / "spyder-menu.json"
213
+ menufile = DIST / "spyder-menu.json"
214
+ commit , branch = self .repo .head .commit .name_rev .split ()
215
+ text = _menufile .read_text ()
216
+ text = text .replace ("__PKG_VERSION__" , self .version )
217
+ text = text .replace ("__SPY_BRANCH__" , branch )
218
+ text = text .replace ("__SPY_COMMIT__" , commit [:8 ])
219
+ menufile .write_text (text )
220
+
206
221
def _patch_meta (self , meta ):
207
222
# Add source code patch
208
223
search_patches = re .compile (
@@ -265,18 +280,30 @@ def _patch_build_script(self):
265
280
266
281
if os .name == 'posix' :
267
282
file = self ._fdstk_path / "recipe" / "build.sh"
268
- build_patch = RESOURCES / "build-patch.sh"
269
283
text = file .read_text ()
270
- text += build_patch .read_text ()
284
+ text += dedent (
285
+ """
286
+ # Create the Menu directory
287
+ mkdir -p "${PREFIX}/Menu"
288
+
289
+ # Copy menu.json template
290
+ cp "${SRC_DIR}/installers-conda/dist/spyder-menu.json" "${PREFIX}/Menu/spyder-menu.json"
291
+
292
+ # Copy application icons
293
+ if [[ $OSTYPE == "darwin"* ]]; then
294
+ cp "${SRC_DIR}/img_src/spyder.icns" "${PREFIX}/Menu/spyder.icns"
295
+ else
296
+ cp "${SRC_DIR}/branding/logo/logomark/spyder-logomark-background.png" "${PREFIX}/Menu/spyder.png"
297
+ fi
298
+ """
299
+ )
300
+
271
301
if os .name == 'nt' :
272
302
file = self ._fdstk_path / "recipe" / "bld.bat"
273
303
text = file .read_text ()
274
304
text = text .replace (
275
305
r"copy %RECIPE_DIR%\menu-windows.json %MENU_DIR%\spyder_shortcut.json" ,
276
- r"""powershell -Command"""
277
- r""" "(gc %SRC_DIR%\installers-conda\resources\spyder-menu.json)"""
278
- r""" -replace '__PKG_VERSION__', '%PKG_VERSION%' | """
279
- r"""Out-File -encoding ASCII %MENU_DIR%\spyder-menu.json" """
306
+ r"copy %SRC_DIR%\installers-conda\dist\spyder-menu.json %MENU_DIR%\spyder-menu.json"
280
307
)
281
308
file .rename (file .parent / ("_" + file .name )) # keep copy of original
282
309
file .write_text (text )
0 commit comments