How can I make setuptools install a package from another source that's also available on pypi with the same version number?

前端 未结 2 1369
醉酒成梦
醉酒成梦 2020-12-30 21:51

It\'s a similar question to How can I make setuptools install a package that's not on PyPI? but not the same.

As I would like to use the forked version of some p

2条回答
  •  悲&欢浪女
    2020-12-30 22:23

    I ended up doing something very similar to the answer in stackoverflow.com/a/17442663/368102.

    I need a requests-file github package that name-conflicts with a different requests-file package in PyPi. They both have a version 1.0, and the PyPi version has some higher versions.

    The workaround in my ias_tools/setup.py looks like this:

    setup(
        ...
        install_requires=[
            'requests-file<=99.99',
        ],
        dependency_links=[
            'https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip#egg=requests-file-99.99'
        ]
    )
    

    In my case, I'm using pip so I also had to use --process-dependency-links:

    % pip install --process-dependency-links ./ias_tools
    You are using pip version 6.0.6, however version 6.1.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    Processing ./ias_tools
      DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
    Collecting requests-file<=99.99 (from ias-tools==0.1)
      Downloading https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip
    Requirement already satisfied (use --upgrade to upgrade): requests>=1.1.0 in ./venv/lib/python2.7/site-packages (from requests-file<=99.99->ias-tools==0.1)
    Installing collected packages: ias-tools, requests-file
      Running setup.py install for ias-tools
      Running setup.py install for requests-file
    Successfully installed ias-tools-0.1 requests-file-1.0
    

    I'm not too worried about the deprecation notice, as a pull request was submitted to pip to deprecate the deprecation (after a discussion about it).

提交回复
热议问题