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

Added py3dns recipe #2590

Merged
merged 2 commits into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pythonforandroid/recipes/py3dns/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pythonforandroid.recipe import PythonRecipe


class Py3DNSRecipe(PythonRecipe):
site_packages_name = 'DNS'
version = '3.2.1'
url = 'https://github.com/Neizvestnyj/py3dns/archive/{version}.zip'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using the official launchpad download link instead?
https://launchpad.net/py3dns/trunk/3.2.1/+download/py3dns-3.2.1.tar.gz

Suggested change
url = 'https://github.com/Neizvestnyj/py3dns/archive/{version}.zip'
url = 'https://launchpad.net/py3dns/trunk/{version}/+download/py3dns-{version}.tar.gz'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, well, I didn't think about it. py3dns works fine and does not require any changes yet. It's just that there is such a bug on android. The last validate_email release was in 2015 :)

depends = ['setuptools']
patches = ['patches/android.patch']
call_hostpython_via_targetpython = False


recipe = Py3DNSRecipe()
21 changes: 21 additions & 0 deletions pythonforandroid/recipes/py3dns/patches/android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/DNS/Base.py b/DNS/Base.py
index 34a6da7..15f83a2 100644
--- a/DNS/Base.py
+++ b/DNS/Base.py
@@ -49,9 +49,13 @@ defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,
'server': [] }

def ParseResolvConf(resolv_path="/etc/resolv.conf"):
- "parses the /etc/resolv.conf file and sets defaults for name servers"
- with open(resolv_path, 'r') as stream:
- return ParseResolvConfFromIterable(stream)
+ try:
+ "parses the /etc/resolv.conf file and sets defaults for name servers"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter too much, but docstring could stay where it was instead of being in the try/except block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

+ with open(resolv_path, 'r') as stream:
+ return ParseResolvConfFromIterable(stream)
+ except FileNotFoundError:
+ defaults['server'].append('127.0.0.1')
+ return

def ParseResolvConfFromIterable(lines):
"parses a resolv.conf formatted stream and sets defaults for name servers"