On Thu, Jun 1, 2017 at 10:30 AM, Victor Stinner
<victor.stin...@gmail.com> wrote:
> Hi,
>
> Perl 5.26 succeeded to remove the current working directory from the
> default include path (our Python sys.path):
>
> https://metacpan.org/pod/release/XSAWYERX/perl-5.26.0/pod/perldelta.pod#Removal-of-the-current-directory-(%22.%22)-from-@INC
>
> Would it technically possible to make this change in Python? Or would
> it destroy the world? Sorry, it's a naive question (but honestly, I
> don't know the answer.)
>
> My main use case for "." in sys.path is to be to run an application
> without installing it: run ./hachoir-metadata which loads the Python
> "hachoir" module from the script directory. Sometimes, I run
> explicitly "PYTHONPATH=$PWD ./hachoir-metadata".
>
> But I don't think that running an application from the source without
> installing it is the most common way to run an application. Most users
> install applications to use them, no?
>
> Enabling the isolated mode already prevents "." to be added to
> sys.path: -I command line option.
> https://docs.python.org/dev/using/cmdline.html#cmdoption-I
>
> There is also an old idea of a "restricted" system Python which would
> use a "fixed" sys.path.

FYI, PEP 432 (Restructuring the CPython startup sequence) [1]
facilitates efforts along these lines.  It even proposes adding a
system-python binary to the cpython build.

More specific to the matter of sys.path[0], there's a long-standing
issue (#13475) [2] that discusses the topic and some solutions.  Note
that progress on the issue was blocked by desire to clean up
interpreter startup (i.e. PEP 432) first, which has now been
accomplished as of the recent PyCon sprints.

-eric

[1] https://www.python.org/dev/peps/pep-0432/
[2] http://bugs.python.org/issue13475
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to