Merge branch 'windows-binary' into testing

This commit is contained in:
Dmitri Bogomolov 2021-12-15 22:16:36 +02:00
commit 962ddbcc2e
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
5 changed files with 55 additions and 23 deletions

View File

@ -18,7 +18,8 @@ function download_sources_32 {
https://web.archive.org/web/20210420044701/https://download.microsoft.com/download/1/1/1/1116b75a-9ec3-481a-a3c8-1777b5381140/vcredist_x86.exe \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/PyQt${PYQT_VERSION}-x32.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/Win32OpenSSL-${OPENSSL_VERSION}.exe?raw=true \
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win32.whl?raw=true
https://github.com/Bitmessage/ThirdPartyLibraries/blob/master/pyopencl-2015.1-cp27-none-win32.whl?raw=true \
https://web.archive.org/web/20190720195601/https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi
}
function download_sources_64 {
@ -64,8 +65,10 @@ function install_python(){
wine msiexec -i python-${PYTHON_VERSION}.msi /q /norestart
# MSVCR 2008 required for Windows XP
cd ${SRCPATH} || exit 1
echo "Installing vc_redist (2008) for 32 bit "
echo "Installing vc_redist (2008) for 32 bit"
wine vcredist_x86.exe /Q
echo "Installing vcpython27"
wine msiexec -i VCForPython27.msi /qn /norestart
fi
echo "Installing pytools 2020.2"
# last version compatible with python 2
@ -88,9 +91,11 @@ function install_openssl(){
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
echo "Installing OpenSSL ${OPENSSL_VERSION} 64b"
wine Win64OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
export OPENSSL_DIR="$HOME/.wine64/drive_c/OpenSSL-Win64"
else
echo "Installing OpenSSL ${OPENSSL_VERSION} 32b"
wine Win32OpenSSL-${OPENSSL_VERSION}.exe /q /norestart /silent /verysilent /sp- /suppressmsgboxes
export OPENSSL_DIR="C:\\OpenSSL-Win32"
fi
}
@ -131,8 +136,8 @@ function install_pyopencl()
function build_dll(){
cd "${BASE_DIR}" || exit 1
cd src/bitmsghash || exit 1
if [ "${MACHINE_TYPE}" == 'x86_64' ]; then
cd src/bitmsghash || exit 1
echo "Create dll"
x86_64-w64-mingw32-g++ -D_WIN32 -Wall -O3 -march=native \
"-I$HOME/.wine64/drive_c/OpenSSL-Win64/include" \
@ -147,18 +152,20 @@ function build_dll(){
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
-o bitmsghash64.dll -Wl,--out-implib,bitmsghash.a
else
echo "Create dll"
i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native \
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
-I/usr/i686-w64-mingw32/include \
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib" \
-c bitmsghash.cpp
i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
-D_WIN32 -O3 -march=native \
"-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
"-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW" \
-fPIC -shared -lcrypt32 -leay32 -lwsock32 \
-o bitmsghash32.dll -Wl,--out-implib,bitmsghash.a
echo "Create pyd"
# FIXME: check for VCPython and build dll if not found
wine python setup.py build_ext --inplace
# i686-w64-mingw32-g++ -D_WIN32 -Wall -m32 -O3 -march=native \
# "-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
# -I/usr/i686-w64-mingw32/include \
# "-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib" \
# -c bitmsghash.cpp
# i686-w64-mingw32-g++ -static-libgcc -shared bitmsghash.o \
# -D_WIN32 -O3 -march=native \
# "-I$HOME/.wine32/drive_c/OpenSSL-Win32/include" \
# "-L$HOME/.wine32/drive_c/OpenSSL-Win32/lib/MinGW" \
# -fPIC -shared -lcrypt32 -leay32 -lwsock32 \
# -o bitmsghash32.dll -Wl,--out-implib,bitmsghash.a
fi
}

View File

@ -12,7 +12,7 @@ arch = 32 if ctypes.sizeof(ctypes.c_voidp) == 4 else 64
cdrivePath = site_root[0:3]
srcPath = os.path.join(spec_root[:-20], "pybitmessage")
sslName = 'OpenSSL-Win%i' % arch
openSSLPath = os.path.join(cdrivePath, sslName)
openSSLPath = os.getenv('OPENSSL_DIR') or os.path.join(cdrivePath, sslName)
msvcrDllPath = os.path.join(cdrivePath, "windows", "system32")
outPath = os.path.join(spec_root, "bitmessagemain")
qtBase = "PyQt4"
@ -83,12 +83,19 @@ excluded_binaries = [
]
a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
ext_lib = os.path.join('bitmsghash', 'bitmsghash%i.dll' % arch)
if os.path.isfile(ext_lib):
ext_lib = (ext_lib, os.path.join(srcPath, ext_lib), 'BINARY')
else:
ext_lib = (
os.path.join('bitmsghash', 'bitmsghash.pyd'),
os.path.join(srcPath, 'bitmsghash', 'bitmsghash.pyd'), 'EXTENSION')
a.binaries += [
# No effect: libeay32.dll will be taken from PyQt if installed
('libeay32.dll', os.path.join(openSSLPath, 'libeay32.dll'), 'BINARY'),
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % arch),
os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % arch),
'BINARY'),
ext_lib,
(os.path.join('bitmsghash', 'bitmsghash.cl'),
os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
(os.path.join('sslkeys', 'cert.pem'),

View File

@ -62,6 +62,13 @@ if __name__ == "__main__":
libraries=['pthread', 'crypto'],
)
if sys.platform[:3] == 'win':
bitmsghash.libraries = ['libeay32', 'ws2_32']
openssl_dir = os.getenv('OPENSSL_DIR')
if openssl_dir:
bitmsghash.library_dirs = [os.path.join(openssl_dir, 'lib')]
bitmsghash.include_dirs = [os.path.join(openssl_dir, 'include')]
installRequires = ['six']
packages = [
'pybitmessage',
@ -93,11 +100,11 @@ if __name__ == "__main__":
packages += ['pybitmessage.fallback.umsgpack']
data_files = [
('share/applications/',
('share/applications',
['desktop/pybitmessage.desktop']),
('share/icons/hicolor/scalable/apps/',
('share/icons/hicolor/scalable/apps',
['desktop/icons/scalable/pybitmessage.svg']),
('share/icons/hicolor/24x24/apps/',
('share/icons/hicolor/24x24/apps',
['desktop/icons/24x24/pybitmessage.png'])
]

View File

@ -163,3 +163,8 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
free(threaddata);
return successval;
}
// workaround for building setuptools ext on Windows
// https://stackoverflow.com/questions/34689210
void initbitmsghash() {} //Python 2.7
void PyInit_bitmsghash() {} //Python 3.5

View File

@ -346,7 +346,13 @@ def init():
bitmsglib = 'bitmsghash64.dll'
try:
# MSVS
bso = ctypes.WinDLL(os.path.join(paths.codePath(), "bitmsghash", bitmsglib))
libfile = os.path.join(paths.codePath(), "bitmsghash", bitmsglib)
if os.path.isfile(libfile):
bso = ctypes.WinDLL(libfile)
else:
bitmsglib = 'bitmsghash.pyd'
libfile = os.path.join(paths.codePath(), "bitmsghash", bitmsglib)
bso = ctypes.PyDLL(libfile)
logger.info("Loaded C PoW DLL (stdcall) %s", bitmsglib)
bmpow = bso.BitmessagePOW
bmpow.restype = ctypes.c_ulonglong