Skip to content
Open
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: 5 additions & 0 deletions recipe/build_base.bat
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ if "%CONDA_BUILD_CROSS_COMPILATION%" == "1" (
%PYTHON% -Wi %PREFIX%\lib\python\compileall.py -f -q -x "bad_coding|badsyntax|py2_" %PREFIX%\lib\python
if errorlevel 1 exit 1

:: Install a PEP 739 build-details.json next to the stdlib, like on unix
%PYTHON% %RECIPE_DIR%\generate_build_details_win.py %SRC_DIR% %PREFIX%\lib\python\build-details.json
if errorlevel 1 exit 1
type %PREFIX%\lib\python\build-details.json

:: Ensure that scripts are generated
:: https://github.com/conda-forge/python-feedstock/issues/384
%PYTHON% %RECIPE_DIR%\fix_staged_scripts.py
Expand Down
58 changes: 58 additions & 0 deletions recipe/generate_build_details_win.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Generate a PEP 739 build-details.json for the conda Windows layout.

Uses upstream's PC/layout generator (which does not need to run the target
interpreter, so it also works when cross-compiling) and adjusts the paths
for conda's unix-like Windows layout, where the file is installed into the
stdlib directory (%PREFIX%\\lib\\python) just like on unix.

Usage: python generate_build_details_win.py SRC_DIR OUTPUT_FILE
"""

import json
import os
import sys
import types


def main():
src_dir, output = sys.argv[1:3]

# Make PC/layout/support/constants.py read the version from the sources
# rather than from the running interpreter.
os.environ["PYTHONINCLUDE"] = os.path.join(src_dir, "Include")
sys.path.insert(0, os.path.join(src_dir, "PC", "layout"))
from support.builddetails import get_builddetails

arch = {
"win-64": "amd64",
"win-32": "win32",
"win-arm64": "arm64",
}[os.environ["target_platform"]]

ns = types.SimpleNamespace(
include_builddetails_json=True,
include_freethreaded=os.environ.get("PY_FREETHREADING") == "yes",
debug=os.environ.get("PY_INTERP_DEBUG") == "yes",
include_dev=True,
arch=arch,
)
((_, (_, content)),) = list(get_builddetails(ns))
details = json.loads(content)

# The file lives in %PREFIX%\lib\python; all other paths are relative
# to base_prefix.
details["base_prefix"] = "../.."
# build_base.bat always installs python.exe (copied for debug and
# free-threaded builds), whereas e.g. python_d.exe is not always there.
details["base_interpreter"] = "./python.exe"
for key in ("dynamic", "dynamic_stableabi"):
details["libpython"][key] = "./" + details["libpython"][key]
details["c_api"]["headers"] = "./include/python"

with open(output, "w", encoding="utf-8") as f:
json.dump(details, f, indent=2)
f.write("\n")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set ver2 = '.'.join(version.split('.')[0:2]) %}
{% set ver2nd = ''.join(version.split('.')[0:2]) %}
{% set ver3nd = ''.join(version.split('.')[0:3]) %}
{% set build_number = 0 %}
{% set build_number = 1 %}

# this makes the linter happy
{% set channel_targets = channel_targets or 'conda-forge main' %}
Expand Down
Loading