Skip to content

Commit

Permalink
Use os.path.normpath
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Feb 20, 2025
1 parent 0f8482a commit 5f5982b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,19 @@ def read_pep621_metadata(proj, path) -> LoadedConfig:
raise ConfigError(
"[project.license] should specify file or text, not both"
)
license_f = license_tbl['file']
license_f = osp.normpath(license_tbl['file'])
if isabs_ish(license_f):
raise ConfigError(
f"License file path ({license_f}) cannot be an absolute path"
f"License file path ({license_tbl['file']}) cannot be an absolute path"
)
if ".." in license_f:
if license_f.startswith('..' + os.sep):
raise ConfigError(
f"License file path ({license_f}) cannot contain '..'"
f"License file path ({license_tbl['file']}) cannot contain '..'"
)
if not (path.parent / license_f).is_file():
raise ConfigError(f"License file {license_f} does not exist")
license_p = path.parent / license_f
if not license_p.is_file():
raise ConfigError(f"License file {license_tbl['file']} does not exist")

Check warning on line 617 in flit_core/flit_core/config.py

View check run for this annotation

Codecov / codecov/patch

flit_core/flit_core/config.py#L617

Added line #L617 was not covered by tests
license_f = str(license_p.relative_to(path.parent)).replace(osp.sep, "/")
license_files.add(license_f)
elif 'text' in license_tbl:
pass
Expand Down

0 comments on commit 5f5982b

Please sign in to comment.