jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.67k stars 608 forks source link

pip-compile 6.12.2: AttributeError: 'InstallRequirement' object has no attribute 'install_options'. Did you mean: 'global_options' #2037

Closed swiss-knight closed 8 months ago

swiss-knight commented 8 months ago

Hello,

When running pip-compile 6.12.2 on a requirements file I end up on this error:

$ pip-compile requirements_dev.in 

/usr/local/lib/python3.10/dist-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
WARNING: the legacy dependency resolver is deprecated and will be removed in future versions of pip-tools. The default resolver will be changed to 'backtracking' in pip-tools 7.0.0. Specify --resolver=backtracking to silence this warning.
Traceback (most recent call last):
  File "/usr/local/bin/pip-compile", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/piptools/scripts/compile.py", line 589, in cli
    results = resolver.resolve(max_rounds=max_rounds)
  File "/usr/local/lib/python3.10/dist-packages/piptools/resolver.py", line 253, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.10/dist-packages/piptools/resolver.py", line 324, in _resolve_one_round
    constraints = sorted(self.constraints, key=key_from_ireq)
  File "/usr/local/lib/python3.10/dist-packages/piptools/resolver.py", line 222, in constraints
    return set(
  File "/usr/local/lib/python3.10/dist-packages/piptools/resolver.py", line 310, in _group_constraints
    yield combine_install_requirements(ireqs)
  File "/usr/local/lib/python3.10/dist-packages/piptools/resolver.py", line 136, in combine_install_requirements
    combined_ireq = copy_install_requirement(
  File "/usr/local/lib/python3.10/dist-packages/piptools/utils.py", line 459, in copy_install_requirement
    "install_options": template.install_options,
AttributeError: 'InstallRequirement' object has no attribute 'install_options'. Did you mean: 'global_options'

Environment Versions

  1. OS Type: "22.04.3 LTS (Jammy Jellyfish)"
  2. Python version: $ python -V: Python 3.10.12
  3. pip version: $ pip --version: pip 23.3.2 from /usr/local/lib/python3.10/dist-packages/pip (python 3.10)
  4. pip-tools version: $ pip-compile --version:
    /usr/local/lib/python3.10/dist-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
    warnings.warn("Setuptools is replacing distutils.")
    pip-compile, version 6.12.

Steps to replicate

See description here above.

Expected result

A working run of pip-compile.

Actual result

The run stops on the error mentioned in the description here above.

Thanks for your great work around pip and any hint you can provide to solve this issue! 🙂

webknjaz commented 8 months ago

I think pip was going to remove those. Perhaps, it did already. Try an older version.

webknjaz commented 8 months ago

Ah, you're using old pip-tools. Use the current version and it typically works with the current pip.

swiss-knight commented 8 months ago

Indeed, my bad, I thought pip-compile came as a side-package with pip. I didn't remember it was a pip-tools friend. After upgrading the latest to 7.3.0 everything went fine. I'm closing the current issue. Thanks.