The following commands will remove your make altinstall
-ed python:
rm -f /usr/local/bin/python2.7
rm -f /usr/local/bin/pip2.7
rm -f /usr/local/bin/pydoc
rm -rf /usr/local/bin/include/python2.7
rm -f /usr/local/lib/libpython2.7.a
rm -rf /usr/local/lib/python2.7
You might also have to do
rm -f /usr/local/share/man/python2.7.1
rm -rf /usr/local/lib/pkgconfig
rm -f /usr/local/bin/idle
rm -f /usr/local/bin/easy_install-2.7
Although make altinstall
has served me well if the "system python" has a different major.minor number from the one you install, it doesn't work that well if only the micro number (the third position) differs. That number is excluded from the installed binary, and you end up with two versions pythonX.Y. This was always a problem but once distributions started shipping with system utilities based on 2.7.X this problem has been more severe as 2.7 is supposed to be the last of the Python2 series.
IMO the best approach to solve this problem is to prevent it from becoming one: configure python to install in a directory not used by any other python. On my system they go under /opt/python/X.Y.Z
.
To use any of the Pythons installed there you use [virualenv][1]
to make a new environment:
virtualenv --python=/opt/python/2.7.9/bin/python2.7 venv
source venv/bin/activate
or use [virtualenvwrapper][2]
. I have some aliases for the latest versions in the series I work with.
If you are using tox
for testing against multiple versions (you should) the following alias will help it find the various version:
alias tox='PATH=/opt/python/2.7.9/bin:/opt/python/2.6.9/bin:/opt/python/3.4.3/bin:/opt/python/3.3.6/bin:/opt/python/3.5-dev/bin:$PATH tox'
(these are currently the latest versions, I use a slightly different setup by maintaining links from /opt/python/2.7
to the latest /opt/python/2.7.9
, and for the other minor numbers as well, within the process for downloading, building and installing a new python version)
These installs are never used directly. They are always used as the basis for virtualenv
environments only, hence I don't care that they are not in my normal PATH.
You need to also link start up fragments like crt1.o
and others if you want to call libc functions. The linking process can be very complicated, so you'd better use gcc
for that.
On amd64 Ubuntu, you can:
sudo apt-get install gcc-multilib
gcc -m32 -o test test.o
You can see files and commands for the link by adding -v
option.
Best Answer
It depends on the kernel and on the type of executable. It doesn't depend on how the executable was started or installed.
On Linux:
For native executables (i.e. binaries containing machine code, executed directly by the kernel), an executable cannot be modified while it's running.
It is possible to remove the executable (i.e. unlink it) and create a new one at the same path. Like any other case where a file is removed while it's still open, removing the executable doesn't affect the running process, and doesn't actually remove it from the disk until the file is no longer in use, i.e. until all running instances of the program exit.
For scripts (beginning with
#!
), the script file can be modified while the program is running. Whether that affects the program depends on how the interpreter reads the script. If it reads the whole script into its own memory before starting to execute then the execution won't be affected. If the interpreter reads the script on demand then the execution may be affected; some implementations ofsh
do that.Many other Unix systems behave this way, but not all. IIRC older versions of Solaris allow modifying a native executable, which generally causes it to crash. A few Unix variants, including HP/UX, don't even allow removing a native executable that's currently running.
Most software installation programs take care to remove an existing executable before putting a new one in place, as opposed to overwriting the existing binary. E.g. do
rather than just
cp target /bin
. Theinstall
shell command does things this way. This is not ideal though, because if someone tries to execute/bin/target
while thecp
process is running, they'll get a corrupt program. It's better to copy the file to a temporary name and then rename it to the final name. Renaming a file (i.e. moving it inside the same directory, or more generally moving it inside the same filesystem) removes the prior target file if one exists. This is howdpkg
works, for example.