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

No module named kmerdb in the bin script from pyproject.toml's entry_point. #97

Open
MatthewRalston opened this issue Dec 27, 2022 · 5 comments
Assignees
Labels
bug Something isn't working dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed invalid This doesn't seem right

Comments

@MatthewRalston
Copy link
Owner

Traceback (most recent call last):
  File "path/to/python-version/bin/kmerdb", line 5, in <module>
    from kmerdb import cli
ModuleNotFoundError: No module named 'kmerdb'
@MatthewRalston MatthewRalston added bug Something isn't working documentation Improvements or additions to documentation good first issue Good for newcomers invalid This doesn't seem right dependencies Pull requests that update a dependency file labels Dec 27, 2022
@MatthewRalston MatthewRalston added this to the V0.7 stable? milestone Dec 27, 2022
@MatthewRalston MatthewRalston self-assigned this Dec 27, 2022
@MatthewRalston
Copy link
Owner Author

@MatthewRalston
Copy link
Owner Author

What is my environment?

Python 3.10.1
pip 22.3.1

What have I tried?

cd kmerdb
python -m build
pip install -I dist/kmerdb-0.7.2-py3-none-any.whl

Install completes successfully.

pyproject.toml

[build-system]
requires = ["setuptools", "wheel", "numpy>=1.19.0", "Cython>=0.29.21"]
build-backend = "setuptools.build_meta"

[project]
name = "kmerdb"
version = "0.7.2"
description = "Yet another kmer library for Python"

#...


[project.entry-points]
console_scripts = {kmerdb = "kmerdb:cli"}

Expected

I expect the installed bin script to not produce the following.

(kdb) [matt@argo] git:pyprojecttoml_build_twine+ </ffast2/kdb>>kmerdb -h
Traceback (most recent call last):
  File "/home/matt/.pyenv/versions/kdb/bin/kmerdb", line 5, in <module>
    from kmerdb import cli
ModuleNotFoundError: No module named 'kmerdb'
(kdb) [matt@argo] git:pyprojecttoml_build_twine+ </ffast2/kdb>>python
Python 3.10.1 (main, Jan  1 2022, 21:28:19) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import kmerdb
>>> # Imports successfully
(kdb) [matt@argo] git:pyprojecttoml_build_twine+ </ffast2/kdb>>cat ~/.pyenv/versions/kdb/bin/kmerdb 
#!/home/matt/.pyenv/versions/3.10.1/envs/kdb/bin/python3.10
# -*- coding: utf-8 -*-
import re
import sys
from kmerdb import cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

@MatthewRalston
Copy link
Owner Author

Issue borking the debug process on my end: pyenv/pyenv#2572

@MatthewRalston MatthewRalston added the help wanted Extra attention is needed label Dec 28, 2022
@MatthewRalston
Copy link
Owner Author

It seems that this is a generic issue regardless of the virtualenv strategy I'm using. For PyPI folks who may come here, know that I've ruled out a middleware-specific issue by using both classical virtualenv and pyenv virtualenv scenarios to instantiate my Python virtual environment.

The issue is that regardless of whether my python package kmerdb command is invoked from a pyenv shim, or classically with the bin script produced by setup on installation of my wheel, built with python -m build, it has an invalid pythonpath somehow in the shell script.

Virtualenv, pip, setuptools, and python versions can all be found in the relevant issues in your repository.
But again,
pip 22.3.1
virtualenv 20.17.1
python 3.10.1
setuptools 61.0 (specified in pyproject.toml)

The legacy setup.py which did produce the correct bin script can be found here

@MatthewRalston
Copy link
Owner Author

What's interesting is that the virtualenv seems to be setting my pythonpath correctly, so i can still import and invoke the module independently, just can use the kmerdb bin script. For example, the one found at .venv/bin/kmerdb, with the contents as described previously:

#!path/to/.venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from kmerdb import cli
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(cli())

Which again produces the output as above, regarding the kmerdb module not being available to the bin script.

Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant