Skip to content

Commit

Permalink
Create a Python package boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Jul 20, 2020
1 parent 888b9e7 commit 27b0f16
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache python modules
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
yarn --dev
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Lint
run: |
yarn run lint
flake8
- name: Package
run: |
python setup.py bdist_wheel
pip install --no-cache-dir dist/legunto-*.whl
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Upload Release Asset

on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v1
with:
python-version: '3.x'

- name: Cache python modules
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
- name: Package
run: |
python setup.py bdist_wheel
pip install --no-cache-dir dist/legunto-*.whl
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Set file name
id: file_name
run: echo "::set-output name=file_name::$(ls dist)"

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/${{ steps.file_name.outputs.file_name }}
asset_name: ${{ steps.file_name.outputs.file_name }}
asset_content_type: application/zip
8 changes: 8 additions & 0 deletions legunto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python

def main():
print("Hello legunto!")


if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flake8==3.8.3
pytest==5.4.3
wheel==0.34.2
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mwclient==0.10.1
15 changes: 15 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import setuptools

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name="legunto",
version="0.0.1",
scripts=["legunto"],
description="Fetch MediaWiki Scribunto modules from wikis",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
install_requires=["mwclient"],
)

0 comments on commit 27b0f16

Please sign in to comment.