Repo location: https://github.com/willkara/SakaiPy
So I have this python modudle I'm creating. It currently has this structure:
SakaiPy
├── SakaiPy
│ ├── __init__.py #1
│ └── RequestGenerator.py
├── SakaiTools
├── __init__.py #2
├── Assignment.py
├── Announcement.py
└── ...etc.py
└── setup.py
init.py #1 looks like:
__all__=['SakaiTools']
from SakaiTools import *
init.py #2 is empty
My setup.py looks like:
version='1.0',
description='Python interface to the Sakai RESTful API\'s',
license='MIT',
author='William Karavites',
author_email='[email protected]',
url='https://github.com/willkara/SakaiPy',
packages=['SakaiPy','SakaiPy/SakaiTools'],
requires={
"mechanize",
"cookielib",
"requests",
"simplejson"}
)
My problem is that the module seems to be building incorrectly.
When I try and use the module like this:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from SakaiPy import *
print "hello"
authInfo={}
authInfo['baseURL'] =""
authInfo['loginURL']=""
authInfo['username']=""
authInfo['password']=""
rq = RequestGenerator.RequestGenerator(authInfo)
I get this error:
Traceback (most recent call last):
File "../sakaiTest.py", line 14, in <module>
rq = RequestGenerator.RequestGenerator(authInfo)
NameError: name 'RequestGenerator' is not defined
My guess is that my setup.py and init.py scripts are setup incorrectly.
You are going to want to change your directory stucture, as right now you technically have two Python modules and you are giving
setuptoolsan incorrect package path. In order to get the path you are looking for, you are going to need to nest theSakaiToolsdirectory within theSakaiPydirectory. With this, you should be able to have the import you are looking for, and you can importSakaiToolsasSakiPy.SakaiToolslike you appear to be try to do.This will give you a single module with
SakaiToolsas a submodule, which sounds like what you are looking for. You are going to need to remve youSakaiToolsimports from the first__init__.py, as you will be able to access those imports just fine with this setup.If you are looking to keep the two different modules, you are going to need to tell
setuptoolsthat you have two different modules.