summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/create.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-09-19 14:10:26 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-09-19 14:10:26 (GMT)
commitbecf1c58572f29d4f35f448194e3ef9c535e3be0 (patch)
tree9fdee1cd0c48cbf29829bd2a3bfa94f2214ddec6 /Lib/packaging/create.py
parent2496f331a75c9dd30ef8588ae86179131227163a (diff)
parent28df8de6af5f859a212af75d818df68fce5a9377 (diff)
downloadcpython-becf1c58572f29d4f35f448194e3ef9c535e3be0.zip
cpython-becf1c58572f29d4f35f448194e3ef9c535e3be0.tar.gz
cpython-becf1c58572f29d4f35f448194e3ef9c535e3be0.tar.bz2
Branch merge
Diffstat (limited to 'Lib/packaging/create.py')
-rw-r--r--Lib/packaging/create.py22
1 files changed, 5 insertions, 17 deletions
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
index ecabca0..34a8c82 100644
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -25,11 +25,11 @@ import sys
import glob
import shutil
import sysconfig
-import tokenize
from hashlib import md5
from textwrap import dedent
-from functools import cmp_to_key
+from tokenize import detect_encoding
from configparser import RawConfigParser
+
# importing this with an underscore as it should be replaced by the
# dict form or another structures for all purposes
from packaging._trove import all_classifiers as _CLASSIFIERS_LIST
@@ -112,7 +112,7 @@ def load_setup():
been loaded before, because we are monkey patching its setup function with
a particular one"""
with open("setup.py", "rb") as f:
- encoding, lines = tokenize.detect_encoding(f.readline)
+ encoding, lines = detect_encoding(f.readline)
with open("setup.py", encoding=encoding) as f:
imp.load_module("setup", f, "setup.py", (".py", "r", imp.PY_SOURCE))
@@ -370,21 +370,9 @@ class MainProgram:
dist.data_files = [('', dist.data_files)]
# add tokens in the destination paths
vars = {'distribution.name': data['name']}
- path_tokens = list(sysconfig.get_paths(vars=vars).items())
-
- # TODO replace this with a key function
- def length_comparison(x, y):
- len_x = len(x[1])
- len_y = len(y[1])
- if len_x == len_y:
- return 0
- elif len_x < len_y:
- return -1
- else:
- return 1
-
+ path_tokens = sysconfig.get_paths(vars=vars).items()
# sort tokens to use the longest one first
- path_tokens.sort(key=cmp_to_key(length_comparison))
+ path_tokens = sorted(path_tokens, key=lambda x: len(x[1]))
for dest, srcs in (dist.data_files or []):
dest = os.path.join(sys.prefix, dest)
dest = dest.replace(os.path.sep, '/')