Handle `RECORDS` file in `pip`
@@ -6,6 +6,7 @@ import json
import re
import zipfile
import platform
+from shutil import copyfile
from io import open
from sys import __stdout__
@@ -174,6 +175,10 @@ class TopLevelHandler(BaseHandler):
def handle_install(self, src, dest):
tltxtp = os.path.join(src, self.distinfo_name, "top_level.txt")
+ record = False
+ if not os.path.isfile(tltxtp):
+ record = True
+ tltxtp = os.path.join(src, self.distinfo_name, "RECORD")
files_installed = []
try:
@@ -185,9 +190,18 @@ class TopLevelHandler(BaseHandler):
with open(tltxtp, "r") as fin:
for pkg_name in fin:
- pure = pkg_name.replace("\r", "").replace("\n", "")
+ pure = pkg_name.replace("\r", "").replace("\n", "").split(",")[0]
sp = os.path.join(src, pure)
- if os.path.exists(sp):
+ if record:
+ p = os.path.join(dest, pure)
+
+ try:
+ os.makedirs(os.path.dirname(p))
+ except:
+ pass
+
+ copyfile(sp, p)
+ elif os.path.exists(sp):
p = self.copytree(pure, sp, dest, remove=True)
elif os.path.exists(sp + ".py"):
dp = os.path.join(dest, pure + ".py")
