By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,570 Members | 1,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,570 IT Pros & Developers. It's quick & easy.

subprocess.Popen(..., cwd=...) and Makefile $(PWD) don't play nice

P: n/a
Hello All,

Can anybody explain why Makefile $(PWD) does show the right directory
when running under subprocess.Popen(..., cwd=...)

For example:
[18:07] tmp $cat /tmp/p/Makefile
all:
@echo $(PWD)
[18:07] tmp $cat t
#!/usr/bin/env python

from subprocess import Popen
Popen(["make"], cwd="/tmp/p")

[18:07] tmp $./t
/tmp

The output of the "make" command should have been "/tmp/p" and not "/
tmp"

TIA,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com
Oct 6 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
En Mon, 06 Oct 2008 13:09:26 -0300, Miki <mi*********@gmail.comescribió:
Can anybody explain why Makefile $(PWD) does show the right directory
when running under subprocess.Popen(..., cwd=...)

For example:
[18:07] tmp $cat /tmp/p/Makefile
all:
@echo $(PWD)
[18:07] tmp $cat t
#!/usr/bin/env python

from subprocess import Popen
Popen(["make"], cwd="/tmp/p")

[18:07] tmp $./t
/tmp

The output of the "make" command should have been "/tmp/p" and not "/
tmp"
I've tried the equivalent version on Windows and it worked fine.
And I can't see how make could find the Makefile at /tmp/p if the current
directory were another one... (?)

--
Gabriel Genellina

Oct 7 '08 #2

P: n/a
The problem is, he is not printing the name of the current working
directory; he is printing the value of the variable $PWD. *That is
likely set from the environment by the shell he started the Python
program from, but Python does *not* update to reflect changes to
the working directory.
Should I see it as a bug? Should subprocess change this?
Use '@pwd' instead of '@echo $(PWD)'.
I'm using '$(shell pwd)', just wondered why $PWD didn't work.

Thanks for the explanation.
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com

Oct 13 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.