pip-`git + file`不适用于setup.cfg

时间:2019-11-08 19:46:30

标签: python pip

我想在setup.cfg中引用对本地文件系统的依赖。


当我在命令行上执行以下操作时:

$  pip install  git+file:///Users/Dev/Projects/dakia/#subdirectory=server

它可以正常工作,如manual中所述。


但是如果我在setup.cfg中指定相同的内容,就像这样:

[options]
    dakia @ git+file:///Users/Dev/Projects/dakia/#subdirectory=server

它失败并显示以下跟踪信息:

$  pip install -v -e .[dev]
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-ephem-wheel-cache-_4jzvm87
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck
Created requirements tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-install-gwp9chgb
Obtaining file:///Users/dev/Projects/dara/server
  Added file:///Users/dev/Projects/dara/server to build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
    Running setup.py (path:/Users/dev/Projects/dara/server/setup.py) egg_info for package from file:///Users/dev/Projects/dara/server
    Running command python setup.py egg_info
    Traceback (most recent call last):
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in __init__
        super(Requirement, self).__init__(requirement_string)
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 101, in __init__
        raise InvalidRequirement("Invalid URL given")
    pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid URL given

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/dev/Projects/dara/server/setup.py", line 3, in <module>
        setup()
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
        dist.parse_config_files(ignore_option_errors=True)
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 701, in parse_config_files
        self._finalize_requires()
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 505, in _finalize_requires
        self._move_install_requirements_markers()
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 544, in _move_install_requirements_markers
        inst_reqs = list(pkg_resources.parse_requirements(spec_inst_reqs))
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3094, in parse_requirements
        yield Requirement(line)
      File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3103, in __init__
        raise RequirementParseError(str(e))
    pkg_resources.RequirementParseError: Invalid URL given
Cleaning up...
Removed file:///Users/dev/Projects/dara/server from build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
Removed build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Exception information:
Traceback (most recent call last):
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 295, in _get_abstract_dist_for
    req, self.require_hashes, self.use_user_site, self.finder,
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 258, in prepare_editable_requirement
    req, self.req_tracker, finder, self.build_isolation,
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 49, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/distributions/source/legacy.py", line 39, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 563, in prepare_metadata
    self.metadata_directory = metadata_generator(self)
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/generate_metadata.py", line 124, in _generate_metadata_legacy
    command_desc='python setup.py egg_info',
  File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/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.

如何使git+file的网址与setup.cfg一起使用? 那不可能吗?如果是这样,为什么?


我认为这篇文章不需要更多的解释,但是如果没有一定数量的文字,我不会让我发布的。

1 个答案:

答案 0 :(得分:0)

我认为不支持该子目录。

没有子目录,那么它在setup.cfg中看起来可能像这样:

[options]
install_requires =
    dakia
dependency_links =
    git+file:///Users/Dev/Projects/dakia#egg=dakia

https://setuptools.readthedocs.io/en/latest/setuptools.html#dependencies-that-aren-t-in-pypi