Skip to content

Commit 896105a

Browse files
committed
Write RECORD dist-info file
This file records the python files in the distribution.
1 parent d3a3a36 commit 896105a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

python/lsst/sconsUtils/builders.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
__all__ = ("filesToTag", "DoxygenBuilder")
55

6+
import csv
67
import fnmatch
78
import os
89
import re
@@ -739,6 +740,43 @@ def makeEntryPoints(target, source, env):
739740
self.Command(filename, [], self.Action(makeEntryPoints, strfunction=lambda *args: None))
740741
)
741742

743+
def makeRecordFile(target, source, env):
744+
# Write the RECORD file containing every python file in the package.
745+
# Do not attempt to write hashes and file sizes since these can
746+
# change if the package is not really installed into an EUPS tree.
747+
all_files = set()
748+
for root, dirs, files in os.walk(pythonDir):
749+
root = root.removeprefix(pythonDir)
750+
root = root.removeprefix("/")
751+
all_files.update({os.path.join(root, f) for f in files})
752+
# Ensure that RECORD itself is included in the list.
753+
record_path = target[0].abspath
754+
record_path = record_path.removeprefix(os.path.abspath(pythonDir)).removeprefix("/")
755+
all_files.add(record_path)
756+
757+
# Also force the other metadata files we are writing into the
758+
# file in case the order cannot be guaranteed.
759+
meta_files = ["INSTALLER", "METADATA"]
760+
if entryPoints:
761+
meta_files.append("entry_points.txt")
762+
dist_path, _ = os.path.split(record_path)
763+
for f in meta_files:
764+
all_files.add(os.path.join(dist_path, f))
765+
766+
# The RECORD file is nominally a CSV file.
767+
# Do not record file sizes or hashes.
768+
rows = [(f, "", "") for f in sorted(all_files)]
769+
with open(target[0].abspath, "w") as outFile:
770+
csv_writer = csv.writer(outFile)
771+
csv_writer.writerows(rows)
772+
773+
filename = os.path.join(distDir, "RECORD")
774+
# This action really needs to run after the previous pkginfo actions
775+
# so that INSTALLER, entry_points.txt and METADATA files are created.
776+
# Additionally, the RECORD target needs to run after "python" so that
777+
# shared libraries are created -- this is configured elsewhere.
778+
results.append(self.Command(filename, [], self.Action(makeRecordFile, strfunction=lambda *args: None)))
779+
742780
self.AlwaysBuild(results)
743781
return results
744782

python/lsst/sconsUtils/scripts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def finish(defaultTargets=DEFAULT_TARGETS, subDirList=None, ignoreRegex=None):
243243
state.env.Requires(state.targets["tests"], state.targets["version"])
244244
if "pkginfo" in state.targets:
245245
state.env.Default(state.targets["pkginfo"])
246+
state.env.Requires(state.targets["pkginfo"], state.targets["python"])
246247
state.env.Requires(state.targets["tests"], state.targets["pkginfo"])
247248
if "scripts" in state.targets:
248249
state.env.Default(state.targets["scripts"])

0 commit comments

Comments
 (0)