1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Use quoted-printable as the inner encoding.

This compresses a lot more efficiently (get-pip.py.gz is within 12% of tar czf).
This commit is contained in:
Gabriel 2013-04-16 09:25:29 +02:00
parent 18bbcf21a0
commit 25d47b9a14
2 changed files with 6 additions and 2 deletions

View file

@ -36,7 +36,7 @@ def pkg_to_mapping(name):
pkg = pkgname(name, toplevel, os.path.join(root, pyfile))
f = open(os.path.join(root, pyfile))
try:
name2src[pkg] = base64.encodestring(f.read())
name2src[pkg] = f.read().encode('quoted-printable')
finally:
f.close()
return name2src

View file

@ -3,6 +3,7 @@
sources = """
@SOURCES@"""
import codecs
import os
import sys
import base64
@ -10,6 +11,9 @@ import zlib
import tempfile
import shutil
# quoted-printable is poorly supported on Python 3,
# use the codecs module directly
quopri_decode = codecs.getdecoder('quopri_codec')
def unpack(sources):
temp_dir = tempfile.mkdtemp('-scratchdir', 'unpacker-')
@ -21,7 +25,7 @@ def unpack(sources):
os.makedirs(packagedir)
mod = open(os.path.join(packagedir, filepath[-1]), 'wb')
try:
mod.write(base64.decodestring(content.encode('ascii')))
mod.write(quopri_decode(content.encode('ascii'))[0])
finally:
mod.close()
return temp_dir