[BUG] `python -i -m cudf.pandas foo.py` does not leave interpreter with variables from `foo.py` in scope
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the bug**
I think this is because the runpy commands we're using return the scripts globals dictionary and we need to use this to update the outer globals dict.
Note that the [runpy documentation](https://docs.python.org/3/library/runpy.html) says:
> [...], any functions and classes defined by the executed code are not guaranteed to work correctly after a [runpy](https://docs.python.org/3/library/runpy.html#module-runpy) function has returned. If that limitation is not acceptable for a given use case, [importlib](https://docs.python.org/3/library/importlib.html#module-importlib) is likely to be a more suitable choice than this module.
**Steps/Code to reproduce bug**
```python
(cudfdev) /cudf$ cat foo.py
VALUE = 1
(cudfdev) /cudf$ python -i foo.py
>>> VALUE
1
>>> exit()
(cudfdev) /cudf$ python -i -m cudf.pandas foo.py
>>> VALUE
Traceback (most recent call last):
File "", line 1, in
NameError: name 'VALUE' is not defined
>>> exit()
```
**Expected behavior**
```python
(cudfdev) /cudf$ python -i -m cudf.pandas foo.py
>>> VALUE
1
```
**Environment overview (please complete the following information)**
- Environment location: [Bare-metal]
- Method of cuDF install: [from source]
Contributor guide
Assessment
This issue has not been assessed yet.