Summary: | Changing default Python version unduly difficult | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Ports & Packages | Reporter: | Mikhail Teterin <mi> | ||||||
Component: | Ports Framework | Assignee: | David Naylor <dbn> | ||||||
Status: | Closed DUPLICATE | ||||||||
Severity: | Affects Only Me | CC: | dbn, iblis.dif01, kde, koobs, ports-bugs, python | ||||||
Priority: | --- | Keywords: | needs-qa | ||||||
Version: | Latest | ||||||||
Hardware: | Any | ||||||||
OS: | Any | ||||||||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209551 | ||||||||
Attachments: |
|
Description
Mikhail Teterin
![]() ![]() Replace: PYTHON3_DEFAULT=3.5 PYTHON_DEFAULT=3 by DEFAULT_VERSIONS= python=3.5 python3=3.5 Now, there are ports that will insist on python 2.7, because they don't work with 3. I don't see any reason for this to happen with devel/py-sip though. Without builds logs, on the other hand, I don't see any way to help you. Best is to open a PR with that port with a poudriere log, to see what happens. (In reply to Mathieu Arnold from comment #1) > DEFAULT_VERSIONS= python=3.5 python3=3.5 Does not help. For example: % make -C /usr/ports/textproc/py-pygments -V DEFAULT_VERSIONS ruby=2.0 tcl=8.6 gcc=4.9 db=6.1 python=3.5 python3=3.5 perl=5.22 ghostscript9:agpl and yet: % make -C /usr/ports/textproc/py-pygments -V USES -V PYTHON_VER -V PKGNAME python 2.7 py27-pygments-2.1.3 > I don't see any reason for this to happen with devel/py-sip though. Nor for py-pygments, right? > Without builds logs, on the other hand, I don't see any way to help you. Why do you need build logs? The problem is right there with the incorrect names of PYTHON_VER and PKGNAME -- these can be seen without any builds even attempted, right? The build logs would allow us to have a better understanding of what the problem is. In this particular case I suspect a warning message in the build logs would give a clue as to the solution. Also, I am able to reproduce the problem on my system: # cd /usr/ports/textproc/py-pygments # make -V PYTHON_VER 2.7 # make -V PYTHON_VER DEFAULT_VERSIONS=python=3.5 2.7 # make -V WARNING "Your requested default python version 3.5 is different from the installed default python interpreter version 2.7" The above warning is what should appear in your build logs. If not we can address that. The issue is you have already installed lang/python (i.e. the default) as version 2.7. This means your system is "hard-coded" to use python-2.7 as the default until you uninstall all ports that depend on lang/python, inclusive, and rebuild them all with the new default. The effect of "default" is stronger than what the word implies, it is more akin to choosing i386 and amd64 at install time. Once you have chosen it, that's it. Until you undo and redo. In other words, the choice of default is persistent and cannot be changed, only undone. I hope this clarifies the issue. Hi, Here is the code block in Mk/Uses/python.Mk. From line 276-289 https://svnweb.freebsd.org/ports/head/Mk/Uses/python.mk?view=markup&pathrev=414168#l276 It shows that the python interpreter pointed by `/usr/local/bin/python` will be chosen. It overrides the config of `DEFAULT_VERSIONS`. And, in our case, we install python2 first, implies `/usr/local/bin/python` point to py2. (In reply to David Naylor from comment #3) > This means your system is "hard-coded" to use python-2.7 as the default > until you uninstall all ports that depend on lang/python This is, what I refer to as "unduly difficult". Seems like a gratuitous requirement. If I can edit the port's Makefile and change -USES=python +USES=python:3 to build the package prefixed with p35- instead of p27-, I should be able to have the same effect by simply setting my preference with DEFAULT_VERSIONS. (In reply to Iblis Lin from comment #4) > the python interpreter pointed by `/usr/local/bin/python` > will be chosen. It overrides the config of `DEFAULT_VERSIONS`. Thanks, Iblis. Should not be hard to fix, Python-folks? Oops, apologies. The correct approach to what you want to achieve is: # Variables, which can be set by a user: # # PYTHON_VERSION - The chosen Python interpreter including the version, # e.g. python2.7, python3.3, etc. This allows the user # to override the currently chosen default version and # to install the port for a specific Python version. # It must not be set by a port. For example: # cd /usr/ports/textproc/py-pygments # make -V PYTHON_VER 2.7 # make -V PYTHON_VER PYTHON_VERSION=python3.5 3.5 i.e. if you want to install ports for python versions other than the default (as already set in your system, per PEP 394) then use PYTHON_VERSION, this can be set in /etc/make.conf to effectively change the default. (In reply to David Naylor from comment #6) > PYTHON_VERSION - The chosen Python interpreter including the version, Oh... So, do we rename this PR into something like "PYTHON_VERSION ignores DEFAULT_VERSIONS"? Because I, for one, think it was a great idea to centralize these settings into one list... The current approach -- as this very ticket's comments attest -- too confusing even for members of portmgr@ and python@ . Ordinary users have no hope :-) Created attachment 171555 [details]
Depreciate PYTHON_VERSION, use PYTHON_DEFAULT instead
Per your suggestion that PYTHON_VERSION is now un-intuitive in the current Ports Framework (a la DEFAULT_VERSIONS) the attached patch depreciates PYTHON_VERSION and uses PYTHON_DEFAULT instead:
# make -V PYTHON_VER
2.7
# make -V PYTHON_VER DEFAULT_VERSIONS=python=3.5
3.5
Reopen: patch to change confusing behavior. Hi! please check out the comment in bug 209551, also. (I have no idea how to add `sea also` link... *** This bug has been marked as a duplicate of bug 209551 *** Assign to committer that resolved Created attachment 171563 [details] propose patch Please give this patch a try, It follows the rule i proposed in bug 209551, comment 1. Here describe the testing flow: 1. prepare a new jail 2. check the current priority of `${LOCALBASE}/bin/python` $ pkg install python # should create a symlink `/usr/local/bin/python` $ cd /usr/ports/databases/py-sqlite3 $ make -V PYTHON_VERSION DEFAULT_VERSIONS=python=3.5 python2.7 # the symlink win now 3. apply this patch 4. check that DEFAULT_VERSIONS got higher priority $ cd /usr/ports/databases/py-sqlite3 $ make -V PYTHON_VERSION python2.7 $ make -V PYTHON_VERSION DEFAULT_VERSIONS=python=3.5 python3.5 5. one more check for priority of symlink `/usr/local/bin/python` $ pkg delete python $ pkg install python3 # we will get python3.4 installed $ cd /usr/local/bin $ ln -s python3 python $ ls -l python lrwxr-xr-x 1 root wheel 7 Jun 19 14:16 python@ -> python3 $ cd /usr/ports/databases/py-sqlite3 $ make -V PYTHON_VERSION DEFAULT_VERSIONS=python=3.5 python3.5 $ make -V PYTHON_VERSION python3.4 # ya! symlink auto-detect correct! hmm, i will post my comment to the new issue page. (When i was writing it, i do not notice it has been closed |