Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ihmeuw/easylink into sbachmei/mic-5…
Browse files Browse the repository at this point in the history
…561/improve-docstrings-graph_components-implementation
  • Loading branch information
stevebachmeier committed Jan 7, 2025
2 parents 67c1a79 + 67f7b9d commit 1b03395
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 7 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ name: build
on: [push, pull_request, workflow_dispatch]

jobs:
get-python-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install jq
run: sudo apt-get install jq
- name: Get Python versions
id: set-matrix
run: |
echo "MATRIX_RESULT=$(jq -c . python_versions.json)" >> $GITHUB_ENV
outputs:
matrix: ${{ env.MATRIX_RESULT }}
build:
needs: get-python-versions
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ${{ fromJSON(needs.get-python-versions.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -----------------------------------------------------------------------------
# - invoked on push to any branch
# -----------------------------------------------------------------------------
name: update README

on: push

jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Update README
run: |
pip install packaging
python update_readme.py
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git diff --quiet && git diff --staged --quiet || (
git add README.rst
git commit -am "update README with supported Python versions"
git pull --rebase origin ${{ github.ref_name }}
git push origin ${{ github.ref_name }}
)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
**0.1.3 - 1/7/25**

- Validate currently-installed python version during setup
- Automatically update README when supported python versions change
- Automatically extract github actions supported python version test matrix

**0.1.2 - 12/16/24**

- Add optional arg to pass allowable schemas to the Config constructor
Expand Down
11 changes: 5 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ entity resolution (ER) pipelines.

.. _python_support:

Supported Python versions: 3.11, 3.12
**Supported Python versions: 3.11, 3.12**

.. _end_python_support:

Expand All @@ -22,21 +22,20 @@ There are a few things to install in order to use this package:
likely need to request it from your system admin.
Refer to https://docs.sylabs.io/guides/4.1/admin-guide/installation.html

.. highlight:: console

- Install graphviz via:
::

.. code-block:: console
$ conda install graphviz
- Install EasyLink.

Option 1 - Install from PyPI with pip::
Option 1 - Install from PyPI with pip::

$ pip install easylink

Option 2 - Build from source with pip::
Option 2 - Build from source with pip::

$ git clone [email protected]:ihmeuw/easylink.git # or git clone https://github.com/ihmeuw/easylink.git
$ cd easylink
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[build-system]
requires = ["packaging", "setuptools"]

[tool.black]
line_length = 94

Expand Down
1 change: 1 addition & 0 deletions python_versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["3.11", "3.12"]
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
#!/usr/bin/env python
import json
import os
import sys

from packaging.version import parse
from setuptools import find_packages, setup

with open("python_versions.json", "r") as f:
supported_python_versions = json.load(f)

python_versions = [parse(v) for v in supported_python_versions]
min_version = min(python_versions)
max_version = max(python_versions)
if not (
min_version <= parse(".".join([str(v) for v in sys.version_info[:2]])) <= max_version
):
py_version = ".".join([str(v) for v in sys.version_info[:3]])
# NOTE: Python 3.5 does not support f-strings
error = (
"\n--------------------------------------------\n"
"Error: EasyLink runs under python {min_version}-{max_version}.\n"
"You are running python {py_version}.\n".format(
min_version=min_version.base_version,
max_version=max_version.base_version,
py_version=py_version,
)
+ "--------------------------------------------\n"
)
print(error, file=sys.stderr)
sys.exit(1)


if __name__ == "__main__":
base_dir = os.path.dirname(__file__)
src_dir = os.path.join(base_dir, "src")
Expand Down Expand Up @@ -55,6 +83,7 @@
name=about["__title__"],
description=about["__summary__"],
long_description=long_description,
long_description_content_type="text/x-rst",
license=about["__license__"],
url=about["__uri__"],
author=about["__author__"],
Expand Down
32 changes: 32 additions & 0 deletions update_readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
""" This script updates the README.rst file with the latest information about
the project. It is intended to be run from the github "update README" workflow.
"""

import json
import re

from packaging.version import parse

# Load supported python versions
with open("python_versions.json", "r") as f:
versions = json.load(f)
versions_str = ", ".join(versions)
versions = [parse(v) for v in versions]
max_version = max(versions).base_version

# Open README and replace python versions
with open("README.rst", "r") as file:
readme = file.read()
# Update the list of supported python versions
# NOTE: this regex assumes the version format is always major.minor
readme = re.sub(
r"Supported Python versions:\s*(?:\d+\.\d+\s*,\s*)+\d+\.\d+",
r"Supported Python versions: " + versions_str,
readme,
)
# Update the python version used in the installation code snipped example
readme = re.sub(r"python=\d+\.\d+", "python=" + max_version, readme)

# Write the updated README back to file
with open("README.rst", "w") as file:
file.write(readme)

0 comments on commit 1b03395

Please sign in to comment.