Instagram / Instagram/LibCST

[support] running test suite doesn’t find libcst.native

Open
#1,176 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

When packaging libCST for openSUSE, I fail to make running test suite. We build our packages in the network-isolated environment, and we want the simplest possible environment, so I am trying to run test suite (with installed libraries) just with (effectively):

```sh
export PATH=/home/abuild/rpmbuild/BUILD/libcst-1.4.0/build/flavorbin:/usr/local/bin:/usr/bin:/bin
export PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-libcst-test-1.4.0-0.x86_64/usr/lib/python3.10/site-packages
PYTHONDONTWRITEBYTECODE=1
python3.10 -m unittest discover -v libcst/tests
```

However, even with (hopefully) correctly set `PATH` and `PYTHONPATH`, 42 tests are not able to find `libcst.native` (even though the `*.so` is in the right place) and error, for example:

```
[ 103s] test_leaky_codemod (test_e2e.ToolE2ETest) ... Executing codemod...
[ 103s] Failed to determine module name for /tmp/tmp4wbthukg/example.py: '/tmp/tmp4wbthukg/example.py' is not in the subpath of '' OR one path is relative and the other is absolute.
[ 103s] Codemodding /tmp/tmp4wbthukg/example.py
[ 103s] Traceback (most recent call last):
[ 103s] File "/home/abuild/rpmbuild/BUILD/libcst-1.4.0/libcst/codemod/_cli.py", line 276, in _execute_transform
[ 103s] input_tree = parse_module(
[ 103s] File "/home/abuild/rpmbuild/BUILD/libcst-1.4.0/libcst/_parser/entrypoints.py", line 109, in parse_module
[ 103s] result = _parse(
[ 103s] File "/home/abuild/rpmbuild/BUILD/libcst-1.4.0/libcst/_parser/entrypoints.py", line 42, in _parse
[ 103s] from libcst.native import parse_expression, parse_module, parse_statement
[ 103s] ModuleNotFoundError: No module named 'libcst.native'
[ 103s]
[ 103s] Failed to codemod /tmp/tmp4wbthukg/example.py
```

It seems that the generated test script doesn’t follow `PYTHONPATH`?

[Complete build log](https://github.com/user-attachments/files/16332259/_log-unittest.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.