Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module not callable if package is installed from source control #1526

Open
111100001 opened this issue Aug 31, 2024 · 3 comments
Open

module not callable if package is installed from source control #1526

111100001 opened this issue Aug 31, 2024 · 3 comments

Comments

@111100001
Copy link

111100001 commented Aug 31, 2024

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

  1. install my fork using pipx install git+https://github.com/111100001/tubeup.git
  2. type tubeup in the terminal
  3. the error will show up
  4. 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

@Gitznik
Copy link
Contributor

Gitznik commented Sep 2, 2024

Can you please link your fork and the original repo, so I can have a quick look if I can see any issues there?

@111100001
Copy link
Author

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

@Gitznik
Copy link
Contributor

Gitznik commented Sep 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants