Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flit_core: Normalize sdist names according to PEP 625 #628

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions flit_core/flit_core/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ def add_setup_py(self, files_to_add, target_tarfile):

@property
def dir_name(self):
return '{}-{}'.format(self.metadata.name, self.metadata.version)
return common.normalize_dist_name(self.metadata.name, self.metadata.version)

def build(self, target_dir, gen_setup_py=True):
os.makedirs(str(target_dir), exist_ok=True)
target = target_dir / '{}-{}.tar.gz'.format(
self.metadata.name, self.metadata.version
)
target = target_dir / '{}.tar.gz'.format(self.dir_name)
source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH', '')
mtime = int(source_date_epoch) if source_date_epoch else None
gz = GzipFile(str(target), mode='wb', mtime=mtime)
Expand Down
9 changes: 9 additions & 0 deletions flit_core/flit_core/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ def test_data_dir():
files = builder.apply_includes_excludes(builder.select_files())

assert osp.join('data', 'share', 'man', 'man1', 'foo.1') in files


def test_pep625(tmp_path):
builder = sdist.SdistBuilder.from_ini_path(
samples_dir / 'normalization' / 'pyproject.toml'
)
path = builder.build(tmp_path)
assert path == tmp_path / 'my_python_module-0.0.1.tar.gz'
assert_isfile(path)