Skip to content

Explore Python_Rules

valhuber edited this page Sep 27, 2020 · 3 revisions

Installation

To get started, you will need:

  • Python3.8 (Relies on from __future__ import annotations, so requires Python 3.8)

    • Run the windows installer; on mac/Unix, consider using brew
  • virtualenv - see here (e.g., pip install virtualenv)

  • An IDE - any will do (I've used PyCharm and VSCode, install notes here) - ide will do, though different install / generate / run instructions apply for running programs

Issues? Try here.

Using your IDE or command line:

git fork / clone
cd python-rules
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

The project includes:

  • the logic engine that executes the rules
  • the sample database (sqlite, so no db install is required)
  • business logic, both by-code and by-rules, to facilitate comparison
    • control whether logic is via rules or code by alteringby_rules in __init__.py
  • a test folder that runs various sample transactions

You can run the programs in the nw/trans_tests folder (note the generated log), and/or review this readme and the wiki.

Deploy to Pypi

Using this reference...

Acquire the setup software (initial, 1-time setup):

cd python-rules
deactivate
python setup.py install
python3 -m pip install --user --upgrade twine
python3 -m pip install --user --upgrade setuptools wheel

Creating the dist, first time Get a Saved API Key

cd python-rules
deactivate
python3 setup.py sdist bdist_wheel
# verify this produced the dist folder; next command uploads to test Pypi
python3 -m twine upload --repository testpypi dist/*

User is __token__, pwd is Saved API Key (from above).

This should upload to the Pypi site

To re-upload:

  1. Delete the dist folder (and build, and .egg)
  2. Alter the version number in setup.py
deactivate
python3 setup.py sdist bdist_wheel
python3 -m twine upload  --skip-existing --repository testpypi dist/*

To install locally (beware - may require 15 mins until new version is active.

source venv/bin/activate
pip uninstall python-rules
pip install -i https://test.pypi.org/simple/ python-rules

Local pip

Per this helpful link, you can build the wheel and install locally:

cd receiving_project
virtualenv venv
source venv/bin/activate
pip install ../python-rules
Clone this wiki locally