Skip to content

Commit 8066677

Browse files
authored
Merge pull request #700 from pypa/win-py3.13-tests
Fix tests on Python 3.13 & Windows
2 parents 5c416e5 + 34445e9 commit 8066677

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- "*"
79
pull_request:
810

911
concurrency:

flit_core/flit_core/config.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import os
66
import os.path as osp
7+
from os.path import isabs
78
from pathlib import Path
89
import re
910

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

165166
normp = osp.normpath(data_dir)
166-
if osp.isabs(normp):
167+
if isabs_ish(normp):
167168
raise ConfigError(f"{toml_key} cannot be an absolute path")
168169
if normp.startswith('..' + os.sep):
169170
raise ConfigError(
@@ -233,9 +234,9 @@ def _check_glob_patterns(pats, clude):
233234

234235
normp = osp.normpath(p)
235236

236-
if osp.isabs(normp):
237+
if isabs_ish(normp):
237238
raise ConfigError(
238-
'{} pattern {!r} is an absolute path'.format(clude, p)
239+
f'{clude} pattern {p!r} is an absolute path'
239240
)
240241
if normp.startswith('..' + os.sep):
241242
raise ConfigError(
@@ -274,7 +275,7 @@ def add_scripts(self, scripts_dict):
274275

275276

276277
def description_from_file(rel_path: str, proj_dir: Path, guess_mimetype=True):
277-
if osp.isabs(rel_path):
278+
if isabs_ish(rel_path):
278279
raise ConfigError("Readme path must be relative")
279280

280281
desc_path = proj_dir / rel_path
@@ -708,3 +709,12 @@ def pep621_people(people, group_name='author') -> dict:
708709
if emails:
709710
res[group_name + '_email'] = ", ".join(emails)
710711
return res
712+
713+
714+
def isabs_ish(path):
715+
"""Like os.path.isabs(), but Windows paths from a drive root count as absolute
716+
717+
isabs() worked this way up to Python 3.12 (inclusive), and where we reject
718+
absolute paths, we also want to reject these odd halfway paths.
719+
"""
720+
return os.path.isabs(path) or path.startswith(('/', '\\'))

tests/test_find_python_executable.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from os.path import isabs, basename, dirname
2+
import os
23
import re
34
import sys
45
import venv
@@ -17,7 +18,8 @@ def test_self():
1718

1819

1920
def test_abs():
20-
assert find_python_executable("/usr/bin/python") == "/usr/bin/python"
21+
abs_path = "C:\\PythonXY\\python.exe" if os.name == 'nt' else '/usr/bin/python'
22+
assert find_python_executable(abs_path) == abs_path
2123

2224

2325
def test_find_in_path():

0 commit comments

Comments
 (0)