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

RFC: Replace hardcoded path with _libdir macro as done in pkgconfig.attr. #346

Conversation

ydario
Copy link

@ydario ydario commented Nov 2, 2017

I have used the same macro from pkgconfig.attr.

@ydario
Copy link
Author

ydario commented Nov 2, 2017

In case above is not acceptable, this code can be used instead

%define py_prefix %(echo python -c "import sys; sys.stdout.write(sys.prefix)")

but I don't know if .attr files can handle above macro.

@@ -1,4 +1,4 @@
%__python_provides %{_rpmconfigdir}/pythondeps.sh --provides
%__python_requires %{_rpmconfigdir}/pythondeps.sh --requires
%__python_path ^((/usr/lib(64)?/python[[:digit:]]\\.[[:digit:]]/.*\\.(py[oc]?|so))|(%{_bindir}/python[[:digit:]]\\.[[:digit:]]))$
%__python_path ^((%{_libdir}(64)?/python[[:digit:]]\\.[[:digit:]]/.*\\.(py[oc]?|so|pyd))|(%{_bindir}/python[[:digit:]]\\.[[:digit:]]))$
Copy link
Contributor

Choose a reason for hiding this comment

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

on x86_64 that would be: /usr/lib64(64)? which is wrong.. do you really have very different libdir or is it %{_prefix}/lib* ?

@pmatilai
Copy link
Member

pmatilai commented Nov 3, 2017

Yup, %{_libdir} is wrong on x86_64 and technically like with %{_prefix}, there's no actual guarantee that python shares the same prefix as rpm. So I guess the really right thing to do would be querying all those different library paths out of python itself: we have %python_sitelib and %python_sitearch but nothing for the standard lib, and I'm not sure they're technically required to overlap in the way the do in eg Fedora.

Might also be that's all just being too perfect for anybodys good, and %{_prefix} be close enough for this purpose. Dunno.

The 'pyd' addition should be in a separate commit, and explained what it is. But for that too, the technically most correct solution would be fishing the extension out of python itself:

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_vars('SHLIB_EXT')
['".so"']

@ydario
Copy link
Author

ydario commented Nov 3, 2017

I was not aware that x86_64 was already ending in 64.But python lib can be queried using the code in the 2nd comment, I just don't know how to insert into a .attr file.

@ydario
Copy link
Author

ydario commented Nov 3, 2017

I just checked SHLIB_EXT in python for OS/2, and it reports ['".dll"\r'] which is even wrong. I don't know why historically the code is compiling shared modules with PYD extension. This is a bit strange since DLL is more common and I don't see a good reason for changing it unless original porters wanted to avoid recognizing them as ordinary DLLs.

@Conan-Kudo
Copy link
Member

@ydario But they are ordinary DLLs, so they should be marked as such...

@ydario
Copy link
Author

ydario commented Nov 4, 2017

yes,they are ordinary DLLs but there isn't an 'executable flag' in OS/2 (like Windows), so files can be recognized only by the extension (or inspecting the content).

@Conan-Kudo
Copy link
Member

So then probably there's a bug in the Python port in OS/2, since it should reflect the proper extension...

@ydario
Copy link
Author

ydario commented Nov 4, 2017

PYD is the correct extension but probably SHLIB_EXT is not used in the build system so nobody noticed it; I'll get this variable fixed in the next build.

@pmatilai
Copy link
Member

pmatilai commented Nov 6, 2017

See https://docs.python.org/2/faq/windows.html#is-a-pyd-file-the-same-as-a-dll

So they are a bit special for Python 2, and maybe SHLIB_EXT is about something else then.

@ydario
Copy link
Author

ydario commented Nov 6, 2017

Special in the way they are handled by python, but from the OS point of view they are 100% DLLs. Probably they use PYD also to avoid name clash with DLL and to avoid searching the default paths.

Given that PYD is used in windows too, I think that hardcoding the extension is not an error.

@pmatilai
Copy link
Member

pmatilai commented Nov 6, 2017

Yeah it doesn't seem like an error any more than .py[oc] is, just thought there would be a configuration for this and SHLIB_EXT seemed promising. There still might be some config for it, I just dont know what that would be.

@ffesti ffesti closed this in 5ac4305 Feb 19, 2018
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.

None yet

4 participants