Skip to content
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

Native REPL should allow for environment configuration #23570

Open
Apreche opened this issue Jun 6, 2024 · 10 comments
Open

Native REPL should allow for environment configuration #23570

Apreche opened this issue Jun 6, 2024 · 10 comments
Assignees
Labels
area-repl community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs community feedback Awaiting community feedback

Comments

@Apreche
Copy link

Apreche commented Jun 6, 2024

For a lot of Python projects, in my case Django web projects, simply running a straight Python REPL isn't very helpful. There's a lot of environment setup and initialization that is required for the REPL to be useful within the context of the project. That's why there are facilities such as ./manage.py shell and with django-extensions ./manage.py shell_plus.

Those tools are already capable of launching different Python REPLs such as the default one, bpython and iPython. It would be great if they could seamlessly launch the VSCode native Python REPL in the same way.

Failing that, there should still be extensive configuration options for the native REPL. What directory does is run in? What environment variables to set automatically? What Python code to run automatically at the start of every REPL instance?

iPython profiles is a good place to start looking for what kinds of configuration options are desirable. Every time I have ever wanted to change the behavior of a Python REPL, I've found it was possible to do with iPython.

@Apreche Apreche added the feature-request Request for new features or functionality label Jun 6, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jun 6, 2024
@anthonykim1
Copy link

Hello @Apreche, thanks much for your suggestions on improving the REPL experience. I kindly appreciate it.

Failing that, there should still be extensive configuration options for the native REPL. What directory does is run in? What environment variables to set automatically? What Python code to run automatically at the start of every REPL instance?

I do agree with you that equivalent or similar concept of IPython profiles would be great addition to the REPL experience, especially some sort of start up script that would run at the start of session which would allow users to automatically set their desired variables (such as environment variables) in a consistent manner. Or moreover, additional things that are listed in the example config file such as which scripts to automatically execute in each instance of iPython.

In terms of django related, I believe there is already a feature request on this: #13027

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Jun 17, 2024
Copy link

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
@jgorset
Copy link

jgorset commented Aug 2, 2024

I think the bot closed this one by mistake, since there was no additional information requested by @anthonykim1, but rather an acknowledgement that it would be a neat feature. And, it really would be! So, should we reopen this? :)

@anthonykim1
Copy link

anthonykim1 commented Aug 7, 2024

@jgorset Correct, let me reopen this with a better tag this time. Please upvote to show interest in this :)

@anthonykim1 anthonykim1 reopened this Aug 7, 2024
@anthonykim1 anthonykim1 added the needs community feedback Awaiting community feedback label Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

@anthonykim1 anthonykim1 added the community ask Feature request that the community expressed interest in label Aug 7, 2024
Copy link

github-actions bot commented Sep 7, 2024

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2024
@anthonykim1
Copy link

I am keeping this opened since it already has over 9 votes.

@anthonykim1 anthonykim1 reopened this Sep 8, 2024
@anthonykim1 anthonykim1 removed the info-needed Issue requires more information from poster label Sep 8, 2024
@anthonykim1 anthonykim1 removed the triage-needed Needs assignment to the proper sub-team label Dec 9, 2024
@anthonykim1
Copy link

Related as well: #13027

@LewyCoda
Copy link

I generally like how it looks comparatively to the usual terminal and I also like how it opens on the right side of vscode.
I would like to know if there are any details regarding making it easier for me to use in relation to my current projects.
For now however, I find it a bit harder to use with poetry as my environment is not interconnected with Python RELP or I just have little information regarding how to use it appropriately. My imports from my other scripts no longer work within the same file location of my script. My usual process was running python interpreter from the terminal and then hitting (shift + enter) to run selected lines and piecing them together one by one until I felt comfortable with the script running. Is it still possible to do something similar to this?

Thank you and best regards

@anthonykim1
Copy link

@LewyCoda Thanks for the feedback.
It may be a case where you have not selected the virtual environment you created with poetry as an "active interpreter".
Try running command Select interpreter in the command palette (ctrl/cmd +shift+ p) and make sure you select your desired poetry environment before launching the Native REPL.

Image.

. My usual process was running python interpreter from the terminal and then hitting (shift + enter) to run selected lines and piecing them together one by one until I felt comfortable with the script running. Is it still possible to do something similar to this?

Yes, I'm thinking it may be easier to do this because the history of the cell execution are nicely divided into separate cell now, instead of having lists of undivided text in the terminal.
If you have the setting python.REPL.sendToNativeREPL to true and python.REPL.enableREPLSmartSend (more description here: https://code.visualstudio.com/docs/python/run#_smart-send). The hope is that you will end up with smoother shift+enter workflow from your Python file to Native REPL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-repl community ask Feature request that the community expressed interest in feature-request Request for new features or functionality needs community feedback Awaiting community feedback
Projects
None yet
Development

No branches or pull requests

4 participants