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

Fix tests on Python 3.13 & Windows #700

Merged
merged 3 commits into from
Oct 31, 2024
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
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