AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
949 stars 338 forks source link

Canonical way to delete "env" variable? #875

Open KelSolaar opened 4 years ago

KelSolaar commented 4 years ago

Hi,

I'm trying to delete a variable in an env attribute in my commands definition and I'm having a hard time. Any idea?

C:\Users\thomas>rez -V
Rez 2.47.2

Cheers,

Thomas

KelSolaar commented 4 years ago

So it seems like unsetenv does work but not quite fully. I just lost 2 hours on that...

    print(env.OCIO_ACTIVE_DISPLAYS)
    unsetenv('OCIO_ACTIVE_DISPLAYS')
    print(env.OCIO_ACTIVE_DISPLAYS)
Display 1:Display 2
Display 1:Display 2

But then in Maya:

import os
print os.environ['OCIO_ACTIVE_DISPLAYS']
# Error: OCIO_ACTIVE_DISPLAYS
# Traceback (most recent call last):
#   File "<maya console>", line 2, in <module>
#   File "[...]maya\bin\python27.zip\os.py", line 425, in __getitem__
#     return self.data[key.upper()]
# KeyError: 'OCIO_ACTIVE_DISPLAYS' # 

So it does unset the variable but it is partially cached somewhere still...

nerdvegas commented 4 years ago

Looks like a bug to me. Let's ticket it up. Thx A

On Wed, Apr 15, 2020 at 3:11 PM Thomas Mansencal notifications@github.com wrote:

So it seems like unsetenv does work but not quite fully. I just lost 2 hours on that...

print(env.OCIO_ACTIVE_DISPLAYS)
unsetenv('OCIO_ACTIVE_DISPLAYS')
print(env.OCIO_ACTIVE_DISPLAYS)

Display 1:Display 2 Display 1:Display 2

But then in Maya:

import osprint os.environ['OCIO_ACTIVE_DISPLAYS']# Error: OCIO_ACTIVE_DISPLAYS# Traceback (most recent call last):# File "", line 2, in # File "[...]maya\bin\python27.zip\os.py", line 425, in getitem# return self.data[key.upper()]# KeyError: 'OCIO_ACTIVE_DISPLAYS' #

So it does unset the variable but it is partially cache somewhere still...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nerdvegas/rez/issues/875#issuecomment-613820012, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMOUSUJIRFGNGGHW3X4OEDRMU6YBANCNFSM4MIH2OBQ .

KelSolaar commented 4 years ago

It really drove me nuts yesterday, went through the code (rez\utils\data_utils.py, rez\rex.py) which is really hard to follow with multiple nested data structure referencing each others. It would certainly benefit from documentation and a solid battery of unit tests. Thing that did not help is that I only found unsetenv very late too, might be worth referencing directly around here: https://github.com/nerdvegas/rez/wiki/Package-Commands#variable-appending-and-prepending and not at the very end.