0

I'm new to building binaries and am having a problem adding the dnspython module. Dnspython sometimes includes some modules dynamically using __import__ and these modules are nested inside other packages. Therefore the find_packages() does not find the required package.

In my case I need the SRV.py module which is located in dns/rdtypes/IN/SRV.py where dns is the dnspython package.

The following is my current setup.py:

from setuptools import setup

APP = ['MongoDB.py']
OPTIONS = {
    "includes": [],
}

setup(
     plugin=APP,
     options={'py2app': OPTIONS},
     setup_requires=['py2app'],
     install_requires=['pyobjc', 'pymongo', 'dnspython'],
)

Since I need the SRV.py file inside rdtypes and IN, I thought I called a requirement like so: dnspython.rdtypes.IN which did not work. I also tried adding it to the packages(packages=[dnspython, ...]) which also didn't work.

I have not found anything regarding these nested packages and how to include them, any help would be greatly appreciated.

phd
  • 82,685
  • 13
  • 120
  • 165
J.Paravicini
  • 882
  • 12
  • 39
  • When i run the setup.py only the files in the root directory(dns) are copied into the plugin, I am using py2app if it is of some importance. But all the subdirectories inside dns are not copied into the plugin – J.Paravicini Jul 17 '18 at 16:08
  • @J.Paravicini: That sounds like it's more of a py2app issue than a setuptools issue. – jwodder Jul 17 '18 at 16:20
  • Hmm could be, have had similar issues with another package. Are there other tools to create python plugins? – J.Paravicini Jul 17 '18 at 16:21
  • `py2app` seems [having problems](https://py2app.readthedocs.io/en/latest/recipes.html) with `__import__` and has worarounds for selected modules but not for `dnspython`. Perhaps you have to develop your own recipe. – phd Jul 17 '18 at 16:59
  • Also try include packages recursively, i.e. list all subpackages explicitly: `OPTIONS = {'packages': ['dns', 'dns.rdtypes', 'dns.rdtypes.ANY', 'dns.rdtypes.IN']}` – phd Jul 17 '18 at 17:01
  • I did this except of using packages I used includes. Do you know what the difference is? – J.Paravicini Jul 17 '18 at 17:04
  • `includes` includes [**modules**](https://docs.python.org/3/tutorial/modules.html), i.e. separate files `*.py`. `packages` adds [**packages**](https://docs.python.org/3/tutorial/modules.html#packages), i.e. directories with `__init__.py` and `*.py` files. – phd Jul 17 '18 at 17:14
  • Thanks, this solved the primer problem. I know i shouldn't ask another question, however I also need to install the ssl package which is a builtin package. How could I include that one? – J.Paravicini Jul 17 '18 at 17:16
  • https://stackoverflow.com/search?q=%5Bpython%5D+ssl+macos – phd Jul 17 '18 at 19:39
  • Thanks for your help, if you'd like you can post you suggestion as an answer and i'll accept it. As the packages: ['dns'... part solved my problem – J.Paravicini Jul 18 '18 at 10:34

0 Answers0