When building python from source, you must specify a prefix which identifies the directory to install into:
./configure --prefix="/etc/py27/"
make
sudo make altinstall
We now have python installed in /etc/py27/
Now, ignoring environment variables, which we'll manage in a startup script, let's say we didn't want to build from source again, and wanted to relocate the Python runtime files.
I noticed that /etc/py27
path is hard coded as follows:
[/etc/py27mv]$ grep -iRI '/etc/py27' *
bin/python2.7-config:#!/etc/py27/bin/python2.7
bin/pydoc:#!/etc/py27/bin/python2.7
bin/smtpd.py:#!/etc/py27/bin/python2.7
bin/2to3:#!/etc/py27/bin/python2.7
bin/idle:#!/etc/py27/bin/python2.7
lib/python2.7/config/Makefile:prefix= /etc/py27
lib/python2.7/config/Makefile:CONFIG_ARGS= '--prefix=/etc/py27/'
lib/python2.7/_sysconfigdata.py: 'BINDIR': '/etc/py27/bin',
lib/python2.7/_sysconfigdata.py: 'BINLIBDEST': '/etc/py27/lib/python2.7',
lib/python2.7/_sysconfigdata.py: 'CONFIG_ARGS': "'--prefix=/etc/py27/'",
lib/python2.7/_sysconfigdata.py: 'CONFINCLUDEDIR': '/etc/py27/include',
lib/python2.7/_sysconfigdata.py: 'CONFINCLUDEPY': '/etc/py27/include/python2.7',
lib/python2.7/_sysconfigdata.py: 'DESTDIRS': '/etc/py27 /etc/py27/lib /etc/py27/lib/python2.7 /etc/py27/lib/python2.7/lib-dynload',
lib/python2.7/_sysconfigdata.py: 'DESTLIB': '/etc/py27/lib/python2.7',
lib/python2.7/_sysconfigdata.py: 'DESTSHARED': '/etc/py27/lib/python2.7/lib-dynload',
lib/python2.7/_sysconfigdata.py: 'INCLDIRSTOMAKE': '/etc/py27/include /etc/py27/include /etc/py27/include/python2.7 /etc/py27/include/python2.7',
lib/python2.7/_sysconfigdata.py: 'INCLUDEDIR': '/etc/py27/include',
lib/python2.7/_sysconfigdata.py: 'INCLUDEPY': '/etc/py27/include/python2.7',
lib/python2.7/_sysconfigdata.py: 'LIBDEST': '/etc/py27/lib/python2.7',
lib/python2.7/_sysconfigdata.py: 'LIBDIR': '/etc/py27/lib',
lib/python2.7/_sysconfigdata.py: 'LIBP': '/etc/py27/lib/python2.7',
lib/python2.7/_sysconfigdata.py: 'LIBPC': '/etc/py27/lib/pkgconfig',
lib/python2.7/_sysconfigdata.py: 'LIBPL': '/etc/py27/lib/python2.7/config',
lib/python2.7/_sysconfigdata.py: 'MACHDESTLIB': '/etc/py27/lib/python2.7',
lib/python2.7/_sysconfigdata.py: 'MANDIR': '/etc/py27/share/man',
lib/python2.7/_sysconfigdata.py: 'SCRIPTDIR': '/etc/py27/lib',
lib/python2.7/_sysconfigdata.py: 'datarootdir': '/etc/py27/share',
lib/python2.7/_sysconfigdata.py: 'exec_prefix': '/etc/py27',
lib/python2.7/_sysconfigdata.py: 'prefix': '/etc/py27',
lib/pkgconfig/python-2.7.pc:prefix=/etc/py27
If each of these /etc/py27
references are replaced with the new location for these files, have we effectively moved the python runtime? Are there any other references, in the binaries perhaps which would necessitate building from source as the only option?