Setuptools: `'extras_require' must be a dictionary` when using git+ link in extras_require

Created on 27 Mar 2020  路  2Comments  路  Source: pypa/setuptools

moved from https://github.com/pypa/pip/issues/7906

I don't know why it says I added a Python 2 label. I don't even see a button to add labels. This is a python 3 thing (well it probably affects both, but I don't care about py2 :) ).

here's the error for quick reference: https://github.com/pypa/setuptools/blob/8bbdc6000f53be32305287edb9bae5725adc7ca5/setuptools/dist.py#L246-L255

Environment1
virtualenv

  • pip version: 20.0.2
  • Python version: 3.5.2, Python
  • Linux my-docker-container 4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux (nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04)

Environment2
Anaconda virtualenv

  • pip version: 19.1.1
  • Python version: 3.6.4
  • Linux my-hostname 4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 16.04.6 LTS)

My test env:

$ pip freeze
pip             20.0.2
setuptools      46.1.1
wheel           0.34.2
#!/usr/bin/env python 
# setup.py
from setuptools import setup, find_packages

# The link is actually to a client library, I'm using six to demonstrate
setup(
        name="dummy",
        packages=find_packages(),
    extras_require={
        'myextra': ['git+https://github.com/benjaminp/six.git'],
    }
)

Description

pip install "./[myextra]"

or

pip install .

fails with

    ERROR: Complete output from command python setup.py egg_info:
    ERROR: error in dummy setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-fgmgoxp2/

Expected behavior
successful pip install of my app plus the extras (a client library in this case). I can pip install a git link, and I can install extras_require, but I can't do extras with a git link

How to Reproduce

  1. new virtualenv/container
  2. make a dummy package with the above setup.py
  3. pip install .

Output

Exception information:
Traceback (most recent call last):
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 331, in run
    resolver.resolve(requirement_set)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 516, in prepare_linked_requirement
    req, self.req_tracker, self.finder, self.build_isolation,
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 95, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/distributions/sdist.py", line 40, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 564, in prepare_metadata
    self.metadata_directory = self._generate_metadata()
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 544, in _generate_metadata
    details=self.name or "from {}".format(self.link)
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/operations/build/metadata_legacy.py", line 118, in generate_metadata
    command_desc='python setup.py egg_info',
  File "/home/ubuntu/.virtualenvs/testdev/lib/python3.6/site-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Most helpful comment

@xkortex can you try this (notice the updated PEP 508 syntax for the direct url requirement):

# setup.py
from setuptools import setup, find_packages

# The link is actually to a client library, I'm using six to demonstrate
setup(
    name="dummy",
    packages=find_packages(),
    extras_require={
        'myextra': ['six @ git+https://github.com/benjaminp/six.git'],
    }
)

All 2 comments

@xkortex can you try this (notice the updated PEP 508 syntax for the direct url requirement):

# setup.py
from setuptools import setup, find_packages

# The link is actually to a client library, I'm using six to demonstrate
setup(
    name="dummy",
    packages=find_packages(),
    extras_require={
        'myextra': ['six @ git+https://github.com/benjaminp/six.git'],
    }
)

I don't know why it says I added a Python 2 label.

Probably you clicked the template for filing issues about the Python 2 warning instead of the blank issue:

image

It's confusing, I know. I've tried to clarify in the template so others don't fall into the same trap.

Was this page helpful?
0 / 5 - 0 ratings