简体   繁体   中英

pip - `git+file` doesn't work with setup.cfg

I want to refer to dependency on the local filesystem in setup.cfg .


When I perform the following on the command line:

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

It works flawlessly, as described in the manual .


But if I specify the same in setup.cfg , like so:

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

It fails with the following trace:

$  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.

How do I make git+file urls work with setup.cfg ? Is that not possible? If so, why?


I don't think this post needs any more explanation, but SO won't let me post without a certain amount of text.

I don't think the sub-directory is supported.

Without a sub-directory then it could look something like this in your 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM