Make it possible to build and use ext on windows
- change ext attributes and c source for windows allowing to build pyd - remove trailing slashes in data_files - try to load pyd in proofofwork by ctypes.PyDLL()
This commit is contained in:
parent
f6cb3ad016
commit
ad6496e426
13
setup.py
13
setup.py
|
@ -59,6 +59,13 @@ if __name__ == "__main__":
|
||||||
libraries=['pthread', 'crypto'],
|
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']
|
installRequires = ['six']
|
||||||
packages = [
|
packages = [
|
||||||
'pybitmessage',
|
'pybitmessage',
|
||||||
|
@ -90,11 +97,11 @@ if __name__ == "__main__":
|
||||||
packages += ['pybitmessage.fallback.umsgpack']
|
packages += ['pybitmessage.fallback.umsgpack']
|
||||||
|
|
||||||
data_files = [
|
data_files = [
|
||||||
('share/applications/',
|
('share/applications',
|
||||||
['desktop/pybitmessage.desktop']),
|
['desktop/pybitmessage.desktop']),
|
||||||
('share/icons/hicolor/scalable/apps/',
|
('share/icons/hicolor/scalable/apps',
|
||||||
['desktop/icons/scalable/pybitmessage.svg']),
|
['desktop/icons/scalable/pybitmessage.svg']),
|
||||||
('share/icons/hicolor/24x24/apps/',
|
('share/icons/hicolor/24x24/apps',
|
||||||
['desktop/icons/24x24/pybitmessage.png'])
|
['desktop/icons/24x24/pybitmessage.png'])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -163,3 +163,8 @@ extern "C" EXPORT unsigned long long BitmessagePOW(unsigned char * starthash, un
|
||||||
free(threaddata);
|
free(threaddata);
|
||||||
return successval;
|
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
|
||||||
|
|
|
@ -298,7 +298,13 @@ def init():
|
||||||
bitmsglib = 'bitmsghash64.dll'
|
bitmsglib = 'bitmsghash64.dll'
|
||||||
try:
|
try:
|
||||||
# MSVS
|
# 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)
|
logger.info("Loaded C PoW DLL (stdcall) %s", bitmsglib)
|
||||||
bmpow = bso.BitmessagePOW
|
bmpow = bso.BitmessagePOW
|
||||||
bmpow.restype = ctypes.c_ulonglong
|
bmpow.restype = ctypes.c_ulonglong
|
||||||
|
|
Reference in New Issue
Block a user