Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The python package that allows you to access all of MiniZinc's functionalities directly from Python.
Explore the docs »
Report Bug
·
Request Feature
MiniZinc Python provides an interface from Python to the MiniZinc driver. The most important goal of this project are to allow easy access to MiniZinc using native Python structures. This will allow you to more easily make scripts to run MiniZinc, but will also allow the integration of MiniZinc models within bigger (Python) projects. This module also aims to expose an interface for meta-search. For problems that are hard to solve, meta-search can provide solutions to reach more or better solutions quickly.
To get a MiniZinc Python up and running follow these simple steps.
MiniZinc Python can be installed by running pip install minizinc
. It
requires MiniZinc 2.5.0+ and
Python 3.6.0+ to be installed on the system. MiniZinc
python expects the minizinc
executable to be available on the executable path,
the $PATH
environmental variable, or in a default installation location.
For more information, please refer to the Documentation
Once all prerequisites and MiniZinc Python are installed, a minizinc
module
will be available in Python. The following Python code shows how to run a
typical MiniZinc model.
import minizinc
# Create a MiniZinc model
model = minizinc.Model()
model.add_string("""
var -100..100: x;
int: a; int: b; int: c;
constraint a*(x*x) + b*x = c;
solve satisfy;
""")
# Transform Model into a instance
gecode = minizinc.Solver.lookup("gecode")
inst = minizinc.Instance(gecode, model)
inst["a"] = 1
inst["b"] = 4
inst["c"] = 0
# Solve the instance
result = inst.solve(all_solutions=True)
for i in range(len(result)):
print("x = {}".format(result[i, "x"]))
For more examples, please refer to the Documentation
MiniZinc Python uses Tox environments to test its coding style and functionality. The code style tests are executed using Black, Flake8, and isort. The functionality tests are constructed using the PyTest unit testing framework.
tox
in the repository directory.-e
flag.
tox -e check
py3x
environments are used to test a specific Python version; for
example, to test using Python version 3.7 run tox -e py37
Tox can also be used to generate the documentation, tox -e docs
, and to
typeset the Python code, tox -e format
.
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the Mozilla Public License Version 2.0. See LICENSE
for more information.
👤 Jip J. Dekker
🏛 MiniZinc
FAQs
Access MiniZinc directly from Python
We found that minizinc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.