pipx
pipx copied to clipboard
module not callable if package is installed from source control
Describe the bug
when i install a fork i made using this command:
pipx install git+https://github.com/111100001/tubeup.git
it installs it fine, but when i try to use it, is says this:
tubeup
Traceback (most recent call last):
File "/home/lucky/.local/bin/tubeup", line 8, in <module>
sys.exit(__main__())
TypeError: 'module' object is not callable
then i found out the file in .local/bin/tubeup is different than the one that is made when the main tubeup is installed normally.
the .local/bin file that pipx made using pipx install git+https://github.com/111100001/tubeup.git :
#!/home/lucky/.local/pipx/venvs/tubeup/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from tubeup import __main__
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(__main__())
the .local/bin file that is made when i install the main tubeup branch using pipx install tubeup :
#!/home/lucky/.local/pipx/venvs/tubeup/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from tubeup.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
i copied the main tubeup bin file and pasted it in the fork version that i installed and it worked.
How to reproduce
- install my fork using
pipx install git+https://github.com/111100001/tubeup.git - type tubeup in the terminal
- the error will show up
- to fix: change the .local/bin/tubeup file to this file (this is the file that is made with
pipx install tubeup:
#!/home/lucky/.local/pipx/venvs/tubeup/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from tubeup.__main__ import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Expected behavior tuebup wokrs normally when installed from source control
Can you please link your fork and the original repo, so I can have a quick look if I can see any issues there?
Can you please link your fork and the original repo, so I can have a quick look if I can see any issues there?
both repos are in the commands above, but here they are:
my fork: https://github.com/111100001/tubeup
the original repo: https://github.com/bibanon/tubeup
It seems the scripts definition in the pyproject.toml is the culprit here. This error happens as well, wenn you install tubeup from the main repo.
I fixed it by changing the scripts from:
[project.scripts]
tubeup = "tubeup:__main__"
to
[project.scripts]
tubeup = "tubeup.__main__:main"
For reference, see my fork and try installing from there.
Looks like setup.py somehow makes the scripts path work when building the package, but installing directly from source, the first version does not work. Mind that this is not pipx functionality (we have nothing to do with the creation of the .../bin/python files). This is handled by pip itself.