[opensuse-packaging] Proper way to set shebangs in singlespecs
Hi openSUSE hackers, I have been looking for a way to properly set the right shebang in a python singlespec package. But without any lucky so far. The naughty package in question is python-gobject: https://build.opensuse.org/package/show/GNOME:Next/python-gobject I did some try and error with %ifpython macro, which seems to be the usual way to make this right, but after toasting some kittens I stopped and realized this is not working. Have someone cross this path before? If someone have succeeded in such quest and could shed some light on this one for my curiosity's sake and the package's health as well, of course, I would be grateful. Looking forward for your thoughts, Luciano. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
For executables: Replace the /usr/bin/env with /usr/bin/python2/3 using e.g. sed: sed -i '1s/^#!.*/#!\/usr\/bin\/python3/' For doumentation/example files: remove the shebangs and the executable bit. Sebastian On 12/21/2017 03:47 AM, Luciano Santos wrote:
Hi openSUSE hackers, I have been looking for a way to properly set the right shebang in a python singlespec package. But without any lucky so far. The naughty package in question is python-gobject: https://build.opensuse.org/package/show/GNOME:Next/python-gobject
I did some try and error with %ifpython macro, which seems to be the usual way to make this right, but after toasting some kittens I stopped and realized this is not working. Have someone cross this path before? If someone have succeeded in such quest and could shed some light on this one for my curiosity's sake and the package's health as well, of course, I would be grateful.
Looking forward for your thoughts, Luciano.
-- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
Sorry, I wasn't clear enough, English is not my first language. I need a conditional statement that can be satisfied to modify the shebang to use python2 in the python2-gobject package and python3 in the python3-gobject one.
For documentation/example files: remove the shebangs and the executable bit.
That's my case. It's good to know I only need to do some deletion.
For executables: Replace the /usr/bin/env with /usr/bin/python2/3 using e.g. sed:
sed -i '1s/^#!.*/#!\/usr\/bin\/python3/'
Although, if it wasn't, how would I make a conditional to make both packages, python2-* and python3-*, use the right shebang as singlespecs use both pythons? I can't think of any. If someone do, please help us clarify this particular case. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
For executables: Replace the /usr/bin/env with /usr/bin/python2/3 using e.g. sed:
sed -i '1s/^#!.*/#!\/usr\/bin\/python3/' Although, if it wasn't, how would I make a conditional to make both packages,
Sorry, I wasn't clear enough, English is not my first language. Neiter it is mine :) python2-* and python3-*, use the right shebang as singlespecs use both pythons? You can only use one shebang at a time, so the files in your
On 12/21/2017 10:01 PM, Luciano Santos wrote: python2-package need to have python2, the ones in the python3-package the python3 shebang. Or none at all.
I can't think of any. If someone do, please help us clarify this particular case. In the case of the linked python-gobject with documentation files: Just remove them. I create a submit request for that package: https://build.opensuse.org/request/show/559181
Sebastian -- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
You can only use one shebang at a time, so the files in your python2-package need to have python2, the ones in the python3-package the python3 shebang. Or none at all.
I appreciate your help Sebastian, really, but I'm afraid you are not getting me. I know I can only use one shebang at a time and that python2 packages must use python/python2-ending shebangs, python3 ones, python3. Now, supposing that in this case we hadn't doc/example files in python-gobject, but script files, what kind of conditionals would we need to use to make each package use the proper python? if python2; then #!/usr/bin/python2 else #!/usr/bin/python3 endif Constructs like this (I'm using it only as illustration), using rpm macros are not working, at least I didn't figure it out yet. Using bash, same thing. Since the example files go both under python2-gobject's doc folder and python3-gobject's doc folder as well, I have being thinking using something like this (theoretically speaking): sed -i 'python2 shebang on you' /usr/share/doc/packages/python2-gobject/examples/*.py sed -i 'python3 shebang on you' /usr/share/doc/packages/python3-gobject/examples/*.py Again, supposing python-gobject have scrip files rather than doc/examples. And, of course, using proper syntax and macros. How would we achieve the proper shebang goal? -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On 12/22/2017 12:01 AM, Luciano Santos wrote:
Now, supposing that in this case we hadn't doc/example files in python-gobject, but script files, what kind of conditionals would we need to use to make each package use the proper python? It would be easier if you'd say which files we are talking about. For executables that python's setuptools installs, there is nothing to do. if python2; then #!/usr/bin/python2 else #!/usr/bin/python3 endif You can use %ifpython2/%ifpython3, which is true if the package is build for python2/3. https://en.opensuse.org/openSUSE:Packaging_Python_Singlespec#Requirements_sp... Since the example files go both under python2-gobject's doc folder and python3-gobject's doc folder as well, I have being thinking using something like this (theoretically speaking):
sed -i 'python2 shebang on you' /usr/share/doc/packages/python2-gobject/examples/*.py sed -i 'python3 shebang on you' /usr/share/doc/packages/python3-gobject/examples/*.py You can do that (using %{buildroot} for the paths).
-- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
hello, On 22.12.2017 10:36, Sebastian wrote:
You can use %ifpython2/%ifpython3, which is true if the package is build for python2/3.
based on a couple of recent postings, I feel like i need to shout: WRONG! WRONG WRONG WRONG! correct (mostly) is: %if 0%{?have_python2} %ifpython2 and %ifpython3 work on: - Requires - %files - %pre/%post in other words, they determine if the text *is included in section for python2/python3 subpackage* the build scripts (%prep, %build, %install, %check) are COMMON to all the subpackages. Using %ifpython there does the wrong thing. I have added a warning to the wiki page. I also appreciate any suggestions on how to make this clearer in the docs -- and how to make it fail in code, because people don't read docs :) The problem is that there isn't actually a macro for "true if package is built for python2/3". This needs to be fixed. Now you can use "%if 0%{?have_python2}". It's not exactly the right thing but it works.
https://en.opensuse.org/openSUSE:Packaging_Python_Singlespec#Requirements_sp...
Since the example files go both under python2-gobject's doc folder and python3-gobject's doc folder as well, I have being thinking using something like this (theoretically speaking):
sed -i 'python2 shebang on you' /usr/share/doc/packages/python2-gobject/examples/*.py sed -i 'python3 shebang on you' /usr/share/doc/packages/python3-gobject/examples/*.py You can do that (using %{buildroot} for the paths).
%python_expand sed -i '$python for you' %{buildroot}%{_datadir}/doc/packages/$python-gobject .....
On 12/22/2017 04:23 PM, jan matejek wrote:
I also appreciate any suggestions on how to make this clearer in the docs I have one: add the have_python macros to the docs.
Sebastian -- python programming - mail server - photo - video - https://sebix.at cryptographic key at https://sebix.at/DC9B463B.asc and on public keyservers
participants (3)
-
jan matejek
-
Luciano Santos
-
Sebastian