Open lijincan opened 10 years ago
Hi, If you add the nanomsg.dll to your PATH this should work, but it will be using the ctypes backend which is a bit slower.
I'm afraid building the library from source on windows is a bit hard. I will upload binaries for windows to PyPI as soon as I can.
Hi, add the nanomsg.dll to PATH can't solve the problem ;( still the same error
Hi, any progress on windows support? Building nanomsg sources was easy part but I cannot make nanomsg-python work.
I have manage to make it work on windows. Maybe my tips would be usefull for someone.
Requirements: visual studio, cmake
after this step you should find nanomsg.lib and nanomsg.dll in Release (or Debug) directory.
now you can start to use nanomsg in python - BUT YOU NEED: nanomsg.dll in directory from which you run script.
If there is no nanomsg.dll you will get exception after import nanomsg (WindowsError: [Error 126] ....).
If it's working you can delete
It would be nice to make it easier - maybe someone knows easy way to make binary package installer with nanomsg.dll included.
If you like to I can send you binary installer of python module "nanomsg-1.0.win32-py2.7.exe" (made with python setup.py bdist --format=wininst) and a nanomsg.dll.
@vac thanks pal. it solved my problem.
You can create a complete windows installer (that contains the compiled dll) by adding the following line to setup.py
setup( name='nanomsg', version=version, packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')], data_files=[('lib\site-packages\',["C:\Dev\external\nanomsg\x64\Release\nanomsg.dll"])], ...
of course change the path to nanomsg.dll
yeah windows installer is nice but unfortunately python lib/site-packages are not in windows PATH by default.. So your app/script which is using nanomsg still cannot find dll...
Ok it's now much better. I'v made windows installer with dll included as @shluvme suggested: setup.py:
data_files=[('lib/site-packages',["../nanomsg/nanomsg.dll",])]
setup(
name='nanomsg',
version=__version__,
packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')],
data_files = data_files,
dll would be copied to python site-pakcages. To make sure that it's directory would be included in system PATH I'v added following code to nanomsg/init.py:
from __future__ import division, absolute_import, print_function, unicode_literals
from .version import __version__
from struct import Struct as _Struct
import warnings
#-----HERE:-------
import distutils.sysconfig
import os
os.environ['PATH'] += ';'+distutils.sysconfig.get_python_lib()
#-----------------
from . import wrapper
This way everytime nanomsg is imported the site-packages are added to system path and nanomsg.dll can be found by wrapper.
Installer is made with python setup.py bdist_wininst
.
ps. if you would like to test my windows build I'v put installer here: http://vacu.la/python/nanomsg-1.0.win32-py2.7.exe
warning: nanomsg and nanomsg-python code which was used to generate dll and installer is not recent (april 2015)
C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg_wrappersinit.py:22: UserWarning: Could not load the default wrapper for your platform: cpy, performance may be affected! "%s, performance may be affected!") % (default,)) Traceback (most recent call last): File "F:\eclipse_projects\test\nanomsq_t1.py", line 3, in
import nanomsg
File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsginit.py", line 7, in
from . import wrapper
File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg\wrapper.py", line 4, in
_wrapper = _load_wrapper()
File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsgwrappersinit.py", line 23, in load
wrapper
return importlib.import_module('_nanomsg_ctypes')
File "C:\Python27\lib\importlibinit.py", line 37, in import_module
import(name)
File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg_nanomsg_ctypesinit.py", line 10, in <modul
e>
_lib = ctypes.windll.nanomsg
File "C:\Python27\lib\ctypesinit.py", line 423, in getattr
dll = self._dlltype(name)
File "C:\Python27\lib\ctypesinit.py", line 353, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126]