[Scons-users] Crash with scons 3.1.2 on win when using --enable-virtualenv

Hans-Christian Wild hchr.wild at gmail.com
Wed Apr 15 19:38:07 EDT 2020


Dear all!

I am facing a crash with scons 3.1.2 and Python3.8 on Windows when using
--enable-virtualenv.

The root cause is tracked down easily:

In Platform/virtualenv.py, function _is_path_in() uses os.path.relpath() to
detect if a env path is within the virtualenv and should thus be imported.

The problem I am facing is that I have paths of different drive letters in
my path and that os.path.relpath throws a ValueError (from ntpath.py) when
being asked to compute the relative path between e.g. c:/some/dir and
d:/another/dir.

This ValueError is not caught gracefully, instead scons crashes.

Simple as I am, I can fix the crash by manually altering the function to:

(i.e. by putting an try ... except ValueError around os.path.relpath)
def _is_path_in(path, base):
    """Returns true, if **path** is located under the **base** directory."""
    if not path or not base: # empty path may happen, base too
        return False
    try:
        rp = os.path.relpath(path, base)
    except ValueError:
        return False
    return ((not rp.startswith(os.path.pardir)) and (not
 rp == os.path.curdir))

On a side note, I have noticed that scons is already rudimentarily aware of
pipenv (which is what I am using). It does import only PIPENV_ACTIVE from
the environment however.

Do you think that it would be an improvement to import any "PIPENV_*"
environment variable found instead?

I do understand that it is a principle of SCons to be as environment
agnostic as possible, however I as user I would expect that SCons behaves
as close as possible inside and outside of scons to the users (virtual)
enviroment settings.

The latter point is clearly optional (this is my first post on this list).

I am also aware of that I would be able to work around of any of the above
limitations by doing the environment variable setup manually.

Kind Regards
Hans
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20200416/77e41e68/attachment.html>


More information about the Scons-users mailing list