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

BUG: Packaging in broken #326

Open
Sann5 opened this issue Jan 2, 2024 · 0 comments · May be fixed by #327
Open

BUG: Packaging in broken #326

Sann5 opened this issue Jan 2, 2024 · 0 comments · May be fixed by #327

Comments

@Sann5
Copy link

Sann5 commented Jan 2, 2024

TLDR

When installing q as a python package from the source, calling q fails because the bin package is not found (essentially because installation fails).

Reproduce the error

Let's say I want to install q as a python package using pip and the provided setup.py. Namely,

wget https://github.com/harelba/q/archive/v3.1.6.tar.gz
gunzip q-3.1.6.gz
cd q-3.1.6
conda create --name q python=3.8
conda activate q
PYTHON -m pip install . -vv 
q -h

The last command gives an error:

Traceback (most recent call last):
  File "/path/to/my/envs/q/bin/q", line 5, in <module>
    from bin.q import run_standalone
ModuleNotFoundError: No module named 'bin'

/path/to/my/envs/q/bin/q is a script that is generated by the PYTHON -m pip install . -vv for the console script defined in setup.py. It looks like this...

#!/Users/santiago/mambaforge/envs/q/bin/PYTHON
# -*- coding: utf-8 -*-
import re
import sys
from bin.q import run_standalone
if __name__ == '__main__':
  sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
  sys.exit(run_standalone())

Essentially the issue is that there is no package bin in the environment.

Solution

Adjust the setup.py as follows:

setup(
...
    package_dir={"": "bin"}, # delete this line since its not needed
    packages=setuptools.find_packages(), 
    # originally: packages=setuptools.find_packages(where="bin")
...

Additional considerations

One might want to reconsider renaming the bin folder to q (since it is quite weird to have a package named bin). Then import statements in test_suite.py and the console script in setup.py would have to be adjusted. I don't know what else could break thou.

@Sann5 Sann5 linked a pull request Jan 2, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant