[Cython] Why does embed-position use relative filenames?

Stefan Behnel stefan_ml at behnel.de
Wed Oct 25 10:45:14 EDT 2017


Jeroen Demeyer schrieb am 25.10.2017 um 14:50:
> On 2017-10-25 14:42, Erik Bray wrote:
>> IMO the relative paths make more sense in a way, because when the
>> module is installed the path is relative to the file's location
>> relative to its `sys.path` entry.
>>
>> If it defaulted to absolute paths
> 
> I didn't say that it should default to absolute paths. I am saying that it
> should take the path how it received from the caller. Don't make it
> relative or absolute.

There is usually a mix of absolute *and* relative paths in the compilation,
e.g. for files that are included, found via include/pythonpath, referenced
relative to the current file, etc. That makes it 'difficult' to put
anything consistent into the files. As Erik mentioned, absolute file paths
are also somewhere between useless and misleading after installation. Plus,
it's usually not a good idea to leak information about the developers' home
directory structure into the generated C code. Those are the reasons why
there is a strong preference for relative paths in Cython in general. In
fact, it's quite actively trying to avoid writing absolute paths into the
generated files.

I could imagine doing something at runtime to construct the then valid
absolute paths, but usually, source files won't actually be available at
runtime anyway, so that's also not all that useful.

In short: it's far from obvious to me if and how this should be improved.

Stefan


More information about the cython-devel mailing list