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

Always copy the python dynamic libraries into lib folder #518

Merged
merged 4 commits into from
Nov 24, 2019
Merged

Always copy the python dynamic libraries into lib folder #518

merged 4 commits into from
Nov 24, 2019

Conversation

marcelotduarte
Copy link
Owner

@marcelotduarte marcelotduarte commented Sep 27, 2019

This patch has multiple purposes. With it libpython*.so* is moved to the lib folder, so only the executables will be in one folder and everything else in the lib folder. I see that in some cases, and there are several issues about it, libpython is copied several times. Now it's one less (To be honest, in linux I only saw duplicate, one in root and one in lib).
With this patch it was also possible to run alpine linux on a docker (with the help of #494 and #516). It will also resolve cases where the user compiles python from sources (in alpine it is the same). Why? Because python is placed in /usr/local and not in /usr, and ldd doesn't find the dependencies, so I find the python dependencies (sys.executable) and it resolves it.
I tested on ubuntu and alpine, with one of my projects and with samples advanced, sqlite, pyqt5.
I want to do the same for windows, but I have to solve the dll hell, and if it works, will greatly improve the issue of duplicate files.

@marcelotduarte
Copy link
Owner Author

related issues #425, #513

@@ -215,7 +227,7 @@ def _GetDefaultBinExcludes(self):
if sys.platform == "win32":
return ["comctl32.dll", "oci.dll", "cx_Logging.pyd"]
else:
return ["libclntsh.so", "libwtc9.so"]
return ["libclntsh.so", "libwtc9.so", "ldd"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the meaning of the addition of "ldd"? What would request its inclusion anyway?

Copy link
Owner Author

Choose a reason for hiding this comment

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

On Alpine Linux ldd is a reference to a system library (virtual library maybe)

Copy link
Owner Author

Choose a reason for hiding this comment

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

See #513 for more reference

Copy link
Owner Author

Choose a reason for hiding this comment

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

Previously I had a patch #517 just for that, but I decided to put it together.

setup.py Outdated
@@ -28,7 +28,7 @@ def build_extension(self, ext):
return
if sys.platform == "win32" and self.compiler.compiler_type == "mingw32":
ext.sources.append("source/bases/manifest.rc")
os.environ["LD_RUN_PATH"] = "${ORIGIN}:${ORIGIN}/../lib"
os.environ["LD_RUN_PATH"] = "${ORIGIN}:${ORIGIN}/lib"
Copy link
Collaborator

@anthony-tuininga anthony-tuininga Oct 27, 2019

Choose a reason for hiding this comment

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

The original code was intended so that if you installed the executable in /usr/bin (for example) that you would then find the library in /usr/lib. This would eliminate that and require that the files be found in /usr/bin/lib -- which seems wrong! Perhaps it might be satisfactory to simply add ${ORIGIN}/lib and not replace ${ORIGIN}/../lib"?

And if we are moving all files to the subdirectory lib, should we remove ${ORIGIN}?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I had been a little doubtful about this point, but some change here is needed. I tested it on ubuntu and alpine and it seemed correct. I didn't understand why it had this "$ {ORIGIN} /../ lib". And I think this "$ {ORIGIN}" could be removed yes. I'll try.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I changed it to:
os.environ["LD_RUN_PATH"] = "${ORIGIN}/../lib:${ORIGIN}/lib"

The test pass on alpine linux (with this patch and other that it depend #494)
The test pass on my projects.

Copy link
Owner Author

Choose a reason for hiding this comment

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

PR updated.

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