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

Cannot install salt-lint because salt-lint requires salt-lint to be able to import __init__.py #308

Closed
clickthisnick opened this issue Apr 25, 2023 · 0 comments · Fixed by #319
Labels
Type: Bug Something isn't working

Comments

@clickthisnick
Copy link

Describe the bug

[2023-04-25T13:38:28.676Z] An unexpected error has occurred: CalledProcessError: command: ('/bin/bash', '/home/myuser/.cache/pre-commit/repokh6trj85/py_env-python3.11/bin/python', '-mpip', 'install', '.')
[2023-04-25T13:38:28.676Z] return code: 1
[2023-04-25T13:38:28.676Z] stdout:
[2023-04-25T13:38:28.676Z]     Processing /home/myuser/.cache/pre-commit/repokh6trj85
[2023-04-25T13:38:28.676Z]       Preparing metadata (setup.py): started
[2023-04-25T13:38:28.676Z]       Preparing metadata (setup.py): finished with status 'error'
[2023-04-25T13:38:28.676Z] stderr:
[2023-04-25T13:38:28.676Z]       error: subprocess-exited-with-error
[2023-04-25T13:38:28.676Z]       
[2023-04-25T13:38:28.676Z]       × python setup.py egg_info did not run successfully.
[2023-04-25T13:38:28.676Z]       │ exit code: 1
[2023-04-25T13:38:28.676Z]       ╰─> [6 lines of output]
[2023-04-25T13:38:28.676Z]           Traceback (most recent call last):
[2023-04-25T13:38:28.676Z]             File "<string>", line 2, in <module>
[2023-04-25T13:38:28.676Z]             File "<pip-setuptools-caller>", line 34, in <module>
[2023-04-25T13:38:28.676Z]             File "/home/myuser/.cache/pre-commit/repokh6trj85/setup.py", line 25, in <module>
[2023-04-25T13:38:28.676Z]               from saltlint import (__author__, __license__,
[2023-04-25T13:38:28.676Z]           ModuleNotFoundError: No module named 'saltlint'
[2023-04-25T13:38:28.676Z]           [end of output]
[2023-04-25T13:38:28.676Z]       
[2023-04-25T13:38:28.676Z]       note: This error originates from a subprocess, and is likely not a problem with pip.
[2023-04-25T13:38:28.676Z]     error: metadata-generation-failed
[2023-04-25T13:38:28.676Z]     
[2023-04-25T13:38:28.676Z]     × Encountered error while generating package metadata.
[2023-04-25T13:38:28.676Z]     ╰─> See above for output.
[2023-04-25T13:38:28.677Z]     
[2023-04-25T13:38:28.677Z]     note: This is an issue with the package mentioned above, not pip.
[2023-04-25T13:38:28.677Z]     hint: See above for details.
[2023-04-25T13:38:28.677Z] Check the log at /home/myuser/.cache/pre-commit/pre-commit.log

To Reproduce
I don't have a great reproduction tutorial but its somewhat described in https://stackoverflow.com/a/2058872

  1. Use python3.11 and install pre-commit in a venv
  2. pre-commit will create its own venv that fallsback to a sys python
  3. Use pre-commit or use a subprocess.Popen to install salt-lint via the setup.py but don't have the cwd set the root of salt-lint repo
  4. pip will not be able to install salt-lint because it's looking for the relative path to salt-lint to import the versioning information

Expected behavior
I should be able to install salt-lint without needing any relative directory or path to be accessible

Desktop (please complete the following information):

  • Redhat
  • 7.9

Additional context

If you'd like me to take a stab at it, I believe if we require python3.8 (remember python3.7 is deprecated https://endoflife.date/python)

Then we can do the following code in the cli.py which is the reason the versioning appears to be in init.py and not just hardcoded in setup.py

$ python3.11
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import version  
>>> version("salt-lint")
'0.9.2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant