AcademySoftwareFoundation / AcademySoftwareFoundation/rez
Cannot call get_developer_package on a previously modified package
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 374
- Avg merge
- 9d 12h
- Merged PRs (30d)
- 5
Description
If you call `get_developer_package`, modify the package.py, and then call it again on the same directory, you get a serialization error.
Re-production Steps:
```python
import os
import textwrap
from rez import packages_
path = "/tmp/testout"
package_path = os.path.join(path, "package.py")
with open(package_path, "w") as handler:
handler.write(
textwrap.dedent(
"""\
# -*- coding: utf-8 -*-
name = "foo_bar"
version = "1.0.0"
build_command = "echo 'asdf'"
def commands():
pass
"""
)
)
package = packages_.get_developer_package(path)
with open(package.filepath, "w") as handler:
handler.write(
textwrap.dedent(
"""\
# -*- coding: utf-8 -*-
name = "foo_bar"
version = "1.1.0"
requires = [
"python-2",
]
build_command = "echo 'asdf'"
def commands():
pass
"""
)
)
package = packages_.get_developer_package(path)
```
Running the code above on Linux creates this traceback
```
Traceback (most recent call last):
File "/home/selecaotwo///temp/test.py", line 303, in
package = packages_.get_developer_package(path)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/packages.py", line 601, in get_developer_package
return DeveloperPackage.from_path(path, format=format)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/developer_package.py", line 92, in from_path
data = load_from_file(filepath, format_, disable_memcache=True)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 124, in load_from_file
update_data_callback=update_data_callback)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 161, in _load_file
result = load_func(f, filepath=filepath)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 218, in load_py
return _load_py(stream, filepath=filepath)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 256, in _load_py
result = process_python_objects(result, filepath=filepath)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 380, in process_python_objects
data = _process(data)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 298, in _process
value[k] = _process(v)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/serialise.py", line 353, in _process
eval_as_function=False)
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/utils/sourcecode.py", line 104, in __init__
self._init_from_func()
File "/home/selecaotwo/packages/rez/2.53.0/platform-linux/arch-x86_64/os-CentOS-7.6.1810/rez/utils/sourcecode.py", line 124, in _init_from_func
loc = getsourcelines(self.func)[0][len(self.decorators) + 1:]
File "/usr/lib64/python2.7/inspect.py", line 690, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib64/python2.7/inspect.py", line 580, in findsource
if pat.match(lines[lnum]): break
IndexError: list index out of range
```
Given that `get_developer_package` loads packages directly and not from memcache, I would've expected this to work, no matter how many times I modified the original package.py.
If there's a simple way to get around this issue (e.g. flushing data or some other method) please let me know. Thank you!
Contributor guide
Research direction
Start with packages_.get_developer_package in rez/packages.py and follow DeveloperPackage.from_path in rez/developer_package.py into load_from_file and process_python_objects in rez/serialise.py. Reproduce the issue with the provided script, then inspect the SourceCode handling in rez/utils/sourcecode.py. Done means loading the same directory again after modifying package.py succeeds without a serialization error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100