Reputation: 26049
Update: added setup.py
content.
I have the following directory structure:
setup.py
packagename/
__init__.py
useless_file.py
In __init__.py
, I have the following:
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
CONFIG_FILENAME = "packagename.settings"
def create_app():
app = Flask(__name__)
app.config.from_object(CONFIG_FILENAME)
db.init_app(app)
app.register_blueprint(sms_testing)
return app
I followed Flask's recommended package structure.
Here is setup.py
:
import os
from setuptools import setup
requires = (
"flask",
"flask-sqlalchemy",
"requests>=0.13.6",
"python-dateutil>=1.5",
"twilio",
"selenium",
)
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "Package Name",
version = "0.0.1",
author = "Charles-Axel Dein",
author_email = "[email protected]",
description = ("useless"),
license = "BSD",
keywords = "example documentation tutorial",
url = "http://packages.python.org/an_example_pypi_project",
packages=['package_name',],
# namespace_packages = ['package_name'],
install_requires=requires,
long_description=read('README.md'),
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
],
)
When I do python setup.py develop
, I get:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from setuptools import setup
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/__init__.py", line 2, in <module>
# The Python Imaging Library.
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/extension.py", line 2, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 6, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/sdist.py", line 5, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2623, in <module>
if not len(req.specs):
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 679, in subscribe
`requirements` must be a string or a (possibly-nested) sequence
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2623, in <lambda>
if not len(req.specs):
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2172, in activate
return pv
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1790, in declare_namespace
module.__path__ = []; _set_parent_ns(packageName)
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1761, in _handle_ns
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 238, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/package_name/__init__.py", line 2, in <module>
import flask
File "/.virtualenvs/api/lib/python2.7/site-packages/flask/exthook.py", line 86, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask
(I redacted the folder)
I guess it's logical, since setuptools is trying to import my package, which imports packagename/__init__.py
, where there is this import flask
before it got the chance to install it.
The thing is, I need this import flask
in __init__.py
to create the db.
What would you recommend?
Thanks!
Chx
Upvotes: 3
Views: 7769
Reputation: 6375
I personally don't like python setup.py develop
, have you tried this?
% pip install -e .
Where the current directory is the directory with your setup.py
in it. It's similar to develop
but will install all required packages.
Upvotes: 2