문제

I have a project structure like:

pgmpy/
|-- pgmpy
|   |-- BayesianModel
|   |   |-- BayesianModel.py
|   |   |-- __init__.py
|   |-- Exceptions
|   |   |-- Exceptions.py
|   |   |-- __init__.py
|   |-- Factor
|   |   |-- CPD.py
|   |   |-- _factor_product.c
|   |   |-- _factor_product.pyx
|   |   |-- Factor.py
|   |   |-- __init__.py
|   |-- Independencies
|   |   |-- Independencies.py
|   |   |-- __init__.py
|   |-- __init__.py
|   |-- MarkovModel
|   |   |-- __init__.py
|   |   |-- MarkovModel.py
|   |-- readwrite
|   |   |-- __init__.py
|   |   |-- ProbModelXML.py
|   `-- tests
|       |-- help_functions.py
|       |-- test_BayesianModel.py
|       `-- test_Independencies.py
`-- setup.py

The Factor dir contains a .pyx file. When I install pgmpy using setup.py it compiles with Cython and creates a shared object file in python's dist-packages dir. But since this shared object file is not available in the project dir, running nosetests from this dir gives an error that it is unable to import the cython file. Running nosetests from any other directory works fine.

What should I do to make sure that nosetests runs from the project dir also?

도움이 되었습니까?

해결책

I had a look at your project, try changing the import of setup from distutils.core into just setuptools, as distutils does not provide useful functionality such as python setup.py develop - this will instead build the .so file into pgmpy/Factor/_factor_product.cpython-33m.so which will then be available for import.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top