Skip to content

Commit

Permalink
build: Integrate venvlauncher build/installation into the Makefile
Browse files Browse the repository at this point in the history
This is required for venv creation on Windows.
Ideally this would use the venv specific launcher (PC/launcher.c),
but a copy of main binary seems to work as well for now.
  • Loading branch information
lazka committed Aug 25, 2023
1 parent c6ef700 commit d1d9c27
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ BINLIBDEST= @BINLIBDEST@
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION)
CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
VENVLAUNCHERDIR= $(BINLIBDEST)/venv/scripts/nt

# Symbols used for using shared libraries
SHLIB_SUFFIX= @SHLIB_SUFFIX@
Expand Down Expand Up @@ -295,6 +296,8 @@ LIBOBJS= @LIBOBJS@
PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
BUILDPYTHONW= pythonw$(BUILDEXE)
BUILDVENVLAUNCHER= venvlauncher$(BUILDEXE)
BUILDVENVWLAUNCHER= venvwlauncher$(BUILDEXE)

HOSTRUNNER= @HOSTRUNNER@

Expand Down Expand Up @@ -597,7 +600,7 @@ LIBEXPAT_HEADERS= \

# Default target
all: @DEF_MAKE_ALL_RULE@
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) platform oldsharedmods sharedmods \
build_all: check-clean-src $(BUILDPYTHON) $(BUILDPYTHONW) $(BUILDVENVLAUNCHER) $(BUILDVENVWLAUNCHER) platform oldsharedmods sharedmods \
gdbhooks Programs/_testembed python-config
build_wasm: check-clean-src $(BUILDPYTHON) platform oldsharedmods python-config

Expand Down Expand Up @@ -729,6 +732,14 @@ $(BUILDPYTHONW): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) pythonw
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) python_exe.o
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -municode -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS) python_exe.o

# FIXME: build these from PC/launcher.c instead
$(BUILDVENVLAUNCHER): $(BUILDPYTHON)
cp $(BUILDPYTHON) $(BUILDVENVLAUNCHER)

# FIXME: build these from PC/launcher.c instead
$(BUILDVENVWLAUNCHER): $(BUILDPYTHONW)
cp $(BUILDPYTHONW) $(BUILDVENVWLAUNCHER)

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

Expand Down Expand Up @@ -1821,7 +1832,7 @@ $(DESTSHARED):
# Install the interpreter with $(VERSION) affixed
# This goes into $(exec_prefix)
altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
@for i in $(BINDIR) $(LIBDIR); \
@for i in $(BINDIR) $(LIBDIR) $(VENVLAUNCHERDIR); \
do \
if test ! -d $(DESTDIR)$$i; then \
echo "Creating directory $$i"; \
Expand All @@ -1832,6 +1843,8 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
if test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
$(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(BINDIR)/python3w$(EXE); \
$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(VENVLAUNCHERDIR)/python$(EXE); \
$(INSTALL_PROGRAM) $(BUILDPYTHONW) $(DESTDIR)$(VENVLAUNCHERDIR)/pythonw$(EXE); \
else \
$(INSTALL_PROGRAM) $(STRIPFLAG) Mac/pythonw $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE); \
fi
Expand Down

0 comments on commit d1d9c27

Please sign in to comment.