Skip to content

setup.py fails if odbc_config can't be found #1213

Open
@RA80533

Description

@RA80533

Issue

setup.py attempts to run odbc_config in the user's shell via os.popen():

pyodbc/setup.py

Line 204 in 7b4e277

pipe = os.popen('odbc_config --cflags --libs 2>/dev/null')

It then calls readlines() and assumes there will be at least 2 values to unpack and assign to cflags and ldflags:

pyodbc/setup.py

Line 205 in 7b4e277

cflags, ldflags = pipe.readlines()

If odbc_config isn't found in the user's PATH, readlines() won't unpack anything and a ValueError will be raised. This issue is likely often to occur when a user is attempting to install pyodbc where it unfortunately produces an unhelpful error:

(example) RA80533@mbp example % python -m pip install --pre --no-binary :all: pyodbc
Collecting pyodbc
  Using cached pyodbc-4.0.39.tar.gz (282 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/Users/RA80533/Desktop/example/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/RA80533/Desktop/example/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/RA80533/Desktop/example/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/rx/mgpqyfxd01q4w5yhxdctdfcm0000gn/T/pip-build-env-b_hshvm7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/rx/mgpqyfxd01q4w5yhxdctdfcm0000gn/T/pip-build-env-b_hshvm7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/rx/mgpqyfxd01q4w5yhxdctdfcm0000gn/T/pip-build-env-b_hshvm7/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 371, in <module>
        File "<string>", line 77, in main
        File "<string>", line 205, in get_compiler_settings
      ValueError: not enough values to unpack (expected 2, got 0)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions