Недопустимое требование, ошибка синтаксического анализа в "--instal" при попытке использовать --install-option в needs.txt - PullRequest
0 голосов
/ 15 ноября 2018

Я пытаюсь установить модуль python, используя setup.py с needs.txt.Я устанавливаю модуль с помощью pip install -U . в каталог, где у меня есть файл setup.py.

Мой setup.py файл анализирует файл requirements.txt, сохраняя требования в списке строк:

def get_requirements():
    root_path = os.path.abspath(os.path.dirname(__file__))
    requirements_file_path = os.path.join(root_path, 'requirements.txt')

    # example: `numpy >= 1.13`
    with open(requirements_file_path) as file:
        requirements = [requirement.strip() for requirement in file.readlines()]
        requirements = filter(lambda requirement: len(requirement), requirements)
        requirements = filter(lambda requirement: not requirement.startswith('-'), requirements)
        requirements = list(requirements)

    return requirements

requirements = get_requirements()
config = {'name': name, 
          'install_requires': requirements
}
setuptools.setup(**config)

Файл моих требований выглядит следующим образом:

numpy >= 1.13
pyyaml >= 3.12
matplotlib
opencv-python >= 3.2
setuptools
cython
mock
scipy
six
future
protobuf
yacs
ninja
colour
torchvision_nightly
torch_nightly --install-option="--find-links https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html"

Однако, когда я пытаюсь установить модуль с pip install -U ., я получаю следующую ошибку разбора:

Processing /home/my-module
    Complete output from command python setup.py egg_info:
    error in my_module setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'--instal'"

----------------------------------------

Сбой команды «python setup.py egg_info» с кодом ошибки 1 в / tmp / pip-req-build-rf9439sf /

Есть идеи, почему передача --install-option вызывает ошибку разбора?

1 Ответ

0 голосов
/ 15 ноября 2018

Объявление зависимостей в setuptools имеет синтаксис, отличный от pip .Вы должны преобразовать одно в другое автоматически или вручную.

...