Skip to content
Open
10 changes: 6 additions & 4 deletions Lib/test/test_build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,19 @@ def test_implementation(self):
)


@unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now')
@unittest.skipIf(is_wasm32, 'Feature not available on WebAssembly builds')
class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase):
"""Test CPython's install details file implementation."""

@property
def location(self):
if sysconfig.is_python_build():
projectdir = sysconfig.get_config_var('projectbase')
with open(os.path.join(projectdir, 'pybuilddir.txt')) as f:
dirname = os.path.join(projectdir, f.read())
if sys.platform == 'win32':
dirname = sysconfig.get_config_var('BINDIR')
else:
projectdir = sysconfig.get_config_var('projectbase')
with open(os.path.join(projectdir, 'pybuilddir.txt')) as f:
dirname = os.path.join(projectdir, f.read())
else:
dirname = sysconfig.get_path('stdlib')
return os.path.join(dirname, 'build-details.json')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :pep:`739` :file:`build-details.json` file is now generated and
installed on Windows.
Patch by Adam Turner.
7 changes: 7 additions & 0 deletions PCbuild/python.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@
<Message Text="Generating $(OutDir)pybuilddir.txt" />
<WriteLinesToFile File="$(OutDir)pybuilddir.txt" Lines="%0D%0A" Overwrite="true" />
</Target>
<Target Name="GenerateBuildDetailsJSON" AfterTargets="Link">
<Message Text="Generating $(OutDir)build-details.json" />
<WriteLinesToFile File="$(OutDir)build-details.json" Lines="%0D%0A" Overwrite="true" />
<Exec Command='setlocal
set PYTHONPATH=$(PySourcePath)Lib
Comment on lines +131 to +132
Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure if these bits are needed, I copied them from the entry slightly further down.

"$(OutDir)$(PyExeName)$(PyDebugExt).exe" "$(PySourcePath)Tools\build\generate-build-details.py" "$(OutDir)build-details.json"' ContinueOnError="true" />
</Target>
<Target Name="ValidateUcrtbase" AfterTargets="AfterBuild" Condition="$(Configuration) != 'PGInstrument' and $(Platform) != 'ARM' and $(Platform) != 'ARM64'">
<PropertyGroup>
<UcrtName>ucrtbase</UcrtName>
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -735,4 +735,7 @@
<Target Name="_DeletePyBuildDirTxt" BeforeTargets="PrepareForBuild">
<Delete Files="$(OutDir)pybuilddir.txt" />
</Target>
<Target Name="_DeleteBuildDetailsJson" BeforeTargets="PrepareForBuild">
<Delete Files="$(OutDir)build-details.json" />
</Target>
</Project>
5 changes: 4 additions & 1 deletion Tools/build/generate-build-details.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def generate_data(schema_version: str) -> collections.defaultdict[str, Any]:
if '_multiarch' in data['implementation']:
data['implementation']['_multiarch'] = sysconfig.get_config_var('MULTIARCH')

data['abi']['flags'] = list(sys.abiflags)
if sys.platform != 'win32':
data['abi']['flags'] = list(sys.abiflags)
else:
data['abi']['flags'] = []

data['suffixes']['source'] = importlib.machinery.SOURCE_SUFFIXES
data['suffixes']['bytecode'] = importlib.machinery.BYTECODE_SUFFIXES
Expand Down
Loading