Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amend the python build to create executable linked to shared library #16

Merged
merged 1 commit into from
Feb 13, 2019

Conversation

ajorpheus
Copy link
Contributor

This commit fixes the issue that the python executable built requires
specifiying the LD_LIBRARY_PATH to load the correct library versions.

This issue is seen by comparing the output of python -V with
LD_LIBRARY_PATH=/usr/local/lib python -V . The former returns an
incorrect version (2.7.5) whereas the latter return the correct version
(2.7.15).

The default prefix when building python from source is /usr/local.
However the executable built loads the shared libraries from /lib64
(symlinked to /usr/lib64) which ends up loading the (incorrect) system
libpython2.7.so instead of loading it from the one that is built in
/usr/local/lib

The libraries being loaded by the executable are visible by executing:
For the correctly built exectuable it is :

[root@90fbc9dd6cfa /]# ldd /usr/local/bin/python
	libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007fedc6348000)

whereas for the current version (before this commit) the so is loaded
from /lib64 (-> /usr/lib64)

The fix is to either:

  1. Specify the library path like so before invoking the python
    exectuable:
    LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/python -V

OR,

  1. Specify the library path at compile time using LD_RUN_PATH (as done
    in this commit) so that it does not need to be specified at runtime and
    does not require alterations to existing Jenkinsfile

@ajorpheus
Copy link
Contributor Author

Do not merge yet

This commit fixes the issue that the python executable built requires
specifiying the LD_LIBRARY_PATH to load the correct library versions.

Replacing `altinstall` with `install` ensures that the python binary is
built in the default prefix (/usr/local/bin) and since that has
precedence on the PATH, this allows existing Jenkinsfile to use
`python` without specifying the full path and still get the expected
version of python.

Currently, with altinstall, a python executable is not built in
/usr/local/bin and `python` then defaults to /usr/bin or /bin (which are
the system versions, probably not the same as the one expected from the
image)

Additioanlly I have begun using install instead of altinstall so that
the python executable on the

This issue is seen by comparing the output of `python -V` with
`LD_LIBRARY_PATH=/usr/local/lib python -V` . The former returns an
incorrect version (2.7.5) whereas the latter return the correct version
(2.7.15).

The default prefix when building python from source is /usr/local.
However the executable built loads the shared libraries from /lib64
(symlinked to /usr/lib64) which ends up loading the (incorrect) system
libpython2.7.so instead of loading it from the one that is built in
/usr/local/lib

The libraries being loaded by the executable are visible by executing:
For the correctly built exectuable it is :
```
[root@90fbc9dd6cfa /]# ldd /usr/local/bin/python
	libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007fedc6348000)
```
whereas for the current version (before this commit) the so is loaded
from /lib64 (-> /usr/lib64)

The fix is to either:
1. Specify the library path like so before invoking the python
exectuable:
  `LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/python -V`

OR,

2. Specify the library path at compile time using LD_RUN_PATH (as done
in this commit) so that it does not need to be specified at runtime and
does not require alterations to existing Jenkinsfile

Relevant links:
http://blog.dscpl.com.au/2015/06/installing-custom-python-version-into.html
https://bugs.python.org/issue27685
@ajorpheus
Copy link
Contributor Author

Ready for review and merge

@ajorpheus
Copy link
Contributor Author

The CI (push) build failed with the error The job exceeded the maximum time limit for jobs, and has been terminated.

@ajorpheus
Copy link
Contributor Author

The Travis Build are failing due to the --enable-optimizations flag for python builds which triggers Profile Guided Optimizations (PGO) requiring the execution of all tests to generate profile data which is then used to optimize the compiled code (this results in a faster python executable being generated). However, the side effect of this is that the builds take much longer and hit the timeout limit that Travis CI has for a job.

For the change in build times look at this comment (and the conversation thread itself) : docker-library/python#160 (comment)

Travis CI build timeouts are documented here: https://docs.travis-ci.com/user/customizing-the-build/#build-timeouts

Given the above, I am going to merge this, as well as PR #17 in.

@ajorpheus ajorpheus merged commit e7d1e1a into master Feb 13, 2019
@ajorpheus ajorpheus deleted the fix/python-lib-path branch February 13, 2019 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants