Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
get the interpreter path from the build system
Signed-off-by: Filipe Laíns <lains@riseup.net>
  • Loading branch information
FFY00 committed Feb 24, 2024
commit 5b3fe211c602268b64ec6f6fc7a550729bf9bbdc
3 changes: 2 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform

install-details.json: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt $(srcdir)/Tools/build/generate_install_details_file.py
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate_install_details_file.py ./install-details.json
$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/build/generate_install_details_file.py ./install-details.json \
--executable $(BINDIR)/python3$(EXE)

# Create build directory and generate the sysconfig build-time data there.
# pybuilddir.txt contains the name of the build dir and is used for
Expand Down
10 changes: 4 additions & 6 deletions Tools/build/generate_install_details_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@
ConfigData = dict[str, SectionData]


def generic_info() -> ConfigData:
def generic_info(executable: str) -> ConfigData:
return {
'python': {
'version': sys.version.split(' ')[0],
'version_parts': {
field: getattr(sys.version_info, field)
for field in ('major', 'minor', 'micro', 'releaselevel', 'serial')
},
'executable': os.path.join(
sysconfig.get_path('scripts'),
os.path.basename(sys.executable),
),
'executable': executable,
'stdlib': sysconfig.get_path('stdlib'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This assumes that we're running in the target interpreter, yeah? So we need another way to generate this file for when we're cross-compiling (which is a normal part of the Windows build process).

Is there an easy way to have the script pick up all the makefile variables during a build without having to actually parse the makefile?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, but we can add a CLI option to specify the value, like we do for executable. This way you just give the script the value when you call it in the Makefile, or other build system.

I'd like to make this script as standalone as possible.

},
}
Expand All @@ -31,10 +28,11 @@ def generic_info() -> ConfigData:
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('output_path', metavar='FILE')
parser.add_argument('--executable', help='The executable path on the system.')

args = parser.parse_args()

config = generic_info()
config = generic_info(args.executable)

with open(args.output_path, 'w') as f:
json.dump(config, f)
Expand Down