[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-11 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Thanks, I've misunderstood how it works. It makes sense now. Closing as not a 
bug.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-06 Thread Christian Heimes


Christian Heimes  added the comment:

The cache prefix mirrors the directory structure. Python takes the absolute 
path to the .py file, converts the path to a relative path by stripping off the 
leading slash, and finally joins the path with the prefix.

Take this example:

$ PYTHONPYCACHEPREFIX=/tmp/pycache python3.10 -c pass

This will create the cache file 
"/tmp/pycache/usr/lib64/python3.10/os.cpython-310.pyc" for the Python file 
"/usr/lib64/python3.10/os.py.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-05 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Can this also create the risk of 'path too long' issues?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-05 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

If CWD=/a/b and pycache_prefix=c, the resulting dir is /a/b/c as I would expect.

If CWD=/a/b and pycache_prefix='', I would expect resulting dir to be /a/b 
 instead of /a/b/a/b .

For example as the shell `cd` command accepts relative path as arg, I would 
expect that `cd c` changes to /a/b/c ; but it would be very strange to expect 
`cd ` with empty arg to change to /a/b/a/b .

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-05 Thread Christian Heimes


Christian Heimes  added the comment:

It works as designed and documented. An empty string is considered a relative 
directory.

https://docs.python.org/3/library/sys.html#sys.pycache_prefix


> If this is set (not None), Python will write bytecode-cache .pyc files to 
> (and read them from) a parallel directory tree rooted at this directory...
>
> A relative path is interpreted relative to the current working directory.

--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

(I forgot to mention this happens on MacOS).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45977] Unexpected effect of sys.pycache_prefix = ""

2021-12-03 Thread Andrei Kulakov


New submission from Andrei Kulakov :

Setting sys.pycache_prefix = "", re-creates CWD structure under current 
directory, e.g. if run from /Users/foo/test, will create 
/Users/foo/test/Users/foo/test/myfile.pyc . Is that intentional? It seems a 
little weird. At least it might be good to document it.

--
components: Interpreter Core
messages: 407632
nosy: andrei.avk
priority: low
severity: normal
status: open
title: Unexpected effect of sys.pycache_prefix = ""
type: behavior
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com