I have python 3.6 installed on FreeBSD 11.1
if I run pkg install sysutils/py-salt, it will install py36-salt.
But if I run the following command
python3.6 -c "import subprocess;subprocess.Popen(['pkg', 'install', '-y', 'sysutils/py-salt'])"
, it will install package py27-salt.
Since I am using salt-stack to mange all my FreeBSD servers, this breaks everything because every time I do a salt state.highstate, it will revert all the py36-* packages to py27-* packages.
I don't know the difference if I run the pkg command inside python scripts. Is there some special environment variable for FLAVORs?
Sorry, I was wrong. This has nothing to do with python, but pkg itself.
If the current installed pkg is py36-salt, when I run pkg install sysutils/py-salt, it will install py27-salt.
if the current install pkg is py27-salt, when I run pkg install sysutils/py-salt, it will install py36-salt.
I am curious, why you have a Salt state that installs salt?
If you want 36, why not just `pkg install -y py36-salt' ?
That's to ensure every machine have the same version of salt running.
that's not important.
Even if I run by hand 'pkg install sysutils/py-salt, it have the same problem.
If the current installed package is py27-salt, it will install py36-salt. And when you run it again, it will install py-salt.
I cannot specify the flavor in the package name, say if I do 'pkg install sysutils/py36-salt or py27-salt, it will say the package does not exist. I am not sure if this is bug of pkg or could it be the way I build the packages with poudiere.
What happens if you do:
pkg upgrade sysutils/py-salt
Hmm, no that doesn't work either..
The main problem is that sysutils/py-salt is not unique:
# pkg search -f sysutils/py-salt |grep '^Name'
Name : py36-salt
Name : py27-salt
So, of course, pkg install sysutils/py-salt does not work as you could expect, or want.
The problem is If I do pkg install sysutils/py36-salt, it will say 'pkg: No packages available'
So I have to use 'sysutils/py-salt' as the package name in my script, which will cause problem is the script was executed a second time.
This is a "mean" thing. The trick is, make the command without category:
python3.6 -c "import subprocess;subprocess.Popen(['pkg', 'install', '-y', 'py36-salt'])".
This is working.