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
Virtualenv cell magic #1891
Virtualenv cell magic #1891
Conversation
""" | ||
if 'WORKON_HOME' not in os.environ: | ||
return False | ||
if os.path.exists(os.environ['WORKON_HOME'] + '/' + env): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.path.join
;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fixed on this line, though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it.
For the tests: rather than relying on VEW being installed and active, we should set $WORKON_HOME to a temporary directory, make a virtualenv there and test against that. Also, rather than depending on different versions of Python, we should make the subprocess *brackets so it works on Python 2 or 3. |
…hich deleted after tests are done. Started adding support to windows but it still incomplete and untested.
I have Started on support for windows but didn't finish it. it will be pretty complicated since VEW doesn't support it. |
OK, that's not quite what I meant with the tests. We shouldn't mess with user visible folders in the test suite. Have a look at
Then in
|
""" | ||
Returns the correct activate command given the platform | ||
""" | ||
if sys.platform.startswith("linux"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the default behavior, as the most likely other platforms (OS X, freebsd, etc.) will all behave the same as Linux here, rather than "Platform not supported".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's inactive for the time being but I intend to finish it in time for
release 0.14.
Em 11/06/2012 18:50, "Min RK" <
reply@reply.github.com>
escreveu:
return
- cmd = get_activate_cmd(line)
- p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
- out, err = p.communicate(cell)
- p.wait()
- if err:
print >> sys.stderr, err
- return out
+_loaded = False
+
+def get_activate_cmd(line):
- """
- Returns the correct activate command given the platform
- """
- if sys.platform.startswith("linux"):
This should be the default behavior, as the most likely other platforms
(OS X, freebsd, etc.) will all behave the same as Linux here, rather than
"Platform not supported".
Reply to this email directly or view it on GitHub:
https://github.com/ipython/ipython/pull/1891/files#r963238
def test_virtualenv_testenv(): | ||
ip = get_ipython() | ||
result = ip.run_cell_magic('virtualenv', 'testenv', 'print("hello")') | ||
nt.assert_equals('hello\n', result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this test do something to demonstrate that it's running in the virtualenv - like printing sys.path
. Then we can get rid of the redundant test_virtualenv_pypy
and test_virtualenv_python3
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
On Sun, Jun 17, 2012 at 10:01 PM, Thomas Kluyver <
reply@reply.github.com
wrote:
- result = ip.run_cell_magic('virtualenv', 'pypyEnv', 'import
sys;print\(sys.version)')
- nt.assert_true('PyPy' in result)
+def test_virtualenv_python3():
- if not env_exists('py3'):
raise SkipTest("Environment py3 not found, skipping test")
- ip = get_ipython()
- result = ip.run_cell_magic('virtualenv', 'py3', 'import sys;print \
- (sys.version_info.major)')
- nt.assert_equals('3\n', result)
+def test_virtualenv_testenv():
- ip = get_ipython()
- result = ip.run_cell_magic('virtualenv', 'testenv',
'print("hello")')- nt.assert_equals('hello\n', result)
Let's make this test do something to demonstrate that it's running in the
virtualenv - like printingsys.path
. Then we can get rid of the redundant
test_virtualenv_pypy
andtest_virtualenv_python3
.
Reply to this email directly or view it on GitHub:
https://github.com/ipython/ipython/pull/1891/files#r998914
Flávio Codeço Coelho
+55(21) 3799-5567
Professor
Escola de Matemática Aplicada
Fundação Getúlio Vargas
Praia de Botafogo, 190 sala 312
Rio de Janeiro - RJ
22250-900
Brasil
def test_virtualenv_testenv(): | ||
ip = get_ipython() | ||
result = ip.run_cell_magic('virtualenv', 'testenv', 'import sys;print(sys.path)') | ||
nt.assert_equals('tmp', os.path.split(eval(result)[1])[0].split(os.path.sep)[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a very robust test - all sorts of things can be in /tmp. And it's probably not called /tmp on Windows.
What about something like nt.assert_in(testenv_dir.name, result)
?
@takluyver, @minrk: what's your take on this one? It seems there's a comment from @takluyver still pending improvement; is it otherwise in mergeable state? If so, is that small missing point a deal-breaker to merge it? Given this will be probably pretty popular, I'm willing to ask @fccoelho to improve the testing post-0.13 if need be, so that we can get it in now. Thoughts? |
There are several unaddressed comments here, and this is not even basically functional on any of my systems, due to the treatment of WORKON_HOME. I do not think it is ready to merge. |
Got it. Then let's target this for 0.14, as I simply don't see it getting ready in a day or two (and us having the bandwidth to carefully review and test it). Thanks @minrk for that one... |
It's best this way. I don't have the time to address those issues right thanks for the patience, Flávio On Tue, Jun 26, 2012 at 1:47 AM, Fernando Perez <
Flávio Codeço Coelho+55(21) 3799-5567 |
No worries, @fccoelho! We're very happy to have your contributions, and 0.14 will be out before you know it. It's OK to polish after merge, but since in this case it looks like it does need real work, re-targeting seems like the best policy. We're very happy to have you contributing to IPython, so I hope this bubbles to the top of your todo list before too long :) |
Hi, This PR is unactive for 2 month now. What is it's status ? Thanks. |
It's inactive for now, But I plan to finish it before the next Ipython's release. Flávio On Fri, Aug 24, 2012 at 6:31 AM, Bussonnier Matthias <
Flávio Codeço Coelho+55(21) 3799-5567 |
Ok, no problem, take your time :-) |
I'm going to close this pull request for now. Please reopen it if and when you have time to complete the necessary changes. Altenatively you might find it more convenient to just upload your extension to gist or similar and post it on the list of IPython exensions. Thanks. |
fine. On Tue, Sep 18, 2012 at 5:32 PM, Bradley M. Froehle <
Flávio Codeço Coelho+55(21) 3799-5567 |
Hi,
here is my virtualenv extension. It is very simple, and has a couple of tests to it (84% coverage). It requires a couple of envs to test, but if they are not present, it raises SkipTest.
Suggestion for improvement both of the extention or its testing are very welcome!