Skip to content

Commit

Permalink
added pyproject.toml packaging files
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Antonellis committed Feb 1, 2021
1 parent 5c38670 commit d34187e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/actions/verify-wheel/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set -euo pipefail

MODULE_NAME=$1

echo "Ensuring pip is up to date"
python -m pip install --upgrade pip
echo "Installing the PyPA build package"
pip build

echo "--------------"
echo "Building wheel"
python -m build

APP_DIR=$(pwd)

# move into root dir so Python will import the installed package instead of the local source files
cd /
echo "------------------"
echo "Installing package"
pip install ${APP_DIR}/dist/*.whl

echo "-----------------------------"
echo "Attempting to import package"
python "${GITHUB_ACTION_PATH}/test_module_import.py" "${MODULE_NAME}"
12 changes: 12 additions & 0 deletions .github/actions/verify-wheel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Verify Python Wheel"
description: "Build a wheel for the package and importing the package doesn't cause an error"
inputs:
package-import-name:
description: "Name used to import the package from python code"
required: true
runs:
using: "composite"
steps:
- name: "Verify wheel"
run: "$GITHUB_ACTION_PATH/action.sh ${{ inputs.package-import-name }}"
shell: "bash"
15 changes: 15 additions & 0 deletions .github/actions/verify-wheel/test_module_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import importlib
import sys

try:
module_name = sys.argv[1]
except IndexError:
print("module_name must be provided as first argument to test_module_import.py script")
sys.exit(1)

try:
module = importlib.import_module(module_name)
except Exception as e:
print(f"Error importing module {module_name}: {e}")
sys.exit(1)
print(f"Imported {module_name} version {module.__version__}")
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[metadata]
name = extra-model
version = 0.0.1
description = extra model description

[options]
packages = find:

0 comments on commit d34187e

Please sign in to comment.