vheon / JediHTTP

Simple http wrapper around jedi
Apache License 2.0
40 stars 9 forks source link

Python config #49

Closed xiaoyaoliu closed 6 years ago

xiaoyaoliu commented 6 years ago

allow user to custom their own project directory for JediHttp. the python user just need add a vimrc.py in their project directory to add their custom path to python's sys.path


This change is Reviewable

codecov-io commented 6 years ago

Codecov Report

Merging #49 into master will decrease coverage by 1.45%. The diff coverage is 53.84%.

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
- Coverage   95.22%   93.76%   -1.46%     
==========================================
  Files           9        9              
  Lines         356      369      +13     
==========================================
+ Hits          339      346       +7     
- Misses         17       23       +6
micbou commented 6 years ago

Thanks for the PR but I don't really see the advantage compared to setting the PYTHONPATH environment variable while starting JediHTTP. Also, vimrc.py is not a good choice of a name as JediHTTP is supposed to be editor-agnostic.


Review status: 0 of 5 files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

xiaoyaoliu commented 6 years ago

@micbou Thanks for your reply. Because different projects need different PYTHONPATH, I have to custom it in project's config file. As the PYTHONPATH variable may be global, it will search python code cross projects. Suppose I have A Project and B Project, when I use YouCompleteMe::GoTo in A Project, I want it only goto files in A Project, don't return any result from B Project.

The config filename (vimrc.py), can be edited as your pleasure.

vheon commented 6 years ago

As the PYTHONPATH variable may be global, it will search python code cross projects.

Can't you run the JediHTTP server with a specific PYTHONPATH?

Also I'm not that great Python developer but if your project has all the dependencies configured properly isn't running JediHTTP from the project directory enough?

xiaoyaoliu commented 6 years ago

@vheon thanks for your reply! I start JediHTTP server in ycmd, it just can run server with specific executable python(python_binary_path), not specific PYTHONPATH.

Until now, I have not found a better solution to custom PYTHONPATH for JediHTTP server, so I wrote this PR. If I found a better solution to set specific PYTHONPATH for JediHTTP server in future, I would close and comment this PR. So, you can ignore this PR now.

Suppose the project directory is D1. In our company‘s projects,not only D1 must be added to PYTHONPATH, but also D1/common, D1/lib, D1/common_server, and so on. We have project D2、D3... every project need specific PYTHONPATH.

vheon commented 6 years ago

I start JediHTTP server in ycmd, it just can run server with specific executable python(python_binary_path), not specific PYTHONPATH.

Yeah I understand that but what's wrong with changing the PYTHONPATH in the shell before starting vim or whatever client you use for ycmd? Does it work as you might expect?

In our company‘s projects,not only D1 must be added to PYTHONPATH, but also D1/common, D1/lib, D1/common_server, and so on.

And at runtime how does the application know that it has to look at those path too? 😕

micbou commented 6 years ago

Obsoleted by PR https://github.com/Valloric/ycmd/pull/1028.