Skip to contentSkip to conversation

scanpypi: don't pass any arguments to main()

PATCH New Alexey Roslyakov 3 participants 5 messages Jul 20, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 scanpypi: don't pass any arguments to main()

'if __name__ == "__main__"' idiom typically calls main function that doesn't take any arguments in most cases. We shouldn't pass any tuple to it.
I've tested the script with python-idna-2.5 and now it works with this little change.

---
 utils/scanpypi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/scanpypi +2 -2
index bb3899241b..9abf3c4139 100755
@@ -255,12 +255,12 @@ class BuildrootPackage():
             # called through the if __name__ == '__main__' directive.
             # In this case, we can only pray that it is called through a
             # function called main() in setup.py.
-            setup.main([]) # Will raise AttributeError if not found
+            setup.main() # Will raise AttributeError if not found
             self.setup_metadata = self.setup_args[self.metadata_name]
         # Here we must remove the module the hard way.
         # We must do this because of a very specific case: if a package calls
         # setup from the __main__ but does not come with a 'main()' function,
-        # for some reason setup.main([]) will successfully call the main
+        # for some reason setup.main() will successfully call the main
         # function of a previous package...
         sys.modules.pop('setup',None)
         del setup
Signature · 1 line
2.13.0
#1 lore raw

PATCH 2/2 scanpypi: include LICENSE.RST in the list of supported license files

---
 utils/scanpypi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/scanpypi +2 -2
index 9abf3c4139..02384f2569 100755
@@ -416,8 +416,8 @@ class BuildrootPackage():
             license=', '.join(licenses))
         lines.append(license_line)
 
-        filenames = ['LICENCE', 'LICENSE', 'LICENSE.TXT', 'COPYING',
-		     'COPYING.TXT']
+        filenames = ['LICENCE', 'LICENSE', 'LICENSE.RST', 'LICENSE.TXT',
+		     'COPYING', 'COPYING.TXT']
         license_files = list(find_file_upper_case(filenames, self.tmp_extract))
         license_files = [license.replace(self.tmp_extract, '')[1:]
                          for license in license_files]
Signature · 1 line
2.13.0
#2 lore raw

PATCH 2/2 scanpypi: include LICENSE.RST in the list of supported license files

Quoted 1 line · Alexey Roslyakov
Quoted 22 lines
---
 utils/scanpypi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/scanpypi +2 -3
index 9abf3c4139..02384f2569 100755
@@ -416,8 +416,8 @@ class BuildrootPackage():
             license=', '.join(licenses))
         lines.append(license_line)
 
-        filenames = ['LICENCE', 'LICENSE', 'LICENSE.TXT', 'COPYING',
-                    'COPYING.TXT']
+        filenames = ['LICENCE', 'LICENSE', 'LICENSE.RST', 'LICENSE.TXT',
+                    'COPYING', 'COPYING.TXT']
         license_files = list(find_file_upper_case(filenames, self.tmp_extract))
         license_files = [license.replace(self.tmp_extract, '')[1:]
                          for license in license_files]
--

2.13.0

#3 lore raw

PATCH 1/2 scanpypi: don't pass any arguments to main()

In reply to Alexey Roslyakov

Hi Alexey,

Quoted 7 lines · Alexey Roslyakov

'if __name__ == "__main__"' idiom typically calls main function that doesn't take any arguments in most cases. We shouldn't pass any tuple to it.
I've tested the script with python-idna-2.5 and now it works with this little change.

Good catch! I've tested it with cbor and it is now working like a charm.

Quoted 26 lines
---
 utils/scanpypi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/scanpypi +2 -3
index bb3899241b..9abf3c4139 100755
@@ -255,12 +255,12 @@ class BuildrootPackage():
             # called through the if __name__ == '__main__' directive.
             # In this case, we can only pray that it is called through a
             # function called main() in setup.py.
-            setup.main([]) # Will raise AttributeError if not found
+            setup.main() # Will raise AttributeError if not found
             self.setup_metadata = self.setup_args[self.metadata_name]
         # Here we must remove the module the hard way.
         # We must do this because of a very specific case: if a package calls
         # setup from the __main__ but does not come with a 'main()' function,
-        # for some reason setup.main([]) will successfully call the main
+        # for some reason setup.main() will successfully call the main
         # function of a previous package...
         sys.modules.pop('setup',None)
         del setup
--

2.13.0

#4 lore raw

PATCH 1/2 scanpypi: don't pass any arguments to main()

In reply to Alexey Roslyakov

Hello,

Quoted 10 lines · Alexey Roslyakov

'if __name__ == "__main__"' idiom typically calls main function that doesn't take any arguments in most cases. We shouldn't pass any tuple to it.
I've tested the script with python-idna-2.5 and now it works with this little change.

---
 utils/scanpypi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Both patches applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com