@@ -66,9 +66,9 @@ def add_file(bundle, src_file, zip_name):
66
66
print (zip_name , file_size , file_sector_size )
67
67
return file_sector_size
68
68
69
- def get_module_name (library_path ):
69
+ def get_module_name (library_path , remote_name ):
70
70
"""Figure out the module or package name and return it"""
71
- repo = subprocess .run ('git remote get-url origin ' , shell = True , stdout = subprocess .PIPE , cwd = library_path )
71
+ repo = subprocess .run (f 'git remote get-url { remote_name } ' , shell = True , stdout = subprocess .PIPE , cwd = library_path )
72
72
repo = repo .stdout .decode ("utf-8" , errors = "ignore" ).strip ().lower ()
73
73
if repo [- 4 :] == ".git" :
74
74
repo = repo [:- 4 ]
@@ -110,15 +110,15 @@ def get_bundle_requirements(directory, package_list):
110
110
pypi_reqs .add (original_name )
111
111
return sorted (dependencies ), sorted (pypi_reqs )
112
112
113
- def build_bundle_json (libs , bundle_version , output_filename , package_folder_prefix ):
113
+ def build_bundle_json (libs , bundle_version , output_filename , package_folder_prefix , remote_name = "origin" ):
114
114
"""
115
115
Generate a JSON file of all the libraries in libs
116
116
"""
117
117
packages = {}
118
118
for library_path in libs :
119
119
package = {}
120
120
package_info = build .get_package_info (library_path , package_folder_prefix )
121
- module_name , repo = get_module_name (library_path )
121
+ module_name , repo = get_module_name (library_path , remote_name )
122
122
if package_info ["module_name" ] is not None :
123
123
package ["module_name" ] = package_info ["module_name" ]
124
124
package ["pypi_name" ] = module_name
@@ -144,7 +144,7 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref
144
144
out_file .close ()
145
145
146
146
def build_bundle (libs , bundle_version , output_filename , package_folder_prefix ,
147
- build_tools_version = "devel" , mpy_cross = None , example_bundle = False ):
147
+ build_tools_version = "devel" , mpy_cross = None , example_bundle = False , remote_name = "origin" ):
148
148
build_dir = "build-" + os .path .basename (output_filename )
149
149
top_folder = os .path .basename (output_filename ).replace (".zip" , "" )
150
150
build_lib_dir = os .path .join (build_dir , top_folder , "lib" )
@@ -176,7 +176,7 @@ def build_bundle(libs, bundle_version, output_filename, package_folder_prefix,
176
176
if multiple_libs :
177
177
with open (os .path .join (build_dir , top_folder , "VERSIONS.txt" ), "w" ) as f :
178
178
f .write (bundle_version + "\r \n " )
179
- versions = subprocess .run ('git submodule --quiet foreach \" git remote get-url origin && git describe --tags\" ' , shell = True , stdout = subprocess .PIPE , cwd = os .path .commonpath (libs ))
179
+ versions = subprocess .run (f 'git submodule --quiet foreach \" git remote get-url { remote_name } && git describe --tags\" ' , shell = True , stdout = subprocess .PIPE , cwd = os .path .commonpath (libs ))
180
180
if versions .returncode != 0 :
181
181
print ("Failed to generate versions file. Its likely a library hasn't been "
182
182
"released yet." )
@@ -233,7 +233,8 @@ def _find_libraries(current_path, depth):
233
233
@click .option ('--library_location' , required = True , help = "Location of libraries to bundle." )
234
234
@click .option ('--library_depth' , default = 0 , help = "Depth of library folders. This is useful when multiple libraries are bundled together but are initially in separate subfolders." )
235
235
@click .option ('--package_folder_prefix' , default = "adafruit_" , help = "Prefix string used to determine package folders to bundle." )
236
- def build_bundles (filename_prefix , output_directory , library_location , library_depth , package_folder_prefix ):
236
+ @click .option ('--remote_name' , default = "origin" , help = "Git remote name to use during building" )
237
+ def build_bundles (filename_prefix , output_directory , library_location , library_depth , package_folder_prefix , remote_name ):
237
238
os .makedirs (output_directory , exist_ok = True )
238
239
239
240
package_folder_prefix = package_folder_prefix .split (", " )
@@ -258,7 +259,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
258
259
filename_prefix + '-py-{VERSION}.zip' .format (
259
260
VERSION = bundle_version ))
260
261
build_bundle (libs , bundle_version , zip_filename , package_folder_prefix ,
261
- build_tools_version = build_tools_version )
262
+ build_tools_version = build_tools_version , remote_name = remote_name )
262
263
263
264
# Build .mpy bundle(s)
264
265
os .makedirs ("build_deps" , exist_ok = True )
@@ -275,17 +276,17 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
275
276
TAG = version ["name" ],
276
277
VERSION = bundle_version ))
277
278
build_bundle (libs , bundle_version , zip_filename , package_folder_prefix ,
278
- mpy_cross = mpy_cross , build_tools_version = build_tools_version )
279
+ mpy_cross = mpy_cross , build_tools_version = build_tools_version , remote_name = remote_name )
279
280
280
281
# Build example bundle
281
282
zip_filename = os .path .join (output_directory ,
282
283
filename_prefix + '-examples-{VERSION}.zip' .format (
283
284
VERSION = bundle_version ))
284
285
build_bundle (libs , bundle_version , zip_filename , package_folder_prefix ,
285
- build_tools_version = build_tools_version , example_bundle = True )
286
+ build_tools_version = build_tools_version , example_bundle = True , remote_name = remote_name )
286
287
287
288
# Build Bundle JSON
288
289
json_filename = os .path .join (output_directory ,
289
290
filename_prefix + '-{VERSION}.json' .format (
290
291
VERSION = bundle_version ))
291
- build_bundle_json (libs , bundle_version , json_filename , package_folder_prefix )
292
+ build_bundle_json (libs , bundle_version , json_filename , package_folder_prefix , remote_name = remote_name )
0 commit comments