From e6ee10686bb693c1f1b2e1ef88c47664be8bf7b9 Mon Sep 17 00:00:00 2001 From: Nihaal Sangha <18350092+OrangutanGaming@users.noreply.github.com> Date: Sat, 28 Mar 2020 14:41:04 +0000 Subject: [PATCH] 0.2.0 --- .github/workflows/push.yaml | 28 --------------- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ LICENSE | 2 +- pecho/__init__.py | 10 +++--- pecho/__init__.pyi | 2 +- pyproject.toml | 19 ++++++++++ requirements.txt | 1 - setup.py | 55 ----------------------------- 9 files changed, 95 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/push.yaml create mode 100644 .github/workflows/release.yml create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml deleted file mode 100644 index b65fa8b..0000000 --- a/.github/workflows/push.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Upload - -on: [push] - -jobs: - upload: - name: Upload to PyPi - runs-on: ubuntu-latest - steps: - - name: Check if tag was pushed - uses: actions/bin/filter@master - with: - args: 'tag' - - name: Checkout - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install dependencies - run: pip install -U pip && pip install -U twine setuptools wheel - - name: Build dist files - run: python setup.py sdist bdist_wheel - - name: Upload - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} - run: twine upload dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..71d3d5e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Release + +on: + push: + tags: + - '*.*.*' + +jobs: + release: + name: Release + runs-on: ubuntu-latest + env: + python-version: '3.8' + steps: + - uses: actions/checkout@v2 + - name: Get tag + id: tag + run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} + - name: Set up Python ${{ env.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ env.python-version }} + - name: Get Python version + id: python-version + run: | + echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + - name: Install Poetry + uses: dschep/install-poetry-action@v1.3 + with: + create_virtualenvs: 'true' + - name: Set Poetry config + run: | + poetry config virtualenvs.in-project true + - name: Get package version + id: package-version + run: echo ::set-output name=version::$(poetry version | grep -Po "\d+\.\d+\.\d+$") + - name: Check if tag matches package version + if: steps.tag.outputs.tag != steps.package-version.outputs.version + run: | + echo Tag: ${{ steps.tag.outputs.tag }} + echo Package version: ${{ steps.package-version.outputs.version }} + echo Tag and package version do not match + exit 1 + - name: Cache Poetry virtualenv + uses: actions/cache@v1 + id: cache + with: + path: .venv + key: poetry-venv-${{ runner.os }}-${{ steps.python-version.outputs.version }} + - name: Install/update package and dependencies + run: poetry install + - name: Create release ${{ steps.tag.outputs.tag }} + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.tag }} + release_name: ${{ steps.tag.outputs.tag }} + draft: 'false' + prerelease: 'false' + - name: Build and publish to PyPi + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish --build diff --git a/.gitignore b/.gitignore index f1f1d58..8987e65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .idea/ .vscode/ __pycache__/ + +poetry.lock +*.egg-info/ diff --git a/LICENSE b/LICENSE index cf1fb67..35484ea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Nihaal Sangha +Copyright (c) 2019-2020 Nihaal Sangha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/pecho/__init__.py b/pecho/__init__.py index a95eba9..ff8cc91 100644 --- a/pecho/__init__.py +++ b/pecho/__init__.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019 Nihaal Sangha +# Copyright (c) 2019-2020 Nihaal Sangha # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,17 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from importlib.metadata import version as _version + import colorama colorama.init() __all__ = ['echo'] -__version__ = '0.1.0' +__version__ = _version('pecho') -def echo(*objects, sep=' ', end='', file=None, flush=True, newline=False, print_func=print): +def echo(*objects, sep=' ', end='', file=None, flush=True, newline=False, print_func=print, **print_kwargs): if objects: objects = ('\r' + str(objects[0]),) + objects[1:] @@ -37,4 +39,4 @@ def echo(*objects, sep=' ', end='', file=None, flush=True, newline=False, print_ if newline: end += '\n' - print_func(*objects, sep=sep, end=end, file=file, flush=flush) + print_func(*objects, sep=sep, end=end, file=file, flush=flush, **print_kwargs) diff --git a/pecho/__init__.pyi b/pecho/__init__.pyi index c17fb1e..19969bc 100644 --- a/pecho/__init__.pyi +++ b/pecho/__init__.pyi @@ -5,5 +5,5 @@ __all__: List[str] __version__: str def echo(*objects: Any, sep: str = ' ', end: str = '', file: TextIO = sys.stdout, flush: bool = False, - newline: bool = False, print_func: Callable = print): + newline: bool = False, print_func: Callable = print, **print_kwargs: Any): ... diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d9fa403 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[tool.poetry] +name = "pecho" +version = "0.2.0" +description = "Easy way to write things like status bars" +authors = ["Nihaal Sangha <18350092+OrangutanGaming@users.noreply.github.com>"] +license = "MIT" +include = ["LICENSE"] +readme = "README.md" +repository = "https://github.com/OrangutanGaming/pecho" + +[tool.poetry.dependencies] +python = "^3.8" +colorama = "^0.4.3" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 3fcfb51..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -colorama diff --git a/setup.py b/setup.py deleted file mode 100644 index 14ec6c0..0000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -import re - -from setuptools import find_packages, setup - -with open('requirements.txt') as f: - requirements = f.read().splitlines() - -with open('pecho/__init__.py') as f: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError('Version is not set') - -if version.endswith(('a', 'b', 'rc')): - # Append version identifier based on commit count - try: - import subprocess - - p = subprocess.Popen(['git', 'rev-list', '--count', 'HEAD'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - if out: - version += out.decode('utf-8').strip() - p = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - if out: - version += '+g' + out.decode('utf-8').strip() - except Exception: - pass - -with open('README.md') as f: - readme = f.read() - -setup( - name="Pecho", - author="Nihaal Sangha (Orangutan)", - url="https://github.com/OrangutanGaming/pecho", - project_urls={ - "Issue tracker": "https://github.com/OrangutanGaming/pecho/issues", - }, - version=version, - packages=find_packages(), - license="MIT", - description="Pecho makes it easy to write things like status bars", - long_description=readme, - long_description_content_type="text/markdown", - include_package_data=True, - install_requires=requirements, - python_requires='>=3.3', - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - ] -)