simplest way to visit 3 subdirectories with a command?

D

dmitrey

hi all,
could you inform how to compose a py-file (for soft installation),
that will visit 3 subdirectories (eg subdir1, subdir2, subdir3) and
invoke a command "python setup.py install" in each subdirectory?
I know there should be a simple solution available in Python
documentation, but I have an awful lots of other things to be done, so
could someone write these several lines of code?

Thank you in advance, D.
 
T

Tim Chase

could you inform how to compose a py-file (for soft installation),
that will visit 3 subdirectories (eg subdir1, subdir2, subdir3) and
invoke a command "python setup.py install" in each subdirectory?
I know there should be a simple solution available in Python

If you're executing "python setup.py install", that sounds like
you're operating at the shell level, not within python. In which
case, I'd just use my shell's iteration capabilities:

# running bash on a *nix-like OS
bash$ for dir in subdir1 subdir2 subdir3; do pushd $dir;
python setup.py install; popd; done

# running within Win32's cmd.exe
c:\temp\> for %f in (subdir1 subdir2 subdir3) do pushd %f &
python setup.py install & popd

or something of the sort. Remember in Win32 that the variables
have to be escaped if you put them in a batch file ("%%f" instead
of "%f")

-tkc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top