From 8b1758126a8593e8b1728b7d99843c77968735c8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:29:51 +0200 Subject: [PATCH] Package for distribution --- .github/workflows/ci.yaml | 4 ++-- README.md | 18 ++++++++++-------- pyproject.toml | 40 +++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 --- setup.py | 9 --------- 5 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e8c2582..bf6be2b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,6 +3,7 @@ name: CI on: push: pull_request: + workflow_dispatch: env: FORCE_COLOR: 1 @@ -28,11 +29,10 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies - run: pip install -r requirements.txt + run: pip install .[tests] - name: Check Python version run: python -V - name: Test with pytest run: pytest -vs - diff --git a/README.md b/README.md index f759ec9..6716a20 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,16 @@ Python implementation of the [STAR Voting](https://www.starvoting.org/) system. ## Getting started Install the required packages -`pip install -r requirements.txt` +```shell +pip install . +``` ## Usage ### Single winner STAR To run a single winner election create a pandas dataframe of the ballot data and pass it into the STAR function -``` -from STAR import STAR +```python +from starpy.STAR import STAR import pandas as pd ballots = pd.DataFrame(columns=['Allie', 'Billy', 'Candace'], data=[*2*[[5, 4, 0]], @@ -22,16 +24,16 @@ print(results['elected']) ``` ### Multi-winner Bloc STAR -To run a multi-winner bloc STAR race, set the input parameter numwinners -``` -results = STAR(ballots,numwinners=2) +To run a multi-winner bloc STAR race, set the input parameter `numwinners` +```python +results = STAR(ballots, numwinners=2) ``` ### Multi-winner Proportional STAR To run proportional STAR -``` +```python +from starpy.Allocated_Score import Allocated_Score import pandas as pd -from Allocated_Score import Allocated_Score numwinners=2 ballots = pd.DataFrame(columns=['Allie', 'Billy', 'Candace'], data=[*2*[[5, 4, 0]], diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b05ab8f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[build-system] +build-backend = "hatchling.build" +requires = [ + "hatchling", +] + +[project] +name = "starpy" +version = "0.0.001" +description = "Python implementation of the STAR Voting system" +readme = "README.md" +keywords = [ + "STAR voting", + "voting", +] +license-files = { paths = [ "LICENSE" ] } +requires-python = ">=3.9" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [ + "numpy>=1.21.4", + "pandas>=1.3.4", +] +optional-dependencies.tests = [ + "pytest", +] +urls.Changelog = "https://github.com/Equal-Vote/starpy/releases" +urls.Homepage = "https://github.com/Equal-Vote/starpy" +urls.Source = "https://github.com/Equal-Vote/starpy" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 38c22c3..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pandas>=1.3.4 -numpy>=1.21.4 -pytest>=7.1.2 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 159c41d..0000000 --- a/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='starpy', - version="0.0.001", - extras_require=dict(tests=['pytest']), - packages=find_packages(where='starpy'), - package_dir={"": "starpy"}, -)