2017-12-08 3 views
-1

Ich habe ein Open-Source-Projekt (GridCal) und ich sage den Benutzern, das Paket mit pip install GridCal oder pip3 install GridCal für Unix-Systeme zu installieren.Pip kann keine Abhängigkeiten installieren

Die Setup-Datei ist dies:

from distutils.core import setup 
import sys 
import os 
import platform 
from GridCal.grid.CalculationEngine import __GridCal_VERSION__ 

name = "GridCal" 
version = str(__GridCal_VERSION__) 
description = "Research Oriented electrical simulation software." 

# Python 3.5 or later needed 
if sys.version_info < (3, 5, 0, 'final', 0): 
    raise (SystemExit, 'Python 3.5 or later is required!') 

# Build a list of all project modules 
packages = [] 
for dir_name, dir_names, file_names in os.walk(name): 
     if '__init__.py' in file_names: 
      packages.append(dir_name.replace('/', '.')) 

package_dir = {name: name} 

# Data_files (e.g. doc) needs (directory, files-in-this-directory) tuples 
data_files = [] 
for dir_name, dir_names, file_names in os.walk('doc'): 
     files_list = [] 
     for filename in file_names: 
      fullname = os.path.join(dir_name, filename) 
      files_list.append(fullname) 
     data_files.append(('share/' + name + '/' + dir_name, files_list)) 

if platform.system() == 'Windows': 
    # list the packages (On windows anaconda is assumed) 
    required_packages = ["numpy", 
         "scipy", 
         "networkx", 
         "pandas", 
         "xlwt", 
         "xlrd", 
         # "PyQt5", 
         "matplotlib", 
         "qtconsole", 
         "pysot", 
         "openpyxl", 
         "pulp" 
         ] 
else: 
    # make the desktop entry 
    make_linux_desktop_file(version_=version, comment=description) 

    # list the packages 
    required_packages = ["numpy", 
         "scipy", 
         "networkx", 
         "pandas", 
         "xlwt", 
         "xlrd", 
         "PyQt5", 
         "matplotlib", 
         "qtconsole", 
         "pysot", 
         "openpyxl", 
         "pulp" 
         ] 

# Read the license 
with open('LICENSE.txt', 'r') as f: 
    license_text = f.read() 

setup(
    # Application name: 
    name=name, 

    # Version number (initial): 
    version=version, 

    # Application author details: 
    author="Santiago Peñate Vera", 
    author_email="[email protected]", 

    # Packages 
    packages=packages, 

    data_files=data_files, 

    # Include additional files into the package 
    include_package_data=True, 

    # Details 
    url="http://pypi.python.org/pypi/GridCal/", 

    # License file 
    license=license_text, 

    # description 
    description=description, 

    # long_description=open("README.txt").read(), 

    # Dependent packages (distributions) 
    install_requires=required_packages, 

    setup_requires=required_packages 
) 

Von Zeit zu Zeit erhalte ich Anwender Berichte sagen, dass die Programm-Module fehlt: https://github.com/SanPen/GridCal/issues/12

Ich habe die Liste der Pakete angegeben sowohl in install_requires und setup_requires .

Ist das ein Pip-Bug, oder soll ich etwas anderes machen?

+0

Ich sehe 'PyDOE' nicht in der Liste der Abhängigkeiten. Wie ist es installiert? Ist es eine Abhängigkeit von einer aufgelisteten Abhängigkeit? – phd

+0

Ich bezweifle, dass Sie beide 'install_requires' und' setup_requires' gleichzeitig benötigen. Siehe auch die Warnung unter https://pip.pypa.io/en/stable/user_guide/?highlight=setup_requires#installation-bundles: * Hüten Sie sich schließlich vor dem Schlüsselwort setup_requires arg in setup.py. Die (seltenen) Pakete, die es verwenden, werden dazu führen, dass diese Abhängigkeiten direkt von setuptools heruntergeladen werden, wobei die Schutzmechanismen von pip übersprungen werden. * – phd

+0

pyDOE wird mit pySOT installiert und BTW funktioniert unter Linux und manchmal auch nicht so gut in Windows. Daher die Frage. –

Antwort

0

Ihre setup.py Importe GridCal.grid.CalculationEngine, die fast alle Ihre Abhängigkeiten importiert. I.e. Ihre setup.py importiert Abhängigkeiten vor Installation von ihnen.

Versuchen Sie es in einem neuen leeren virtuellen env von Ihrem globalen abgelöst zu installieren site-packages - das funktioniert sicher nicht:

$ virtualenv --no-site-packages --python python3.4 test-gcal 
Running virtualenv with interpreter /usr/bin/python3.4 
Using base prefix '/usr' 
New python executable in /home/phd/tmp/test-gcal/bin/python3.4 
Also creating executable in /home/phd/tmp/test-gcal/bin/python 
Installing setuptools, pip, wheel...done. 

$ source test-gcal/bin/activate 

$ pip install GridCal 
Collecting GridCal 
    Using cached GridCal-1.85.tar.gz 
    Complete output from command python setup.py egg_info: 
    Traceback (most recent call last): 
     File "<string>", line 1, in <module> 
     File "/tmp/pip-build-c7q9pbep/GridCal/setup.py", line 5, in <module> 
     from GridCal.grid.CalculationEngine import __GridCal_VERSION__ 
     File "/tmp/pip-build-c7q9pbep/GridCal/GridCal/grid/CalculationEngine.py", line 18, in <module> 
     from GridCal.grid.JacobianBased import IwamotoNR, Jacobian, LevenbergMarquardtPF 
     File "/tmp/pip-build-c7q9pbep/GridCal/GridCal/grid/JacobianBased.py", line 19, in <module> 
     from numpy import array, angle, exp, linalg, r_, Inf, conj, diag, asmatrix, asarray, zeros_like, zeros, complex128, \ 
    ImportError: No module named 'numpy' 

    ---------------------------------------- 
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c7q9pbep/GridCal/ 

Die Lösung ist relativ einfach: Sie __GridCal_VERSION__ von GridCal/Engine/CalculationEngine.py zu einem separaten bewegen GridCal/version.py (oder __version__.py oder etwas Ähnliches) und tun from GridCal.version import __GridCal_VERSION__ in setup.py.

Bitte beachten Sie, dass der Import nur funktionieren würde, wenn Ihre GridCal/__init__.py leer ist oder nur eingebaute/Standard-Module importiert. Wenn __init__.py direkt oder indirekt eine (noch nicht installierte) Abhängigkeit importiert, konnte version.py nicht importiert werden. Es gibt einen Weg, dies in setup.py zu überwinden, aber ich überspringe es für jetzt. Wenn Sie jemals die Lösung brauchen - fragen Sie noch einmal.

Verwandte Themen