coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
514 stars 89 forks source link

Local installation fails using `pyproject.toml` #319

Closed bchardin closed 1 year ago

bchardin commented 1 year ago

Pip fails to install a fresh clone of the repository using the provided pyproject.toml configuration file.

The command used is:

python3 -m pip install --editable .

Its output is:

Obtaining file:///data/dev/python-mip
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [48 lines of output]
      configuration error: `project.optional-dependencies.{data__optionaldependencies_key}[{data__optionaldependencies_val_x}]` must be pep508
      DESCRIPTION:
          Project dependency specification according to PEP 508

      GIVEN VALUE:
          "gurobipy>=8.*"

      OFFENDING RULE: 'format'

      DEFINITION:
          {
              "$id": "#/definitions/dependency",
              "title": "Dependency",
              "type": "string",
              "format": "pep508"
          }
      /tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.
        warnings.warn(msg, _BetaConfiguration)
      Traceback (most recent call last):
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 447, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 1, in <module>
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 159, in setup
          dist.parse_config_files()
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 867, in parse_config_files
          pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 62, in apply_configuration
          config = read_configuration(filepath, True, ignore_option_errors, dist)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 126, in read_configuration
          validate(subset, filepath)
        File "/tmp/pip-build-env-3bh11ci4/overlay/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 51, in validate
          raise ValueError(f"{error}\n{summary}") from None
      ValueError: invalid pyproject.toml config: `project.optional-dependencies.{data__optionaldependencies_key}[{data__optionaldependencies_val_x}]`.
      configuration error: `project.optional-dependencies.{data__optionaldependencies_key}[{data__optionaldependencies_val_x}]` must be pep508
      [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 editable 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.

Expected behavior

The installation should proceed.

Desktop (please complete the following information):

Suggested fix

diff --git a/pyproject.toml b/pyproject.toml
index 489831f..7b03489 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -36,7 +36,7 @@ dependencies = ["cffi==1.15.0"]

 [project.optional-dependencies]
 numpy = ["numpy==1.23.1; python_version >= '3.8'", "numpy==1.21.6; python_version == '3.7'"]
-gurobi = ["gurobipy>=8.*"]
+gurobi = ["gurobipy>=8"]

 [project.urls]
 "Homepage" = "https://www.python-mip.com"
sebheger commented 1 year ago

I will fix it within the next few days