Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top