-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(python): python REPL detection is broken #344
Comments
Hi @pysan3, I'm happy that you like the plugin and at the same time sad to hear that there's a bug disrupting your workflow. I might have said that in other issues so sorry if I'm repeating myself too much, but it is becoming increasingly hard for me to keep up with iron as unfortunately I myself stopped using it and am lacking time to properly manage it, so I reckon it is my fault for overseeing this. I'll partially revert that PR as it does some good by dealing with the virtualenv issue. At the same time, the defaults should be a bit more sane. It has been ages since I did python professionally (which entails projects with proper development env setup, with I guess this means that the list of available binaries modules should change according to |
Thanks for your quick response! I understand your pain and I want to thank you again for your hard work! I'm not quite sure if this was added recently or was a feature from long ago but here's the content of # This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi
deactivate () {
unset -f pydoc >/dev/null 2>&1 || true
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV='/home/user/tmp/mytest'
if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
fi
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH" # =============== HERE, PATH IS MODIFIED !!! ================
export PATH
# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1-}"
if [ "x" != x ] ; then
PS1="() ${PS1-}"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
fi
export PS1
fi
# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
pydoc () {
python -m pydoc "$@"
}
# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null After running $ source ./bin/activate
(mytest) $ pip install ipython
Requirement already satisfied: ipython in ./lib/python3.10/site-packages (8.14.0)
Requirement already satisfied: backcall in ./lib/python3.10/site-packages (from ipython) (0.2.0)
... -- skipping output
(mytest) $ tree bin
bin
├── activate
├── activate.csh
├── activate.fish
├── activate.nu
├── activate.ps1
├── activate_this.py
├── ipython
├── ipython3
├── pip
├── pip3
├── pip-3.10
├── pip3.10
├── pygmentize
├── python -> /home/user/.local/share/pyenv/versions/3.10.8/bin/python
├── python3 -> python
├── python3.10 -> python
├── wheel
├── wheel3
├── wheel-3.10
└── wheel3.10
0 directories, 20 files
(mytest) $ cat bin/ipython
#!/home/user/tmp/mytest/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from IPython import start_ipython
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(start_ipython()) I haven't got a setup to test on Windows but I'm pretty sure that you'll have access to Note that I don't use virtualenv regularly (but Hope this helps ;) |
Hi @pysan3 sorry my PR is giving you trouble. For the first part, no it did not occur to me that a change to the start up repl script would interfere with the selection script due to my ignorance of how the selection script works, so I only tested my PR against configurations where the repl is hardcoded. |
Thanks for your response @Palpatineli.
As this is clearly a bug, please submit a PR to either revert your change or fix the current issue.
Just out of curiosity, could you give me a specific example / commands of this situation? When pip installing globally, when using pyenv, you should find |
Any updates? @Palpatineli |
Hi, thanks for the nice plugin!
I have noticed an issue when detecting the python REPL.
The current method mainly uses
vim.fn.executable(command[1])
to detect whether the REPL is available and defines which REPL to use defined in table of eachiron/fts/<filetype>.lua
file.The detecting mechanism is implemented in the following two places (which are doing basically the same thing) and is called mainly in
iron.lowlevel.get_repl_def
.config.repl_definition
iron.nvim/lua/iron/config.lua
Lines 27 to 44 in 9017061
providers.first_matching_binary
iron.nvim/lua/iron/providers.lua
Lines 13 to 32 in 9017061
However, the commands for all python REPLs defined in
iron/fts/python.lua
take the form ofpython -m <module-name>
which makes the result ofvim.fn.executable(command[1]) => vim.fn.executable("python")
always true.@Palpatineli I noticed you recently submitted a PR #337 which is the direct cause of this issue. Are you aware of this? Did you test your code against environment where there's only
python
raw REPL and noipython
or other rich REPLs? (CC @hkupty as you merged the PR)It is sad to say, but I'm quite confused by the aim of that PR in the first place since
ipython
and other commands should be found in$PATH
if the setup of python environment is done correctly (withpoetry shell
,source bin/activate
,conda activate <env-name>
etc) (please correct me if I'm wrong tho).Thanks,
pysan3
The text was updated successfully, but these errors were encountered: