Forum Archive

ipv6 in pythonista not supplied?

tlinnet

Hi.

I am trying to submit an app for Apple app store.

It uses the python request module.

Apple request that such an app should support IPv6-only Networks.

https://developer.apple.com/news/?id=05042016a

The following snippet shows that ipv6 is not included.
It shows:

socket.has_ipv6 = False
error message: "error: getsockaddrarg: bad family"

import requests, socket

# Test of python has ipvp
print("Has ipv6?: %s\n"%socket.has_ipv6)

root='http://ipv6.whatismyv6.com/'
url=root
params = {}

try:
    r = requests.get(url, params=params)
    print("Request works\n")
except requests.exceptions.RequestException as e:
    print("ERROR: Request does not work!")
    print(str(e.message))

I have tested this on pythonista 3.0 and in the 2.7 and 3.5 interpreter.

tlinnet

Could this be solved by using objc_util ?

tlinnet

This is difficult!
How to figure out how this is working in objc_util?

I think I have prepared a request, but now I want to make the request.
But I am lost....

This is where I am at the moment.

https://gist.github.com/tlinnet/92c0654081a6c49aa5b39a984018b253

tlinnet

Another try, but still failing

https://gist.github.com/tlinnet/c1aaa1d4494548217b3ed91301f64eb2

JonB

Does it work in safari? or ipv6.google.com?

I noticed --disable-ipv6 in the config args:

>>> sysconfig.get_config_var('CONFIG_ARGS')
"'CC=xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -miphoneos-version-min=7.0 ' 'LD=xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -miphoneos-version-min=7.0 ' '--host=x86_64-apple-ios' '--build=x86_64-apple-darwin15.2.0' '--prefix=/Users/ole/Development/xcode/Pythonista3/Python-iOS-support-3.5.1-b1/build/iOS/Python-3.5.1-iphonesimulator.x86_64/dist' '--without-pymalloc' '--without-doc-strings' '--disable-ipv6' '--without-ensurepip' 'ac_cv_file__dev_ptmx=no' 'ac_cv_file__dev_ptc=no' 'build_alias=x86_64-apple-darwin15.2.0' 'host_alias=x86_64-apple-ios'"

Looking at the python configure script, it looks like you need to add

#define ENABLE_IPV6 1

to confdefs.h... though I don't know if python is being built in the xcode, or if it is precompiled...

tlinnet

The very first problem for this issue.

To establish an ipv6-only environment, when my router WAN is only ipv4.

So testing is difficult!

But it seems pythonista is shipped without ipv6 support. At least in the iOS app.

tlinnet

I will look into if Xcode can be manipulated to compile with ipv6 .

The road by using objc util instead, could be a solution. But I am simply lost there, and don't know how to bug track.

@omz can you confirm the ipv6 problem?
Has any apps been released to the app store, which use request?

tlinnet

@JonB said:

confdefs.h

No luck in finding confdefs.h or any setting with IPV6.

There is:
PythonistaAppTemplate/PythonistaKit.framework/pylib/_sysconfigdata.py

 'ENABLE_IPV6': 1,```

But the header says:

# [omz] NOTE: This is required by site.py, but the values are not correct.
#             It's a copy of the default OS X _sysconfigdata, but there shouldn't
#             be much need for this on iOS anyway.

# system configuration generated and used by the sysconfig module