Skip to content
Draft
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
5 changes: 4 additions & 1 deletion conda_build/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def get_py_ver(config):
py = config.variant.get("python", get_default_variant(config)["python"])
if not hasattr(py, "split"):
py = py[0]
return ".".join(py.split(".")[:2])
ver = ".".join(py.split(".")[:2])
if config.variant.get("is_freethreading", False) and not ver.endswith("t"):
ver += "t"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good change. freethreading doesn't have anything to do with the version. Similar to other options like unicode support (back in 2.x days) and other implementations like pypy, we don't include the ABI in this field

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isuruf Do you have any pointers in where should this be fixed in the code?

return ver


def get_r_ver(config):
Expand Down
14 changes: 9 additions & 5 deletions conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,16 @@ def get_stdlib_dir(prefix, py_ver):
lib_dir = os.path.join(prefix, "Lib")
else:
lib_dir = os.path.join(prefix, "lib")
python_folder = glob(os.path.join(lib_dir, "python?.*"), recursive=True)
python_folder = sorted(filterfalse(islink, python_folder))
if python_folder:
lib_dir = os.path.join(lib_dir, python_folder[0])
exact = os.path.join(lib_dir, f"python{py_ver}")
if os.path.isdir(exact):
lib_dir = exact
else:
lib_dir = os.path.join(lib_dir, f"python{py_ver}")
python_folder = glob(os.path.join(lib_dir, "python?.*"), recursive=True)
python_folder = sorted(filterfalse(islink, python_folder))
if python_folder:
lib_dir = os.path.join(lib_dir, python_folder[0])
else:
lib_dir = os.path.join(lib_dir, f"python{py_ver}")
return lib_dir


Expand Down
19 changes: 19 additions & 0 deletions news/5990-fix-sp-dir-freethreading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fix SP_DIR resolving to wrong path for free-threading Python builds. (#5563) via (#5990)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
22 changes: 21 additions & 1 deletion tests/test_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import pytest

from conda_build.environ import create_env, os_vars
from conda_build.config import Config
from conda_build.environ import create_env, get_py_ver, os_vars

on_linux = platform.system() == "Linux"

Expand Down Expand Up @@ -50,3 +51,22 @@ def test_build_variable_defaults_to_architecture_based_distro(testing_metadata):

# Verify BUILD uses default cos6 or cos7 (not a custom cdt_name)
assert "conda_cos6" in env_vars["BUILD"] or "conda_cos7" in env_vars["BUILD"]


def test_get_py_ver_normal():
config = Config(variant={"python": "3.13"})
ver = get_py_ver(config)
assert ver == "3.13"
assert not ver.endswith("t")


def test_get_py_ver_freethreading():
config = Config(variant={"python": "3.13", "is_freethreading": True})
ver = get_py_ver(config)
assert ver == "3.13t"


def test_get_py_ver_freethreading_no_double_t():
config = Config(variant={"python": "3.13t", "is_freethreading": True})
ver = get_py_ver(config)
assert ver == "3.13t"
17 changes: 17 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@
from conda_build.exceptions import BuildLockError


@pytest.mark.skipif(utils.on_win, reason="unix-specific path logic")
def test_get_stdlib_dir_exact_match(testing_workdir):
lib_dir = os.path.join(testing_workdir, "lib")
for name in ("python3.13t", "python3.13"):
(Path(lib_dir) / name).mkdir(parents=True)
result = utils.get_stdlib_dir(testing_workdir, "3.13t")
assert result == os.path.join(lib_dir, "python3.13t")


@pytest.mark.skipif(utils.on_win, reason="unix-specific path logic")
def test_get_stdlib_dir_fallback(testing_workdir):
lib_dir = os.path.join(testing_workdir, "lib")
os.makedirs(lib_dir)
result = utils.get_stdlib_dir(testing_workdir, "3.13t")
assert result == os.path.join(lib_dir, "python3.13t")


@pytest.mark.skipif(
utils.on_win, reason="only unix has python version in site-packages path"
)
Expand Down
Loading