Skip to content

Commit

Permalink
Merge branch 'release/4.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Mar 30, 2016
2 parents ee034d0 + f637eb1 commit 6ed74c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ Changelog
- Fixed stray print statement printing skipped files (issue #411)
- Added option for forcing imports into a single bucket: `no_sections`
- Added option for new lines between import types (from, straight): `lines_between_sections`

### 4.2.5
- Fixed an issue that caused modules to inccorectly be matched as thirdparty when they simply had `src` in the leading path, even if they weren't withing $VIRTUALENV/src #414
2 changes: 1 addition & 1 deletion isort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
from . import settings
from .isort import SortImports

__version__ = "4.2.4"
__version__ = "4.2.5"
6 changes: 4 additions & 2 deletions isort/isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,20 @@ def place_module(self, module_name):

paths = PYTHONPATH
virtual_env = self.config.get('virtual_env') or os.environ.get('VIRTUAL_ENV')
virtual_env_src = False
if virtual_env:
paths += [path for path in glob('{0}/lib/python*/site-packages'.format(virtual_env))
if path not in paths]
paths += [path for path in glob('{0}/src/*'.format(virtual_env)) if os.path.isdir(path)]
virtual_env_src = '{0}/src/'.format(virtual_env)

for prefix in paths:
module_path = "/".join((prefix, module_name.replace(".", "/")))
package_path = "/".join((prefix, module_name.split(".")[0]))
if (os.path.exists(module_path + ".py") or os.path.exists(module_path + ".so") or
(os.path.exists(package_path) and os.path.isdir(package_path))):
if 'site-packages' in prefix or 'dist-packages' in prefix or 'src' in prefix:
if ('site-packages' in prefix or 'dist-packages' in prefix or
(virtual_env and virtual_env_src in prefix)):
return self.sections.THIRDPARTY
elif 'python2' in prefix.lower() or 'python3' in prefix.lower():
return self.sections.STDLIB
Expand Down Expand Up @@ -460,7 +463,6 @@ def _add_formatted_imports(self):
sort_ignore_case = self.config.get('force_alphabetical_sort_within_sections', False)
sections = itertools.chain(self.sections, self.config['forced_separate'])

sections = itertools.chain(self.sections, self.config['forced_separate'])
if self.config.get('no_sections', False):
self.imports['no_sections'] = {'straight': [], 'from': {}}
for section in sections:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def run(self):
readme = f.read()

setup(name='isort',
version='4.2.4',
version='4.2.5',
description='A Python utility / library to sort Python imports.',
long_description=readme,
author='Timothy Crosley',
author_email='timothy.crosley@gmail.com',
url='https://github.com/timothycrosley/isort',
download_url='https://github.com/timothycrosley/isort/archive/4.2.4.tar.gz',
download_url='https://github.com/timothycrosley/isort/archive/4.2.5.tar.gz',
license="MIT",
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 6ed74c5

Please sign in to comment.