You are not logged in.
Hi, im learning how packages works on arch, so i decide to update a pkg that is orphan in aur: https://aur.archlinux.org/packages/ski/
The new version is compatible with python2 and python3, it works with both versions, so i try to create a PKGBUILD which depend of python.
I ask about that in the irc and as i understand i set:
depends=('python')
but if i try to install it with python2 installed, pacman try to download python3, so i try to modify the PKGBUILD to work.
depends=('python2>=2.0.0')
but it still try to download the las version of python.
As i read in the wiki it should works, so maybe i am losing something, i add the PKGBUILD that is using now:
pkgname=ski
pkgver=6.11
pkgrel=1
pkgdesc="Ski game for the console"
arch=("any")
url="www.catb.org/esr/ski/ski-6.11.tar.gz"
license=('BSD')
depends=('python>=2.0.0')
options=('zipman')
changelog=NEWS
source=("http://www.catb.org/esr/ski/$pkgname-$pkgver.tar.gz")
md5sums=()
package() {
cd "$pkgname-$pkgver"
install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
make DESTDIR="$pkgdir/" install
}
md5sums=('d0875ef6eacb6dedc8f1cadb1d206166')
Offline
It's not going to run with either/or. It's going to want one or the other. What does it call?
Offline
Try the following: https://wiki.archlinux.org/index.php/PK … pendencies
Version restrictions can be specified with comparison operators, e.g. depends=('foobar>=1.8.0'); if multiple restrictions are needed, the dependency can be repeated for each, e.g. depends=('foobar>=1.8.0' 'foobar<2.0.0').
So you should easily be able to specify python to be less than 3, which should also prevent it from downloading python3 if I understand correctly. AFAIK, there is no harm in having both python3 and python2 installed on a system simultaneously. You would then just have to then specify in your code #!env /usr/bin/python2 for code that is not backwards/forwards compatible.
Last edited by JohnBobSmith (2016-12-03 18:03:27)
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
Try the following: https://wiki.archlinux.org/index.php/PK … pendencies
The Arch Wiki wrote:Version restrictions can be specified with comparison operators, e.g. depends=('foobar>=1.8.0'); if multiple restrictions are needed, the dependency can be repeated for each, e.g. depends=('foobar>=1.8.0' 'foobar<2.0.0').
So you should easily be able to specify python to be less than 3, which should also prevent it from downloading python3 if I understand correctly. AFAIK, there is no harm in having both python3 and python2 installed on a system simultaneously. You would then just have to then specify in your code #!env /usr/bin/python2 for code that is not backwards/forwards compatible.
Nothing in this post makes sense. The python package and the python2 package are two totally separate things, one does not "provide" the other. Versioned deps won't work here at all.
Offline
Bleh, so it seems I messed that up. Good catch! Still, if the OP's script works for both 2 and 3 as he specified, does it matter if python 3 gets downloaded and installed??
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
It matters what the script is calling. It needs to have that specific one available.
Offline
I see. So we need the first part of the script. Daklon, can you post the output of cat <yourscript.py> | head -n3 here? This should tell us which python you need, provide you are using a SHEBANG in your code.
I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.
Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...
Offline
It's Eric S. Raymond's code and the shebang is
#!/usr/bin/env python
If somebody already has python2 but not python and they absolutely don't want to install an extra package, they can always make their own PKGBUILD that modifies the shebang.
Offline
It won't help with the dependency issues at installation, but you might want to look into pyvenv and virtualenv
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Online
It's Eric S. Raymond's code and the shebang is
#!/usr/bin/env python
And there you have it. "python" is part of the python package in Arch, so that's the dependency unless you modify the shebang.
Offline
depends=('python2>=2.0.0')
but it still try to download the las version of python.
As i read in the wiki it should works, so maybe i am losing something, i add the PKGBUILD that is using now:
... depends=('python>=2.0.0') ...
I am giving a lengthy reply to try to clear up some confusion in the hope that it will be helpful to others.
There is a difference between python2>=2.0.0 and python>=2.0.0. "python" is the Python 3 package, so "python>=2.0.0" will always install that package (3 is always >= 2). "python2" is the Python 2 package. "python2>=2.0.0" will always install that package (2 >= 2). If you try something like "python<3.0.0", the dependency will always fail because there is no version of Python 3 below 3. Whenever you see "python" as a dependency, think "python3".
Pacman doesn't directly support "either/or" dependencies (i.e. "use either python or python2"). It only supports virtual dependencies. These are created when a package "provides" a package. When one package can be used as a drop-in replacement for another, it will provide that package. For example, "foo-git" will provide "foo" so that packages that depend on "foo" can use either. Sometimes the package is entirely virtual, such as the "java-environment" virtual package provided by both the openjdk and the java packages. A package that requires a Java runtime environment will depend on "java-environment" and the dependency will be satisfied if either the openjdk or java package is installed.
That doesn't work for Python because Python 2 and Python 3 are not interchangeable. Even if a subset of Python 3 code can run with Python 2 and vice versa, there are many cases where the code is incompatible. The Python 2 package can't provide "python" because any package expecting Python 3 may break (and vice versa again).
For the subset of code that can use either Python 2 or Python 3, the hashbang at the top of the file will usually specify "python". On some systems that may point to either the Python 2 or the Python 3 interpreter. On Arch, it always points to the interpreter in the "python" package, which is currently Python 3. If the hashbang specifies "python" (or "python3"), then the package will use Python 3 and must depend on "python" (or "python3", which is future-proof and better imho). If you want your package to work with Python 2, you need to change the hashbangs to "python2" via the PKGBUILD when creating the package. If you change the hashbangs in the package, then the dependency has to be set to "python2".
Even if you manage to get it working with either version of Python via virtual environment magic, the dependency should be set according to the hashbangs in the package. The package should "just work" after its installed by a user.
edit
My recommendation is to make the package depend on "python3". Add the necessary code to the file to change the hashbangs to "python2", then comment them out. Add a note for the user that the package can be used with Python 2 by uncommenting those lines and replacing "python3" with "python2" in the depends array. Instruction for manual customization is common in AUR packages as they need to be built by the user anyway.
Last edited by Xyne (2016-12-03 20:16:23)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Sorry for the delay in the answer and thanks everybody for the quick reply
I has missunderstand what provide means, i think that "pyhton" was python2 and python3.
I will take your recommendation Xyne, only a last question, where should i add the note? in the code? in the comments in aur?
Offline
Personally, I would recommend ignoring Xyne's recommendation. He's the only packager that has a real problem with the whole python/python3 thing and refuses to follow the conventions everyone else uses. If the program calls python, make it depend on python and move on.
Offline