diff --git a/.github/workflows/cli_setup.yml b/.github/workflows/cli_setup.yml index b5d7c17..5914f2a 100644 --- a/.github/workflows/cli_setup.yml +++ b/.github/workflows/cli_setup.yml @@ -44,14 +44,13 @@ jobs: - name: (MSYS2) Install Python dependencies shell: msys2 {0} run: | - python3 -m pip install wheel + python3 -m pip install -U setuptools wheel - name: (MSYS2) Install QMK CLI from source shell: msys2 {0} run: | - python3 -m pip install -r requirements.txt - python3 setup.py sdist bdist_wheel - cd .. - python3 -m pip install --force-reinstall --no-index --no-deps --find-links qmk_cli/dist qmk + python3 -m pip install -U build + python3 -m build + python3 -m pip install dist/qmk-*.tar.gz - name: (MSYS2) Run qmk setup -y shell: msys2 {0} run: qmk setup -y diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 72abc1b..c5af8cf 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -26,7 +26,7 @@ jobs: run: ./ci_tests - name: Install dependencies run: | - python -m pip install --upgrade pip + python3 -m pip install --upgrade pip pip install setuptools wheel pip install -r requirements-dev.txt - name: Bump version @@ -45,7 +45,7 @@ jobs: TWINE_USERNAME: qmk TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + python3 -m build twine upload dist/* - name: Log in to Docker Hub uses: docker/login-action@v1.10.0 @@ -58,3 +58,7 @@ jobs: context: . push: true tags: qmkfm/qmk_cli:latest + - name: Trigger OS package builds + run: ./trigger_packages + env: + QMK_BOT_TOKEN: ${{ secrets.QMK_BOT_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..374b58c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/requirements-dev.txt b/requirements-dev.txt index 7a5f4ac..d15c777 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,10 @@ bleach==4.0.0 +build==0.6.0.post1 bump2version==1.0.1 bumpversion==0.6.0 certifi==2021.5.30 cffi==1.14.6 chardet==4.0.0 -colorama==0.4.4 cryptography==3.4.7 docutils==0.17.1 idna==2.10 @@ -14,7 +14,6 @@ keyring==23.0.1 packaging==21.0 pkginfo==1.7.1 pycparser==2.20 -Pygments==2.9.0 pyparsing==2.4.7 readme-renderer==29.0 requests==2.26.0 diff --git a/setup.cfg b/setup.cfg index 91c70ea..5952557 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,17 +16,58 @@ universal = 1 ignore = E501,E226 [metadata] +name = qmk +version = 0.3.0 author = skullydazed -author-email = skullydazed@gmail.com -description-file = README.md -dist-name = qmk -license_file = LICENSE -module = qmk_cli -home-page = https://github.com/qmk/qmk_cli -requires-python = >=3.7 +author_email = skullydazed@gmail.com +description = A program to help users work with QMK Firmware. +long_description = file: README.md +long_description_content_type = text/markdown +license = MIT License +project_urls = + Bug Tracker = https://github.com/qmk/qmk_cli/issues + Documentation = https://docs.qmk.fm/#/cli + Homepage = https://qmk.fm/ + Source = https://github.com/qmk/qmk_cli/ +classifiers = + Development Status :: 3 - Alpha + Environment :: Console + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: End Users/Desktop + License :: OSI Approved :: MIT License + Natural Language :: English + Programming Language :: Python :: 3 :: Only + Topic :: Scientific/Engineering + Topic :: Software Development + Topic :: Utilities -[entry_points] -qmk = qmk_cli.script_qmk:main +[options] +install_requires = + appdirs==1.4.4 + argcomplete==1.12.3 + attrs==21.2.0 + colorama==0.4.4 + coverage==5.5 + halo==0.0.31 + hid==1.0.4 + log-symbols==0.0.14 + mccabe==0.6.1 + milc==1.5.0 + pycodestyle==2.7.0 + pyflakes==2.3.1 + pyrsistent==0.18.0 + pyusb==1.2.1 + setuptools>=45 + six==1.16.0 + spinners==0.0.24 + termcolor==1.1.0 +packages = find: +python_requiures = >=3.7 + +[options.entry_points] +console_scripts = + qmk = qmk_cli.script_qmk:main [yapf] align_closing_bracket_with_visual_indent = True diff --git a/setup.py b/setup.py deleted file mode 100644 index 35e1b64..0000000 --- a/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -from configparser import ConfigParser -from setuptools import setup, find_packages - -setup_cfg = ConfigParser() -setup_cfg.read('setup.cfg') -metadata = setup_cfg['metadata'] - -if __name__ == "__main__": - with open('README.md', encoding='utf-8') as readme_file: - long_description = readme_file.read() - setup( - name=metadata['dist-name'], - description='A program to help users work with QMK Firmware.', - entry_points={ - 'console_scripts': ['%s = %s' % i for i in setup_cfg['entry_points'].items()], - }, - license='MIT License', - url=metadata['home-page'], - version=setup_cfg['bumpversion']['current_version'], - author=metadata['author'], - author_email=metadata['author-email'], - maintainer=metadata['author'], - maintainer_email=metadata['author-email'], - long_description=long_description, - long_description_content_type="text/markdown", - packages=find_packages(), - py_modules=['qmk_cli'], - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Intended Audience :: End Users/Desktop', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3 :: Only', - 'Topic :: Scientific/Engineering', - 'Topic :: Software Development', - 'Topic :: Utilities', - ], - python_requires=metadata['requires-python'], - install_requires=[ - "appdirs==1.4.4", - "argcomplete==1.12.3", - "attrs==21.2.0", - "colorama==0.4.4", - "coverage==5.5", - "qmk-dotty-dict==1.3.0.post1", - "flake8==3.9.2", - "halo==0.0.31", - "hid==1.0.4", - "hjson==3.0.2", - "jsonschema==3.2.0", - "log-symbols==0.0.14", - "mccabe==0.6.1", - "milc==1.5.0", - "nose2==0.10.0", - "pycodestyle==2.7.0", - "pyflakes==2.3.1", - "Pygments==2.9.0", - "pyrsistent==0.18.0", - "pyusb==1.2.1", - "setuptools>=45", - "six==1.16.0", - "spinners==0.0.24", - "termcolor==1.1.0", - "yapf==0.31.0" - ] - ) diff --git a/trigger_packages b/trigger_packages new file mode 100755 index 0000000..96ba64e --- /dev/null +++ b/trigger_packages @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Trigger workflows that build QMK packages. +""" +from os import environ +from pathlib import Path + +import requests + +# Pull in environment vars +gh_user = environ.get('GH_USERNAME', 'qmk-bot') +gh_pat = environ.get('QMK_BOT_TOKEN', '') +gh_repo_owner = environ.get('REPO_OWNER', 'qmk') +gh_repo_name = environ.get('REPO_NAME', 'qmk_fpm') +gh_ref = environ.get('GITHUB_REF', 'main') +gh_workflow_ids = environ.get('WORKFLOW_IDS', 'debian-buster-publish.yml,fedora-33-publish.yml,fedora-35-publish.yml,fedora-32-publish.yml,fedora-34-publish.yml,ubuntu-focal-publish.yml').split(',') +gh_api_url = environ.get('GITHUB_API_URL', 'https://api.github.com') +gh_workflow_args = {'ref': gh_ref} +gh_workflow_headers = {'Accept': 'application/vnd.github.v3+json'} + +for gh_workflow_id in gh_workflow_ids: + gh_workflow_endpoint = f'{gh_api_url}/repos/{gh_repo_owner}/{gh_repo_name}/actions/workflows/{gh_workflow_id}/dispatches' + print(f'Triggering {gh_workflow_id} workflow at: {gh_workflow_endpoint}') + workflow_dispatch = requests.post(gh_workflow_endpoint, headers=gh_workflow_headers, json=gh_workflow_args, auth=(gh_user, gh_pat)) + if workflow_dispatch.status_code != 204: + print(f'Error from GitHub API, status_code {workflow_dispatch.status_code}!') + print(workflow_dispatch.text) + exit(1) + +exit(0)