简体   繁体   中英

pip install from GitHub source fails to install dependencies defined in repository's requirements.txt

I'm trying to fully install a Github repository in my package. The item is added properly to my setup.cfg file:

install_requires =
    requests>=2.27.0, <3.0.0
    rich>=12.3.0, <13.0.0
    pydantic>=1.9.0, <2.0.0
    openalexapi @ git+https://github.com/dpriskorn/OpenAlexAPI.git@master#egg=openalexapi

A pip install -e . installs openalexapi but it does not pull the list of dependencies in their requirements.txt. As such, it fails to install backoff and returns the following error:

Python 3.10.0 (default, Oct  7 2021, 04:19:18) [Clang 10.0.0 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from openalexapi import works
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from openalexapi import works

File ~/codes/PPPL/promotion-analysis/venv/lib/python3.10/site-packages/openalexapi/__init__.py:7, in <module>
      4 import logging
      5 from typing import Optional, List
----> 7 import backoff  # type: ignore
      8 import requests
      9 from pydantic import BaseModel, EmailStr

I know that one can do pip install -r https://path/to/requirements.txt but was wondering if there is a way to trigger pulling the dependencies automatically.

When not explicitly ( pip install -r requirements.txt ) asked pip install never implicitly uses requirements.txt .

Dependencies are listed in wheels' metadata or in source distributions in setup.cfg / setup.py . And BTW said metadata is generated from setup.cfg / setup.py which must explicitly read requirements.txt .

It's not the case with openalexapi code so the only way to use its requirements.txt is to do explicitly

pip install -r https://raw.githubusercontent.com/dpriskorn/OpenAlexAPI/master/requirements.txt

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