Problem with Python on MAC OSX

E

edadk

Hi

I have problem with Python on MAC OSX. The following code documents it

strib:~ eda$ pwd
/home/eda
strib:~ eda$ python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Note I would have expected

print os.getcwd()

to print

/home/eda

Note that
/home/eda
0

Of course /home/eda is a symbolic link to /private/home/eda. Is this a
bug or a feature? Is there a good way to work around it?

Regards

Erling
 
R

Reinhold Birkenfeld

edadk said:
Hi

I have problem with Python on MAC OSX. The following code documents it

strib:~ eda$ pwd
/home/eda
strib:~ eda$ python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Note I would have expected

print os.getcwd()

to print

/home/eda

Note that
/home/eda
0

Of course /home/eda is a symbolic link to /private/home/eda. Is this a
bug or a feature? Is there a good way to work around it?

I can see the same behaviour here under Linux.

There is no way to work around that, only using the PWD environment
variable set by the shell. The standard POSIX function getcwd(), which
Python's os.getcwd utilizes, returns an absolute path to the current
directory, that is, without any symlinks in it. The shell, in the
contrary, keeps track of what symlinked directories you enter, and can
tell you these.

But why don't you like the result? The directories pointed to by both
paths are the same...

Reinhold
 
E

edadk

Hi,

But why don't you like the result? The directories pointed to by both
paths are the same...

This feature is casuing problem when I use the Scons build. See
www.scons.org.

It call external tools to do various thing for instance calling the
perforce source control commandline tool p4 via spawn. So when Scons
do something like

'p4 sync file.c'

perforce gets confused because it wants to work with

/home/eda/file.c

and not

/private/home/eda/file.c

I agree in most case this feature is not causing any problems but
sometimes it does.

Regards

Erling
 
R

Reinhold Birkenfeld

edadk said:
Hi,



This feature is casuing problem when I use the Scons build. See
www.scons.org.

It call external tools to do various thing for instance calling the
perforce source control commandline tool p4 via spawn. So when Scons
do something like

'p4 sync file.c'

perforce gets confused because it wants to work with

/home/eda/file.c

and not

/private/home/eda/file.c

I agree in most case this feature is not causing any problems but
sometimes it does.

So you must resort to using the shell-set $PWD -- the kernel does not
keep track of your current directory in the terms of links.

Reinhold
 
R

Ronald Oussoren

Hi

I have problem with Python on MAC OSX. The following code documents it

strib:~ eda$ pwd
/home/eda
strib:~ eda$ python
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Note I would have expected

print os.getcwd()

to print

/home/eda

Note that
/home/eda
0

Of course /home/eda is a symbolic link to /private/home/eda. Is this a
bug or a feature? Is there a good way to work around it?

It's a normal Unix feature.

The thing that surprices me is that that your home directory is in
/home in the first place. The standard location for home directories on
OSX is /Users.

Ronald
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top