paolodragone / pymzn

A Python wrapper for the MiniZinc tool pipeline.
MIT License
55 stars 15 forks source link

Cannot import templates #40

Closed hectorpal closed 5 years ago

hectorpal commented 5 years ago

When attempting to use pyconstruct, the following line failed

pymzn.templates.add_package('pyconstruct.domains', 'share') with error AttributeError: module 'pymzn' has no attribute 'templates

It seems from .templates import * is missing from this file https://github.com/paolodragone/pymzn/blob/master/pymzn/__init__.py

It might have gone missing in this commit: https://github.com/paolodragone/pymzn/commit/df5aca6a5d7523ad54bbb37e208c5590487359f1#diff-21aa6139d6400b1aa70e461a45c6cf63

paolodragone commented 5 years ago

Hi @hectorpal, Looking back at the code, this was actually the intended behavior. The templates package is optional, so to use it one needs to import it explicitly:

import pymzn.templates
pymzn.templates.add_package('pyconstruct.domains', 'share')

I fixed this issue in https://github.com/unitn-sml/pyconstruct/commit/674feb5dd17946e8d519057d341491406c3dbf81.