Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #297 from 515hikaru/master
Browse files Browse the repository at this point in the history
Exclude `__pycache__` from tests in sdist
  • Loading branch information
orsinium committed Nov 12, 2019
2 parents 58337a1 + 5580398 commit 904b15e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions dephell/converters/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def dump(self, reqs, path: Path, project: RootDependency) -> None:
subdir=subdir,
module='/'.join(full_path.relative_to(project.package.path).parts),
)
tar.add(name=str(full_path), arcname=fpath, filter=self._set_uid_gid)
tar.add(name=str(full_path), arcname=fpath, filter=self._sanitize_tar)

self._write_additional_files(tar=tar, project=project, subdir=subdir)

Expand All @@ -132,20 +132,20 @@ def _write_additional_files(self, *, tar, project, subdir):
tar.add(
name=str(project.readme.path),
arcname=subdir + project.readme.path.name,
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)
if project.readme.markup != 'rst':
rst = project.readme.to_rst()
tar.add(
name=str(rst.path),
arcname=subdir + rst.path.name,
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)
elif (project.package.path / 'README.md').exists():
tar.add(
name=str(project.package.path / 'README.md'),
arcname=subdir + 'README.md',
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)

# write setup files
Expand All @@ -155,7 +155,7 @@ def _write_additional_files(self, *, tar, project, subdir):
tar.add(
name=str(path / fname),
arcname=subdir + fname,
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)

# write license files
Expand All @@ -167,7 +167,7 @@ def _write_additional_files(self, *, tar, project, subdir):
tar.add(
name=str(file_path),
arcname=subdir + file_path.name,
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)

# write tests
Expand All @@ -182,19 +182,21 @@ def _write_additional_files(self, *, tar, project, subdir):
tar.add(
name=str(tests_path),
arcname=subdir + tests_path.name,
filter=self._set_uid_gid,
filter=self._sanitize_tar,
)

def _write_content(self, tar, path: str, content) -> None:
content = content.encode('utf-8')
tar_info = TarInfo(path)
tar_info.size = len(content)
tar_info = self._set_uid_gid(tar_info)
tar_info = self._sanitize_tar(tar_info)
tar.addfile(tar_info, BytesIO(content))

# poetry/masonry/builders/sdist.py:clean_tarinfo
@staticmethod
def _set_uid_gid(tarinfo: TarInfo) -> TarInfo:
def _sanitize_tar(tarinfo: TarInfo) -> TarInfo or None:
if '__pycache__' in tarinfo.name:
return None
tarinfo.uid = tarinfo.gid = 0
tarinfo.uname = tarinfo.gname = ''

Expand Down

0 comments on commit 904b15e

Please sign in to comment.