Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get working on Windows 7, v2.7.14 #33

Open
sockduct opened this issue Dec 26, 2017 · 4 comments
Open

Cannot get working on Windows 7, v2.7.14 #33

sockduct opened this issue Dec 26, 2017 · 4 comments

Comments

@sockduct
Copy link

  • mkdir test1
  • virtualenv test1
  • test1\scripts\activate
  • pip install py-radix (--> Successfully installed py-radix-0.10.0)
  • python (--> Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32)
>>> import radix
>>> rtree = radix.Radix()
>>> rnode = rtree.add("10.0.0.0/8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Either the application has not called WSAStartup, or WSAStartup failed.

Am I doing something wrong? Please let me know if you need additional details or would like me to try something.

@sockduct
Copy link
Author

sockduct commented Dec 28, 2017

I cloned the repo and set it up without C extensions. Using the same setup as above I get this:

>>> import radix
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build\bdist.win32\egg\radix\__init__.py", line 4, in <module>
  File "build\bdist.win32\egg\radix\radix.py", line 1, in <module>
ImportError: cannot import name inet_pton

The fix for this is to pip install win_inet_pton (inet_pton isn't available in the stdlib socket on Windows for 2.x):

>>> import socket
>>> socket.inet_pton
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'inet_pton'

Once I do this, I can get it to work:

>>> import win_inet_pton
>>> import radix
>>> rtree = radix.Radix()
>>> rnode = rtree.add("10.0.0.0/8")

I thought this might be fixed in Python 3.4+ as described in issue 7171. If I check in Python 3.6, I can see that inet_pton is now included in the stdlib socket:

>>> import socket
>>> socket.inet_pton
<built-in function inet_pton>

However, I still get the same error in 3.6.3 on Windows 7:

> python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import radix
>>> rtree = radix.Radix()
>>> rnode = rtree.add("10.0.0.0/8")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Either the application has not called WSAStartup, or WSAStartup failed.
>>>

But, if I clone the repo and build this without C extensions it does work correctly in 3.6 on Windows. So, there must be some difference in the way inet_pton works on Windows vs. POSIX systems.

Note - as with Python 2.7, installing the package win_inet_pton and importing it before py-radix fixes the issue (if using C extensions).

--Jim

@mjschultz
Copy link
Owner

Thanks for the information. I don't have a windows platform to test this on so I can't be much help on that front.

I'd certainly prefer to not have an external dependency on win_inet_pton as part of this, so perhaps an addition in the README to that effect for Windows platforms.

If you feel compelled to make a PR to fix support for Windows I would gladly accept it. (If it has a regression test runner system like appveyor.yml which I've not gotten to work that would be better.)

@ghost
Copy link

ghost commented Feb 2, 2018

I'd certainly prefer to not have an external dependency on win_inet_pton as part of this, so perhaps an addition in the README to that effect for Windows platforms.

Also, if that is only needed for Windows? requirements in setup.py can be platform-dependent.

@sockduct
Copy link
Author

@mjschultz I'm not a C programmer, so I can't help with a solution to make the C extension Windows compatible without using win_inet_pton. However, if you would be willing to accept a PR to setup.py (per @wagner-certat's suggestion) and the README.rst I might be willing to take a stab at that. Please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants