pygments
pygments copied to clipboard
make test fails with can't find '__main__' module
I also tried make all
with similar results.
$ git reset --hard && git clean -fd && make clean && make test
HEAD is now at b58e855e Fix syntax highlighting of INI language (#2217)
find . -name '__pycache__' -exec rm -rf {} +
rm -rf doc/_build build Pygments.egg-info
rm -f codetags.html
/usr/bin/python3: can't find '__main__' module in '/home/abentley/hacking/pygments/tests'
make: *** [Makefile:53: test] Error 1
This was with b58e855e41b9266f8412823dbb260d1b8e49b45f
What version of Python is this?
Python 3.10.4 from Ubuntu 22.04
$ apt-cache show python3|grep Version
Version: 3.10.4-0ubuntu2
$ python3 --version
Python 3.10.4
To reproduce from scratch with lxc:
$ lxc launch ubuntu:22.04 pygments-test
Creating pygments-test
Starting pygments-test
$ lxc shell pygments-test
root@pygments-test:~# su ubuntu
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@pygments-test:/root$ cd
ubuntu@pygments-test:~$ git clone https://github.com/pygments/pygments.git
Cloning into 'pygments'...
remote: Enumerating objects: 43026, done.
remote: Counting objects: 100% (69/69), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 43026 (delta 31), reused 21 (delta 9), pack-reused 42957
Receiving objects: 100% (43026/43026), 23.23 MiB | 8.58 MiB/s, done.
Resolving deltas: 100% (33840/33840), done.
ubuntu@pygments-test:~$ sudo apt install make
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libfreetype6
Use 'sudo apt autoremove' to remove it.
Suggested packages:
make-doc
The following NEW packages will be installed:
make
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 180 kB of archives.
After this operation, 426 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 make amd64 4.3-4.1build1 [180 kB]
Fetched 180 kB in 6s (31.5 kB/s)
Selecting previously unselected package make.
(Reading database ... 33824 files and directories currently installed.)
Preparing to unpack .../make_4.3-4.1build1_amd64.deb ...
Unpacking make (4.3-4.1build1) ...
Setting up make (4.3-4.1build1) ...
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@pygments-test:~$ cd pygments
ubuntu@pygments-test:~/pygments$ make test
/usr/bin/python3: can't find '__main__' module in '/home/ubuntu/pygments/tests'
make: *** [Makefile:53: test] Error 1
Ah, I bet that you have not installed pytest
. Please do pip install -r requirements.txt
(as always when starting to hack on a Python project).
Our Makefile doesn't handle this very well, it does $(PYTHON) `which pytest`
, which expands like $(python) ""
. It should probably do $(PYTHON) -m pytest
.
Yes, that fixes it. Sorry, I'd previously installed pygments through pip, so it had all its runtime deps and I forgot to install requirements. Still, a better error would help.
Maybe we should just give up the indirection in the Makefile and call pytest
instead of $(PYTHON) $(which pytest)
?
Those who want to use a different interpreter or pytest can just call the commands directly, it's not like the Makefile has much other magic going.