Bug 228188 - devel/youcompleteme: Add python3 support
Summary: devel/youcompleteme: Add python3 support
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Richard Gallamore
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-12 05:11 UTC by Serge
Modified: 2018-06-14 22:42 UTC (History)
0 users

See Also:
ultima: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serge 2018-05-12 05:11:54 UTC
After installing the latest versions of editors/vim and devel/YouCompleteMe from ports and running vim, I am getting the error:

    YouCompleteMe unavailable: No module named 'future'

It seems that this error is not unique to ports because there are a few similar bug reports at the main github repository. 

In my case, I tend to think the reason is my vim port was built against python 3.6 (which does not have module 'future'), but YCM in ports uses python 2.7. Therefore, an attempt to 'import future' fails.

I wonder if it is possible at all to use YCM with Vim+python3.6 or I will need to rebuild Vim with python 2.7 instead.

It would be nice, of course, if YCM could be built against the current python version, too!

Thanks.
Comment 1 Richard Gallamore freebsd_committer freebsd_triage 2018-05-12 17:20:25 UTC
(In reply to Serge from comment #0)
The issue is indeed because your vim bindings and YouCompleteMe python versions differ. I couldn't get YouCompleteMe to work in python 3 though I suspect it is because of lack of time over compatibility.

Adding python3 support has been on my list for awhile and it will happen, I'm just not sure when I will have the time to make it happen.
Comment 2 Richard Gallamore freebsd_committer freebsd_triage 2018-05-13 18:56:38 UTC
(In reply to Serge from comment #0)
Made another attempt and YouCompleteMe was working with python 3. I haven't committed the patch yet but if you want to test it is here[1].

[1] https://reviews.freebsd.org/D15417
Comment 3 Serge 2018-05-14 19:37:42 UTC
Hi Richard,

Sorry to react slowly, it was difficult over the week-end. Thanks a ton for your effort. I also have to tell you that this was probably the fastest response to any issue I filed here so far :)

I struggled a bit at first when trying to test you patch until I realised that I had to set

DEFAULT_VERSIONS+= python=3.6

in /etc/make.conf

Until now, I only needed to set

DEFAULT_VERSIONS+= python3=3.6

in order to compile a bunch of ports against Python 3.6. But those ports (for example, Vim), had config options to select Python version as well. I am not sure what is the "correct" behaviour.

I have successfully built YCM, but when I try loading a cpp file, I get this type of errors:

YouCompleteMe unavailable: [Errno 2] No such file or directory: '/usr/local/bin/python': '/usr/local/bin/python'

There is no '/usr/local/bin/python' on my system, probably because I do not have lang/python installed (but I do have both python 2.7 and 3.6 and I do have /usr/local/bin/python2.7,  .../python3.6, and .../python3 link). 

I don't have the time to do a full work-load testing for the moment, but after I created symlink:

ln -s /usr/local/bin/python3.6 /usr/local/bin/python

I was able to use YCM to check a couple of simple cpp projects.

I wonder if it is absolutely necessary to set python version to 3.6 system-wise in order to use YCM. I do not currently have any other ports using python 2.7 and relying on default version, but in the future this may create a version conflict.

Thank you again for very quick response.
Comment 4 Richard Gallamore freebsd_committer freebsd_triage 2018-06-14 00:14:51 UTC
Hello Serge,

Seems I missed the email with your reply. This patch should allow you to build the python3.6 flavor which would be required in order to build without setting DEFAULT_VERSION which would be 2.7. This can be done by doing "make FLAVOR=py36" or with "poudriere bulk devel/youcompleteme@py36".

As for the "No such file or directory" python error, ill look into this. I don't recall running into this error but it could be because I did the flavor route.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-06-14 21:52:20 UTC
A commit references this bug:

Author: ultima
Date: Thu Jun 14 21:51:36 UTC 2018
New revision: 472401
URL: https://svnweb.freebsd.org/changeset/ports/472401

Log:
  * Add python flavors support. This will allow
  both python 2 and python 3 support.

  PR:		228188
  Reported by:	Serge <skh^@hotmail.com>
  Reviewed by:	antoine
  Differential Revision:	https://reviews.freebsd.org/D15417

Changes:
  head/devel/youcompleteme/Makefile
Comment 6 Richard Gallamore freebsd_committer freebsd_triage 2018-06-14 21:56:06 UTC
The interpreter is set by what it detects on the host machines depending on the python version being used. My guess is it had to do something with compiling in an unclean environment.

Python3 support is now available.
Comment 7 Serge 2018-06-14 22:42:48 UTC
Hi Richard,

Thank you for your attention to this. It might have been an unclean environment, because I was forced to recompile a few py-flavoured ports, which might have been built before I edited DEFAULT_VERSIONS += python=3.6. After reading your messages, I decided to rebuild both python 2.7 and 3.6, YCM as well as some other py-related ports and try again. I also rebuilt vim. It looks like I am able to use it more or less normally, as I reported previously, but YCM still complains that it cannot find '/usr/local/bin/python'.

Right now, I simply don't have time to roll everything back to DEFAULT_VERSIONS += python=2.7, in order to try building YCM with "make FLAVOR=py36", because it would mean rebuilding all packages depending on python. In this case, the result might be different, but for the moment, I guess I am stuck with adding the /usr/local/bin/python link manually. I will post here if I find anything interesting in the future.

Thanks.