Skip to content

Instantly share code, notes, and snippets.

@nailor
Last active August 29, 2015 14:23
Show Gist options
  • Save nailor/7f4ddb3a76c325b5bab5 to your computer and use it in GitHub Desktop.
Save nailor/7f4ddb3a76c325b5bab5 to your computer and use it in GitHub Desktop.
[~/tmp/ppathtest]$ mkdir bar
[~/tmp/ppathtest]$ mkdir foo/package
[~/tmp/ppathtest]$ mkdir bar/package
[~/tmp/ppathtest]$ echo '__import__("pkg_resources").declare_namespace(__name__)' > bar/package/__init__.py
[~/tmp/ppathtest]$ echo '__import__("pkg_resources").declare_namespace(__name__)' > foo/package/__init__.py
[~/tmp/ppathtest]$ touch foo/package/herp.py
[~/tmp/ppathtest]$ touch bar/package/herp.py
[~/tmp/ppathtest]$ tree
.
├── bar
│   └── package
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── herp.py
│   └── herp.pyc
└── foo
└── package
├── __init__.py
├── __init__.pyc
├── herp.py
└── herp.pyc
[~/tmp/ppathtest]$ PYTHONPATH=bar:foo python2.6 -c 'from package import herp; print herp.__file__'
/Users/jyrki/tmp/ppathtest/bar/package/herp.py
[~/tmp/ppathtest]$ PYTHONPATH=bar:foo python2.7 -c 'from package import herp; print herp.__file__'
/Users/jyrki/tmp/ppathtest/foo/package/herp.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment