schema-tool
schema-tool copied to clipboard
Installing via ``python setup.py install`` generates a broken schema console_script
I'm unable to correctly run the schema console script after installing via python setup.py install
.
(schema-tool)➜ schema-tool git:(master) ✗ schema Traceback (most recent call last): File "/Users/vincent.schumaker/.virtualenvs/schema-tool/bin/schema", line 9, in <module> load_entry_point('schema-tool==0.3.0', 'console_scripts', 'schema')() File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/pkg_resources.py", line 2431, in load_entry_point return ep.load() File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/pkg_resources.py", line 2147, in load ['__name__']) File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/schema_tool-0.3.0-py2.7.egg/schematool/schema.py", line 30, in <module> from command import CommandContext File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/schema_tool-0.3.0-py2.7.egg/schematool/command/__init__.py", line 1, in <module> from context import CommandContext File "/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/schema_tool-0.3.0-py2.7.egg/schematool/command/context.py", line 7, in <module> from db import MySQLDb, PostgresDb, MemoryDb, VerticaDb, HiveDb ImportError: No module named db
This seems to be related to an issue with the value of sys.path, which is listed below.
['/Users/vincent.schumaker/.virtualenvs/schema-tool/bin', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/schema_tool-0.3.0-py2.7.egg', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python27.zip', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-darwin', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-mac', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/vincent.schumaker/.virtualenvs/schema-tool/Extras/lib/python', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-tk', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-old', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages']
Running the script manually, from the root of the git source directory works correctly and produces the following sys.path.
['/Users/vincent.schumaker/Documents/vschumaker/code/schema-tool/schematool', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages/schema_tool-0.3.0-py2.7.egg', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python27.zip', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-darwin', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-mac', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/vincent.schumaker/.virtualenvs/schema-tool/Extras/lib/python', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-tk', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-old', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/vincent.schumaker/.virtualenvs/schema-tool/lib/python2.7/site-packages']
I suppose the issue is that the way imports are written relies on the fact that the current directory of the file being executed is implicitly added to sys.path; however, this won't work when the console_script that is installed via setuptools is used as an entry point.