Skip to content

Commit

Permalink
Ensure package name isn't unicode in Python2 distutils
Browse files Browse the repository at this point in the history
Problem encountered on Ubuntu 14.04

Fixes pypa#190

If people need to fix this without this patch, they have to wrap their package names in `str()` like so:

```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

setup(
    # ....
    package_dir=[
        str('package_name'),
    ]
)
```
  • Loading branch information
benjaoming committed May 27, 2016
1 parent 5675cdd commit fc676e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions setuptools/command/build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import distutils.errors
import itertools

from setuptools.extern.six import string_types
from setuptools.extern.six.moves import map, filter, filterfalse

try:
Expand Down Expand Up @@ -66,6 +67,10 @@ def __getattr__(self, attr):
return orig.build_py.__getattr__(self, attr)

def build_module(self, module, module_file, package):
# Ensure that package names are strings in case an ancient distutils
# library is called
if isinstance(package, string_types):
package = str(package)
outfile, copied = orig.build_py.build_module(self, module, module_file,
package)
if copied:
Expand Down

0 comments on commit fc676e1

Please sign in to comment.