From 4bc079b6335cc2699424dd9e2a27708ed81408e4 Mon Sep 17 00:00:00 2001 From: rex <1073853456@qq.com> Date: Mon, 5 Aug 2024 00:52:27 +0800 Subject: [PATCH] initial commit --- .github/ISSUE_TEMPLATE.md | 15 ++++ .github/workflows/publish.yml | 31 +++++++ .github/workflows/test.yml | 48 ++++++++++ .gitignore | 160 ++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++ README.md | 22 +++++ requirements_dev.txt | 10 +++ setup.cfg | 9 ++ setup.py | 44 ++++++++++ src/one-api-cli/__init__.py | 5 ++ tests/__init__.py | 1 + 11 files changed, 366 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 requirements_dev.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 src/one-api-cli/__init__.py create mode 100644 tests/__init__.py diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..eff9ecf --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ +* one-api-cli version: +* Python version: +* Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e0ad872 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,31 @@ +name: Publish Package + +on: + push: + tags: + - '*' + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Verify tag matches setup.py version + run: | + if [[ "$(git describe --tags)" != "$(grep "^VERSION" setup.py | cut -d"'" -f2)" ]]; then echo "Tag does not match setup.py version"; exit 0; fi + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine check dist/* + twine upload dist/* --skip-existing diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8f6f824 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Python Package + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - python-version: "3.9" + os: ubuntu-latest + - python-version: "3.9" + os: macos-latest + # - python-version: "3.9" + # os: window + + 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: | + python -m pip install --upgrade pip + python -m pip install .[test] + python -m pip install -r requirements_dev.txt + - name: Test with pytest and coverage + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_API_BASE_URL: ${{ secrets.OPENAI_API_BASE_URL }} + run: | + pip install coverage + coverage run -m pytest tests/ + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/.gitignore @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9d38028 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 RexWang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..638b4fb --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# One API CLI + +
+ + PyPI version + + + Tests + + + Documentation Status + + + Coverage + +
+ +# Installation + +```bash +pip install one-api-cli +``` diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..22e5671 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,10 @@ +pip==19.2.3 +bump2version==0.5.11 +wheel==0.33.6 +watchdog==0.9.0 +flake8==3.7.8 +tox==3.14.0 +coverage==4.5.4 +Sphinx==1.8.5 +twine==1.14.0 +pytest==6.2.4 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c19c950 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs +[tool:pytest] +addopts = --ignore=setup.py + + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..62b10e8 --- /dev/null +++ b/setup.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +"""The setup script.""" + +from setuptools import setup, find_packages + +VERSION = '0.1.0' + +with open('README.md') as readme_file: + readme = readme_file.read() + +requirements = ['requests', 'click'] + +test_requirements = ['pytest>=3'] + +setup( + author="Rex Wang", + author_email='1073853456@qq.com', + python_requires='>=3.6', + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + ], + description="A CLI for the One API project", + install_requires=requirements, + license="MIT license", + # long_description=readme + '\n\n' + history , + include_package_data=True, + keywords='One API CLI', + name='one-api-cli', + packages=find_packages(include=['src', 'src.*']), + test_suite='tests', + tests_require=test_requirements, + url='https://github.com/RexWzh/one-api-cli', + version=VERSION, + zip_safe=False, +) diff --git a/src/one-api-cli/__init__.py b/src/one-api-cli/__init__.py new file mode 100644 index 0000000..41bc4d1 --- /dev/null +++ b/src/one-api-cli/__init__.py @@ -0,0 +1,5 @@ +"""Top-level package for one-api-cli.""" + +__author__ = """Rex Wang""" +__email__ = '1073853456@qq.com' +__version__ = '0.1.0' diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..29f35c5 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Unit test package for one-api-cli."""