diff --git a/appveyor.yml b/appveyor.yml index 9cd351ac6..ab0e4425c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,6 +49,7 @@ install: - set PATH=c:\msys64\mingw32\bin;%PATH% - g++ --version - set PATH=c:\Python27-x64;%PATH% + - set PYTHON_INTERPRETER=c:\Python27-x64\python.exe - python --version - echo %ROOT_DIRECTORY% - cd %BOOST_BUILD_PATH% diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 6f989685a..5dd52a713 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -590,6 +590,21 @@ void wait_for_port(int const port) } #endif +std::string get_python() +{ +#ifdef _WIN32 + char dummy[1]; + DWORD const req_size = GetEnvironmentVariable("PYTHON_INTERPRETER", dummy, sizeof(dummy)); + if (req_size > 1 && req_size < 4096) + { + std::vector buf(req_size); + DWORD const sz = GetEnvironmentVariable("PYTHON_INTERPRETER", buf.data(), buf.size()); + if (sz == buf.size() - 1) return buf.data(); + } +#endif + return "python"; +} + } // returns a port on success and -1 on failure @@ -627,29 +642,30 @@ int start_proxy(int proxy_type) case settings_pack::socks4: type = "socks4"; auth = " --allow-v4"; - cmd = "python ../socks.py"; + cmd = "../socks.py"; break; case settings_pack::socks5: type = "socks5"; - cmd = "python ../socks.py"; + cmd = "../socks.py"; break; case settings_pack::socks5_pw: type = "socks5"; auth = " --username testuser --password testpass"; - cmd = "python ../socks.py"; + cmd = "../socks.py"; break; case settings_pack::http: type = "http"; - cmd = "python ../http.py"; + cmd = "../http.py"; break; case settings_pack::http_pw: type = "http"; auth = " --username testuser --password testpass"; - cmd = "python ../http.py"; + cmd = "../http.py"; break; } - char buf[512]; - std::snprintf(buf, sizeof(buf), "%s --port %d%s", cmd, port, auth); + std::string python_exe = get_python(); + char buf[1024]; + std::snprintf(buf, sizeof(buf), "%s %s --port %d%s", python_exe.c_str(), cmd, port, auth); std::printf("%s starting proxy on port %d (%s %s)...\n", time_now_string(), port, type, auth); std::printf("%s\n", buf); @@ -1027,9 +1043,11 @@ int start_web_server(bool ssl, bool chunked_encoding, bool keepalive, int min_in , std::uint16_t(port)), ec); } while (ec); + std::string python_exe = get_python(); + char buf[200]; - std::snprintf(buf, sizeof(buf), "python ../web_server.py %d %d %d %d %d" - , port, chunked_encoding, ssl, keepalive, min_interval); + std::snprintf(buf, sizeof(buf), "%s ../web_server.py %d %d %d %d %d" + , python_exe.c_str(), port, chunked_encoding, ssl, keepalive, min_interval); std::printf("%s starting web_server on port %d...\n", time_now_string(), port);