Maybe it's something stupid I am doing or maybe I need to do something in setup.py
or maybe it's a bug.
Python 2.6 Django 1.6
This is a reusable django app with multiple sub apps. What makes it django related is the error. When I try enable the sub apps django cannot find them. The reason it cannot find them is because setup.py strips out the __init__.py
during install. When I manually add it back in at the install location it's ok.
The app folder and relevant file arrangement is as follows.
someapp
django
apps
subapp1
subapp2
subapp3
__init__.py
setup.py
After python setup.py install
the __init__.py
shown above is missing from the install location and if that file is missing django cannot find subapp1, subapp2, subapp3 when I try add them to INSTALLED_APPS
.
When I try add someapp.django.apps.subapp1
django says
No module named apps.subapp1
When I add the __init__.py in
apps` folder in the install location that error goes away.
All other folders have __init__.py
after running setup.py except apps
.
I tried changing the apps
directory name thinking maybe that's a reserved word but it didn't change anything. I also tried adding something to the __init__.py
file thinking maybe it can't be empty but didn't help. Also tried adding an empty models.py
file thinking there needed to be more there but still no dice.
My setup.py file is just standard boilerplate. Maybe there is something I need to add. I tried using distutils instead of setuptools but that didn't make a difference.
#setup.py
import os
from setuptools import setup
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "appname",
version = "0.0.1",
author = "blah inc",
author_email = "blah@blah.com",
description = ("some description"),
license = "MPL",
keywords = "some keywords",
url = "http://someurl.org",
packages=[
'someapp',
'someapp.api',
'someapp.django',
'someapp.django.apps.subapp1',
'someapp.django.apps.subapp2',
'someapp.django.apps.subapp3',
'someapp.eventsocket',
'someapp.interface',
],
etc.
etc.
.
.
)
You missed out the someapp.django.apps
package; you must list all packages in that list.
You can make the task easier by using setuptools.find_packages()
:
setup(
# ...
packages=find_packages(),
# ...
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.