Skip to content

Commit 6372e5a

Browse files
committed
Remove various subproject forge and tool configs from sdist
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent 72fc3b9 commit 6372e5a

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

common/software.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,33 @@ class Project(Software):
115115
anitya_id: int | None = None
116116
primary: bool = False
117117
remove_dirs: Iterable[str] = ()
118-
# overrides for default file removals
118+
# overrides for default dir/file removals
119+
keep_dirs: Iterable[str] = ()
119120
keep_files: Iterable[str] = ()
120121

122+
DIST_REMOVE_DIRNAMES = {
123+
'.github',
124+
'.gitlab',
125+
'.gitlab-ci',
126+
'.gitlab-ci.d',
127+
}
121128
DIST_REMOVE_FILENAMES = {
129+
'.appveyor.yml',
130+
'.cirrus.yml',
131+
'.clang-format',
132+
'.cmake-format.yaml',
133+
'.codecov.yaml',
134+
'.codespellrc',
135+
'.editorconfig',
136+
'.flake8',
137+
'.gitattributes',
138+
'.gitignore',
139+
'.gitlab-ci.yml',
140+
'.gitmodules',
141+
'.lcovrc',
142+
'.readthedocs.yaml',
143+
'.shellcheckrc',
144+
'.travis.yml',
122145
'CMakeLists.txt',
123146
'configure',
124147
'configure.ac',
@@ -227,7 +250,14 @@ def walkerr(e: OSError) -> None:
227250
return
228251
for subdir in self.remove_dirs:
229252
shutil.rmtree(projdir / subdir)
230-
for dirpath, _, filenames in projdir.walk(on_error=walkerr):
253+
for dirpath, dirnames, filenames in projdir.walk(on_error=walkerr):
254+
for dirname in dirnames:
255+
path = dirpath / dirname
256+
if path.relative_to(projdir).as_posix() in self.keep_dirs:
257+
continue
258+
if path.name in self.DIST_REMOVE_DIRNAMES:
259+
dirnames.remove(path.name)
260+
shutil.rmtree(path)
231261
for filename in filenames:
232262
path = dirpath / filename
233263
if path.relative_to(projdir).as_posix() in self.keep_files:
@@ -323,6 +353,7 @@ def _sqlite3_license(proj: Project) -> tuple[str, str]:
323353
display='glib',
324354
licenses=['COPYING'],
325355
remove_dirs=['gio/tests', 'glib/tests', 'gobject/tests', 'po'],
356+
keep_dirs=['.gitlab-ci'],
326357
keep_files=[
327358
'm4macros/glib-2.0.m4',
328359
'm4macros/glib-gettext.m4',

0 commit comments

Comments
 (0)