@@ -66,9 +66,9 @@ def add_file(bundle, src_file, zip_name):
6666 print (zip_name , file_size , file_sector_size )
6767 return file_sector_size
6868
69- def get_module_name (library_path ):
69+ def get_module_name (library_path , remote_name ):
7070 """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 )
7272 repo = repo .stdout .decode ("utf-8" , errors = "ignore" ).strip ().lower ()
7373 if repo [- 4 :] == ".git" :
7474 repo = repo [:- 4 ]
@@ -110,15 +110,15 @@ def get_bundle_requirements(directory, package_list):
110110 pypi_reqs .add (original_name )
111111 return sorted (dependencies ), sorted (pypi_reqs )
112112
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" ):
114114 """
115115 Generate a JSON file of all the libraries in libs
116116 """
117117 packages = {}
118118 for library_path in libs :
119119 package = {}
120120 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 )
122122 if package_info ["module_name" ] is not None :
123123 package ["module_name" ] = package_info ["module_name" ]
124124 package ["pypi_name" ] = module_name
@@ -144,7 +144,7 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref
144144 out_file .close ()
145145
146146def 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" ):
148148 build_dir = "build-" + os .path .basename (output_filename )
149149 top_folder = os .path .basename (output_filename ).replace (".zip" , "" )
150150 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,
176176 if multiple_libs :
177177 with open (os .path .join (build_dir , top_folder , "VERSIONS.txt" ), "w" ) as f :
178178 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 ))
180180 if versions .returncode != 0 :
181181 print ("Failed to generate versions file. Its likely a library hasn't been "
182182 "released yet." )
@@ -233,7 +233,8 @@ def _find_libraries(current_path, depth):
233233@click .option ('--library_location' , required = True , help = "Location of libraries to bundle." )
234234@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." )
235235@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 ):
237238 os .makedirs (output_directory , exist_ok = True )
238239
239240 package_folder_prefix = package_folder_prefix .split (", " )
@@ -258,7 +259,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
258259 filename_prefix + '-py-{VERSION}.zip' .format (
259260 VERSION = bundle_version ))
260261 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 )
262263
263264 # Build .mpy bundle(s)
264265 os .makedirs ("build_deps" , exist_ok = True )
@@ -275,17 +276,17 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
275276 TAG = version ["name" ],
276277 VERSION = bundle_version ))
277278 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 )
279280
280281 # Build example bundle
281282 zip_filename = os .path .join (output_directory ,
282283 filename_prefix + '-examples-{VERSION}.zip' .format (
283284 VERSION = bundle_version ))
284285 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 )
286287
287288 # Build Bundle JSON
288289 json_filename = os .path .join (output_directory ,
289290 filename_prefix + '-{VERSION}.json' .format (
290291 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