Skip to content

Commit f453adb

Browse files
committed
ENH: do not include uncommitted changer in the sdist
Including uncommitted changes in the sdist was implemented in #58 after the discussion in #53. However, the current behavior for which uncommitted changes to files under version control are included but not other files, is an hard to justify surprising half measure. After careful analysis, it has been determined that none of the use cases for this feature is still valid. Removing it makes the implementation easier, and the behavior less surprising and easier to document an explain.
1 parent b431df3 commit f453adb

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

mesonpy/__init__.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -869,45 +869,13 @@ def sdist(self, directory: Path) -> pathlib.Path:
869869

870870
with tarfile.open(meson_dist_path, 'r:gz') as meson_dist, mesonpy._util.create_targz(sdist) as tar:
871871
for member in meson_dist.getmembers():
872-
# calculate the file path in the source directory
873-
assert member.name, member.name
874-
member_parts = member.name.split('/')
875-
if len(member_parts) <= 1:
876-
continue
877-
path = self._source_dir.joinpath(*member_parts[1:])
878-
879-
if not path.exists() and member.isfile():
880-
# File doesn't exists on the source directory but exists on
881-
# the Meson dist, so it is generated file, which we need to
882-
# include.
883-
# See https://mesonbuild.com/Reference-manual_builtin_meson.html#mesonadd_dist_script
884-
885-
# MESON_DIST_ROOT could have a different base name
886-
# than the actual sdist basename, so we need to rename here
872+
if member.isfile():
887873
file = meson_dist.extractfile(member.name)
888-
member.name = str(pathlib.Path(dist_name, *member_parts[1:]).as_posix())
874+
# rewrite the path to match the sdist distribution name
875+
member.name = '/'.join((dist_name, *member.name.split('/')[1:]))
889876
tar.addfile(member, file)
890877
continue
891878

892-
if not path.is_file():
893-
continue
894-
895-
info = tarfile.TarInfo(member.name)
896-
file_stat = os.stat(path)
897-
info.mtime = member.mtime
898-
info.size = file_stat.st_size
899-
info.mode = int(oct(file_stat.st_mode)[-3:], 8)
900-
901-
# rewrite the path if necessary, to match the sdist distribution name
902-
if dist_name != meson_dist_name:
903-
info.name = pathlib.Path(
904-
dist_name,
905-
path.relative_to(self._source_dir)
906-
).as_posix()
907-
908-
with path.open('rb') as f:
909-
tar.addfile(info, fileobj=f)
910-
911879
# add PKG-INFO to dist file to make it a sdist
912880
pkginfo_info = tarfile.TarInfo(f'{dist_name}/PKG-INFO')
913881
pkginfo_info.mtime = time.time() # type: ignore[assignment]

0 commit comments

Comments
 (0)