Repository: boto/boto

Issue:
Circular Import Error with boto.vendored.regions.regions
as part of using boto with CircleCI in context of deployment (using CodeDeploy) seeing the following error:

``` 
 File "/usr/local/lib/python2.7/dist-packages/boto/__init__.py", line 28, in <module>
    from boto.storage_uri import BucketStorageUri, FileStorageUri
  File "/usr/local/lib/python2.7/dist-packages/boto/storage_uri.py", line 27, in <module>
    from boto.s3.deletemarker import DeleteMarker
  File "/usr/local/lib/python2.7/dist-packages/boto/s3/__init__.py", line 26, in <module>
    from boto.regioninfo import RegionInfo, get_regions
  File "/usr/local/lib/python2.7/dist-packages/boto/regioninfo.py", line 28, in <module>
    from boto.endpoints import BotoEndpointResolver
  File "/usr/local/lib/python2.7/dist-packages/boto/endpoints.py", line 13, in <module>
    import boto.vendored.regions.regions as _regions
ImportError: No module named regions.regions
```

Trying to perform the above import in IPython manually reveals what I believe is a circular dependency import which is probably the core problem:

```
In [2]: from boto.vendored.regions import regions as _regions
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-6327378203c8> in <module>()
----> 1 from boto.vendored.regions import regions as _regions

/Users/adamhadani/.virtualenvs/boto-env/lib/python2.7/site-packages/boto/__init__.py in <module>()
     26 #
     27 from boto.pyami.config import Config, BotoConfigLocations
---> 28 from boto.storage_uri import BucketStorageUri, FileStorageUri
     29 import boto.plugin
     30 import datetime

/Users/adamhadani/.virtualenvs/boto-env/lib/python2.7/site-packages/boto/storage_uri.py in <module>()
     25 import sys
     26 import textwrap
---> 27 from boto.s3.deletemarker import DeleteMarker
     28 from boto.exception import BotoClientError
     29 from boto.exception import InvalidUriError

/Users/adamhadani/.virtualenvs/boto-env/lib/python2.7/site-packages/boto/s3/__init__.py in <module>()
     24 #
     25
---> 26 from boto.regioninfo import RegionInfo, get_regions
     27 from boto.regioninfo import connect
     28

/Users/adamhadani/.virtualenvs/boto-env/lib/python2.7/site-packages/boto/regioninfo.py in <module>()
     26 from boto.compat import json
     27 from boto.exception import BotoClientError
---> 28 from boto.endpoints import BotoEndpointResolver
     29 from boto.endpoints import StaticEndpointBuilder
     30

/Users/adamhadani/.virtualenvs/boto-env/lib/python2.7/site-packages/boto/endpoints.py in <module>()
     11 # ANY KIND, either express or implied. See the License for the specific
     12 # language governing permissions and limitations under the License.
---> 13 import boto.vendored.regions.regions as _regions
     14
     15
```


Discussion:
ping @JordonPhillips  I think above might be regression just introduced in the new release just tagged
taking a look
I'm not able to replicate on a fresh venv in any python version. Could you give me any more information about your setup? What exact import are you using that's failing?
@JordonPhillips I'm able to reliably reproduce this in a clean virtual environment on both my Mac as well as on our Linux based Jenkins instance.

Below has some light editing replacing my home directory name with `${HOME}`.

```
~ ➜ mkvirtualenv boto
New python executable in ${HOME}/.virtualenvs/boto/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating ${HOME}/.virtualenvs/boto/bin/predeactivate
virtualenvwrapper.user_scripts creating ${HOME}/.virtualenvs/boto/bin/postdeactivate
virtualenvwrapper.user_scripts creating ${HOME}/.virtualenvs/boto/bin/preactivate
virtualenvwrapper.user_scripts creating ${HOME}/.virtualenvs/boto/bin/postactivate
virtualenvwrapper.user_scripts creating ${HOME}/.virtualenvs/boto/bin/get_env_details

(boto) ~ ➜ pip install "boto >= 2.34.0"
Collecting boto>=2.34.0
  Using cached boto-2.46.0-py2.py3-none-any.whl
Installing collected packages: boto
Successfully installed boto-2.46.0

(boto) ~ ➜ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "${HOME}/.virtualenvs/boto/lib/python2.7/site-packages/boto/__init__.py", line 28, in <module>
    from boto.storage_uri import BucketStorageUri, FileStorageUri
  File "${HOME}/.virtualenvs/boto/lib/python2.7/site-packages/boto/storage_uri.py", line 27, in <module>
    from boto.s3.deletemarker import DeleteMarker
  File "${HOME}/.virtualenvs/boto/lib/python2.7/site-packages/boto/s3/__init__.py", line 26, in <module>
    from boto.regioninfo import RegionInfo, get_regions
  File "${HOME}/.virtualenvs/boto/lib/python2.7/site-packages/boto/regioninfo.py", line 28, in <module>
    from boto.endpoints import BotoEndpointResolver
  File "${HOME}/.virtualenvs/boto/lib/python2.7/site-packages/boto/endpoints.py", line 13, in <module>
    import boto.vendored.regions.regions as _regions
ImportError: No module named regions.regions
```
Got it to reproduce by installing from pip rather than directly from the git repo.
It's not a circular dependency issue, the relevant package just seems to have not been included in package we deployed for some reason. Looking into it
I think I see the issue. The added packages weren't included in the `setup.py` script.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -82,7 +82,7 @@ def readme():
                   "boto.cloudsearchdomain", "boto.kms",
                   "boto.awslambda", "boto.codedeploy", "boto.configservice",
                   "boto.cloudhsm", "boto.ec2containerservice",
-                  "boto.machinelearning"],
+                  "boto.machinelearning", "boto.vendored.regions"],
       package_data = {
           "boto.cacerts": ["cacerts.txt"],
           "boto": ["endpoints.json"],


Test patch: