{"action":"closed","issue":{"url":"https://api.github.com/repos/pypa/pip/issues/3256","labels_url":"https://api.github.com/repos/pypa/pip/issues/3256/labels{/name}","comments_url":"https://api.github.com/repos/pypa/pip/issues/3256/comments","events_url":"https://api.github.com/repos/pypa/pip/issues/3256/events","html_url":"https://github.com/pypa/pip/issues/3256","id":117964635,"number":3256,"title":"pip install with and without \"-e\" option changes package import behavior","user":{"login":"roopeshvaddepally","id":126345,"avatar_url":"https://avatars.githubusercontent.com/u/126345?v=3","gravatar_id":"","url":"https://api.github.com/users/roopeshvaddepally","html_url":"https://github.com/roopeshvaddepally","followers_url":"https://api.github.com/users/roopeshvaddepally/followers","following_url":"https://api.github.com/users/roopeshvaddepally/following{/other_user}","gists_url":"https://api.github.com/users/roopeshvaddepally/gists{/gist_id}","starred_url":"https://api.github.com/users/roopeshvaddepally/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roopeshvaddepally/subscriptions","organizations_url":"https://api.github.com/users/roopeshvaddepally/orgs","repos_url":"https://api.github.com/users/roopeshvaddepally/repos","events_url":"https://api.github.com/users/roopeshvaddepally/events{/privacy}","received_events_url":"https://api.github.com/users/roopeshvaddepally/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-20T04:46:47Z","updated_at":"2015-11-20T05:19:29Z","closed_at":"2015-11-20T05:19:29Z","body":"When multiple modules imported from different directories to form a package, import behavior changes with \"-e\" option when installed with  \"pip install\" command.\r\n\r\nIgnore the way it's organized (I'm packaging an existing library).\r\n\r\npip install -e does not recognize the `package_dir` package names when installed, but pip install does.\r\n\r\n\r\n### Setup the Python Package and add setup.py\r\n\t(testpackages)19:55:01 [rvaddepally@system-tc8 ~]\r\n\t> which python\r\n\t~/.pyenv/versions/testpackages/bin/python\r\n\t(testpackages)19:55:07 [rvaddepally@system-tc8 ~]\r\n\t> python --version\r\n\tPython 3.4.3\r\n\t> mkdir !$\r\n\tmkdir testpack\r\n\r\n\t(testpackages)19:57:56 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> mkdir -p src/pack_a/mod_a src/pack_a/mod_b src/dir_x/pack_b/mod_x src/dir_x/pack_b/mod_y\r\n\t(testpackages)20:00:27 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> tree .\r\n\t.\r\n\t└── src\r\n\t    ├── dir_x\r\n\t    │   └── pack_b\r\n\t    │       ├── mod_x\r\n\t    │       └── mod_y\r\n\t    └── pack_a\r\n\t        ├── mod_a\r\n\t        └── mod_b\r\n\r\n\t8 directories, 0 files\r\n\r\n\t(testpackages)20:00:30 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> touch src/dir_x/pack_b/__init__.py src/dir_x/pack_b/mod_x/__init__.py src/dir_x/pack_b/mod_y/__init__.py src/pack_a/__init__.py src/pack_a/mod_a/__init__.py src/pack_a/mod_b/__init__.py\r\n\t(testpackages)20:16:28 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> tree .\r\n\t.\r\n\t├── setup.py\r\n\t└── src\r\n\t    ├── dir_x\r\n\t    │   └── pack_b\r\n\t    │       ├── __init__.py\r\n\t    │       ├── mod_x\r\n\t    │       │   └── __init__.py\r\n\t    │       └── mod_y\r\n\t    │           └── __init__.py\r\n\t    └── pack_a\r\n\t        ├── __init__.py\r\n\t        ├── mod_a\r\n\t        │   └── __init__.py\r\n\t        └── mod_b\r\n\t            └── __init__.py\r\n\r\n\t8 directories, 7 files\r\n\r\n\r\n\t# add this to setup.py\r\n\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n\tfrom setuptools import setup, find_packages\r\n\r\n\r\n\tmy_packages = (find_packages('src', include=['pack_a*']) +\r\n\t               find_packages('src/dir_x', include=['pack_b*']))\r\n\r\n\tsetup(\r\n\t    name='testpack',\r\n\t    version='0.0.1',\r\n\t    packages=my_packages,\r\n\t    package_dir={\r\n\t        'pack_a': 'src/pack_a',\r\n\t        'pack_b': 'src/dir_x/pack_b',\r\n\t    },\r\n\t    install_requires=[],\r\n\t    author='my name',\r\n\t    description='',\r\n\t    license='XYZ',\r\n\t)\r\n\t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r\n\r\n### Verify package is not installed\r\n\t(testpackages)20:23:08 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> pip freeze\r\n\tdecorator==4.0.4\r\n\tipython==4.0.0\r\n\tipython-genutils==0.1.0\r\n\tpath.py==8.1.2\r\n\tpexpect==4.0.1\r\n\tpickleshare==0.5\r\n\tptyprocess==0.5\r\n\tsimplegeneric==0.8.1\r\n\ttraitlets==4.0.0\r\n\twheel==0.24.0\r\n\t(testpackages)20:23:13 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c \"import testpack\"\r\n\tTraceback (most recent call last):\r\n\t  File \"<string>\", line 1, in <module>\r\n\tImportError: No module named 'testpack'\r\n\r\n### `pip install` the package and verify modules are available\r\n\t(testpackages)20:24:02 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> pip install .\r\n\tProcessing /auto/home.nas01a/rvaddepally/src/testpack\r\n\tInstalling collected packages: testpack\r\n\t  Running setup.py install for testpack\r\n\tSuccessfully installed testpack-0.0.1\r\n\r\n\t(testpackages)20:25:01 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from pack_a import mod_a, mod_b'\r\n\t(testpackages)20:25:43 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from pack_b import mod_x, mod_y'\r\n\t(testpackages)20:26:00 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from pack_b import mod_z'\r\n\tTraceback (most recent call last):\r\n\t  File \"<string>\", line 1, in <module>\r\n\tImportError: cannot import name 'mod_z'\r\n\r\n### Uninstall \r\n\t> pip uninstall testpack\r\n\tUninstalling testpack-0.0.1:\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/mod_a/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/mod_a/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/mod_b/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_a/mod_b/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/mod_x/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/mod_x/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/mod_y/__init__.py\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/pack_b/mod_y/__pycache__/__init__.cpython-34.pyc\r\n\t  /auto/home.nas01a/rvaddepally/.pyenv/versions/testpackages/lib/python3.4/site-packages/testpack-0.0.1-py3.4.egg-info\r\n\tProceed (y/n)? y\r\n\t  Successfully uninstalled testpack-0.0.1\r\n\r\n\r\n### `pip install -e` the package and verify modules are available, but not with pack_a and pack_b package names\r\n\t(testpackages)20:27:04 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> pip install -e .\r\n\tObtaining file:///auto/home.nas01a/rvaddepally/src/testpack\r\n\tInstalling collected packages: testpack\r\n\t  Running setup.py develop for testpack\r\n\tSuccessfully installed testpack\r\n\r\n\r\n\t(testpackages)20:28:26 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from pack_a import mod_a, mod_b'\r\n\tTraceback (most recent call last):\r\n\t  File \"<string>\", line 1, in <module>\r\n\tImportError: No module named 'pack_a'\r\n\t\r\n\t(testpackages)20:28:33 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from src.pack_a import mod_a, mod_b'\r\n\t\r\n\t(testpackages)20:28:43 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from pack_b import mod_x, mod_y'\r\n\tTraceback (most recent call last):\r\n\t  File \"<string>\", line 1, in <module>\r\n\tImportError: No module named 'pack_b'\r\n\t\r\n\t(testpackages)20:28:55 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from src.dir_x.pack_b import mod_x, mod_y'\r\n\t\r\n\t(testpackages)20:29:18 [rvaddepally@system-tc8 ~/src/testpack]\r\n\t> python -c 'from src.dir_x.pack_b import mod_z'\r\n\tTraceback (most recent call last):\r\n\t  File \"<string>\", line 1, in <module>\r\n\tImportError: cannot import name 'mod_z'\r\n"}}