Skip to content

Commit

Permalink
Merge pull request #700 from pypa/win-py3.13-tests
Browse files Browse the repository at this point in the history
Fix tests on Python 3.13 & Windows
  • Loading branch information
takluyver authored Oct 31, 2024
2 parents 5c416e5 + 34445e9 commit 8066677
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
tags:
- "*"
pull_request:

concurrency:
Expand Down
18 changes: 14 additions & 4 deletions flit_core/flit_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import os.path as osp
from os.path import isabs
from pathlib import Path
import re

Expand Down Expand Up @@ -163,7 +164,7 @@ def prep_toml_config(d, path):
raise ConfigError(f"{toml_key} must be a string")

normp = osp.normpath(data_dir)
if osp.isabs(normp):
if isabs_ish(normp):
raise ConfigError(f"{toml_key} cannot be an absolute path")
if normp.startswith('..' + os.sep):
raise ConfigError(
Expand Down Expand Up @@ -233,9 +234,9 @@ def _check_glob_patterns(pats, clude):

normp = osp.normpath(p)

if osp.isabs(normp):
if isabs_ish(normp):
raise ConfigError(
'{} pattern {!r} is an absolute path'.format(clude, p)
f'{clude} pattern {p!r} is an absolute path'
)
if normp.startswith('..' + os.sep):
raise ConfigError(
Expand Down Expand Up @@ -274,7 +275,7 @@ def add_scripts(self, scripts_dict):


def description_from_file(rel_path: str, proj_dir: Path, guess_mimetype=True):
if osp.isabs(rel_path):
if isabs_ish(rel_path):
raise ConfigError("Readme path must be relative")

desc_path = proj_dir / rel_path
Expand Down Expand Up @@ -708,3 +709,12 @@ def pep621_people(people, group_name='author') -> dict:
if emails:
res[group_name + '_email'] = ", ".join(emails)
return res


def isabs_ish(path):
"""Like os.path.isabs(), but Windows paths from a drive root count as absolute
isabs() worked this way up to Python 3.12 (inclusive), and where we reject
absolute paths, we also want to reject these odd halfway paths.
"""
return os.path.isabs(path) or path.startswith(('/', '\\'))
4 changes: 3 additions & 1 deletion tests/test_find_python_executable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os.path import isabs, basename, dirname
import os
import re
import sys
import venv
Expand All @@ -17,7 +18,8 @@ def test_self():


def test_abs():
assert find_python_executable("/usr/bin/python") == "/usr/bin/python"
abs_path = "C:\\PythonXY\\python.exe" if os.name == 'nt' else '/usr/bin/python'
assert find_python_executable(abs_path) == abs_path


def test_find_in_path():
Expand Down

0 comments on commit 8066677

Please sign in to comment.