Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ $default-branch ]
pull_request:
branches: [ $default-branch ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: build package
run: |
./build-package.sh
- name: install package
run: |
./install-built-package.sh
- name: test consuming package
run: |
./test-consume-package.sh
- name: uninstall package
run: |
./uninstall-package.sh





8 changes: 0 additions & 8 deletions build-package-egg.sh

This file was deleted.

9 changes: 8 additions & 1 deletion build-package.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#/bin/bash
die () {
echo >&2 "$@"
exit 1
}

pushd .
cd ./package-project/src
python ./setup.py sdist
# Warning: eggs are deprecated in favor of wheels, and not supported by pip. - https://setuptools.readthedocs.io/en/latest/setuptools.html#bdist-egg-create-a-python-egg-for-the-project
# python3 ./setup.py bdist_egg || die 'python setup failed'
python3 ./setup.py bdist_wheel || die 'python setup failed'
popd .

echo; echo
2 changes: 1 addition & 1 deletion install-built-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

#only works after running build-package.sh

pip install ./package-project/src/dist/boopackage-1.0.tar.gz
pip3 install --no-cache-dir ./package-project/src/dist/boopackage-1.0-py2.py3-none-any.whl
8 changes: 4 additions & 4 deletions install-devmode-package.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#/bin/bash
# https://packaging.python.org/distributing/#working-in-development-mode
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#working-in-development-mode
pushd .
cd ./package-project/src/
pip install -e .
pip3 install -e ./
popd

echo; echo
echo; echo "Showing package info:"

pip show boopackage
pip3 show boopackage
5 changes: 5 additions & 0 deletions package-project/src/boopackage/barmodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import print_function


def barfunc():
print('barfunc')
13 changes: 12 additions & 1 deletion package-project/src/boopackage/boomodule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from __future__ import print_function
# demonstrating relative verses absolute imports as described at https://www.python.org/dev/peps/pep-0328/
from boopackage.barmodule import barfunc
from .barmodule import barfunc as barfunc_relative


def boofunc():
print('boofunc')
print('boofunc')

print('testing barfunc via absolute/normal import...')
barfunc()
print('testing barfunc via absolute import complete.')

print('testing barfunc via relative import...')
barfunc_relative()
print('testing barfunc via relative import complete.')
4 changes: 2 additions & 2 deletions test-consume-package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
# https://packaging.python.org/distributing/#working-in-development-mode
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#working-in-development-mode

python ./package-consumer-project/consumepackage.py
python3 ./package-consumer-project/consumepackage.py
4 changes: 3 additions & 1 deletion uninstall-package.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#/bin/bash
# https://packaging.python.org/distributing
pip uninstall boopackage
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#working-in-development-mode

pip3 uninstall --yes --no-cache-dir boopackage