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: Requirements.txt handling throws CouldNotInstallRequirements #1599

Open
yaleman opened this issue Feb 23, 2025 · 3 comments
Open

BUG: Requirements.txt handling throws CouldNotInstallRequirements #1599

yaleman opened this issue Feb 23, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@yaleman
Copy link
Contributor

yaleman commented Feb 23, 2025

Description

Including a requirements.txt file exported from pip freeze causes ucc-gen build to fail with the following error:

INFO: Installing requirements from package/lib/requirements.txt
INFO: Executing: python3 -m pip install --upgrade pip
ERROR: Command (pip upgrade) returned 1 status code
Traceback (most recent call last):
  File ".venv/bin/ucc-gen", line 10, in <module>
    sys.exit(main())
  File ".venv/lib/python3.9/site-packages/splunk_add_on_ucc_framework/main.py", line 244, in main
    build.generate(
  File ".venv/lib/python3.9/site-packages/splunk_add_on_ucc_framework/commands/build.py", line 494, in generate
    install_python_libraries(
  File ".venv/lib/python3.9/site-packages/splunk_add_on_ucc_framework/install_python_libraries.py", line 186, in install_python_libraries
    install_libraries(
  File ".venv/lib/python3.9/site-packages/splunk_add_on_ucc_framework/install_python_libraries.py", line 268, in install_libraries
    _pip_install(
  File ".venv/lib/python3.9/site-packages/splunk_add_on_ucc_framework/install_python_libraries.py", line 84, in _pip_install
    raise CouldNotInstallRequirements
splunk_add_on_ucc_framework.install_python_libraries.CouldNotInstallRequirements

I have tried a list of packages:

certifi
charset-normalizer
defusedxml
deprecation
httplib2
idna
packaging
pyparsing
pysocks
requests
solnlib
sortedcontainers
splunk-sdk
splunktaucclib
urllib3

or a full pip freeze output:

certifi==2025.1.31
charset-normalizer==3.4.1
defusedxml==0.7.1
deprecation==2.1.0
httplib2==0.22.0
idna==3.10
packaging==24.2
pyparsing==3.2.1
pysocks==1.7.1
requests==2.32.3
solnlib==6.1.0
sortedcontainers==2.4.0
splunk-sdk==2.1.0
splunktaucclib==7.0.0
urllib3==1.26.20

What UCC version are you using?

5.58.1

Additional System Info

python 3.9.6

@yaleman yaleman added bug Something isn't working triage Pending triage from maintainers labels Feb 23, 2025
@yaleman
Copy link
Contributor Author

yaleman commented Feb 23, 2025

Figured it out - my local virtualenv didn't have pip - can you please improve the errors so they're actionable? Perhaps patch _pip_install so it's more like:

def _pip_install(installer: str, command: str, command_desc: str) -> None:
    cmd = f"{installer} -m pip install {command}"
    try:
        result = _subprocess_run(command=cmd, command_desc=command_desc)
        if result.returncode != 0:
            raise CouldNotInstallRequirements(result.stderr.decode('utf-8'))
    except OSError as e:
        raise CouldNotInstallRequirements from e

@artemrys
Copy link
Member

thanks @yaleman, I believe we are now working on the ticket to improve error messages in this module! we will take your feedback into account!

FYI @sgoral-splunk

@artemrys artemrys removed the triage Pending triage from maintainers label Feb 24, 2025
@yaleman
Copy link
Contributor Author

yaleman commented Feb 24, 2025

Thanks @artemrys 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants