mtrojnar / osslsigncode

OpenSSL based Authenticode signing for PE/MSI/Java CAB files
Other
801 stars 131 forks source link

Not able to run tests when building on system with Python < 3.7 #349

Closed ThinLinc-Zeijlon closed 9 months ago

ThinLinc-Zeijlon commented 9 months ago

When trying to build osslsigncode on systems with older Python versions, the build fails.

This is due to the server_http.py script, that runs as a part of the build procedure. It imports the ThreadingHTTPServer-module which was added to Python in version 3.7.

I tried replacing ThreadingHTTPServer with a plain HTTPServer and the test seems to run just fine anyway, both on Python 3.6 and Python 3.12.

diff --git a/tests/server_http.py b/tests/server_http.py
index 6848172..babda8b 100644
--- a/tests/server_http.py
+++ b/tests/server_http.py
@@ -6,7 +6,7 @@ import subprocess
 import sys
 import threading
 from urllib.parse import urlparse
-from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
+from http.server import SimpleHTTPRequestHandler, HTTPServer

 RESULT_PATH = os.getcwd()
 FILES_PATH = os.path.join(RESULT_PATH, "./Testing/files/")
@@ -96,7 +96,7 @@ class HttpServerThread():

     def start_server(self, port) -> (int):
         """Starting HTTP server on 127.0.0.1 and a random available port for binding"""
-        self.server = ThreadingHTTPServer(('127.0.0.1', port), RequestHandler)
+        self.server = HTTPServer(('127.0.0.1', port), RequestHandler)
         self.server_thread = threading.Thread(target=self.server.serve_forever)
         self.server_thread.start()
         hostname, port = self.server.ser
olszomal commented 9 months ago

It's a good idea. Please feel free to make a pull request yourself.

ThinLinc-Zeijlon commented 9 months ago

Alright, thank you!