From fc72c968d6529d7d273204e9d5abb774f0dd3c89 Mon Sep 17 00:00:00 2001 From: arkohut <39525455+arkohut@users.noreply.github.com> Date: Mon, 27 May 2024 10:35:20 +0800 Subject: [PATCH] init commit --- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ .gitignore | 5 ++++ memos/__init__.py | 0 memos/commands.py | 19 +++++++++++++++ memos/main.py | 7 ++++++ memos/server.py | 4 ++++ requirements.txt | 4 ++++ setup.py | 18 ++++++++++++++ 8 files changed, 102 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 memos/__init__.py create mode 100644 memos/commands.py create mode 100644 memos/main.py create mode 100644 memos/server.py create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e36bc9d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +on: + push: + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + build: + name: Build dist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Build + run: | + pip install setuptools wheel twine + python setup.py sdist bdist_wheel + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + + release: + needs: build + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/memos + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4a1787 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.envrc +dist/ +memos.egg-info/ +build/ +*.pyc diff --git a/memos/__init__.py b/memos/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/memos/commands.py b/memos/commands.py new file mode 100644 index 0000000..35c4bf8 --- /dev/null +++ b/memos/commands.py @@ -0,0 +1,19 @@ +import typer +import httpx +from memos.server import run_server + +app = typer.Typer() + +@app.command() +def serve(): + run_server() + +@app.command() +def ls(): + response = httpx.get("http://localhost:8080/libraries") + libraries = response.json() + for library in libraries: + print(library['name']) + +if __name__ == "__main__": + app() diff --git a/memos/main.py b/memos/main.py new file mode 100644 index 0000000..bf098c1 --- /dev/null +++ b/memos/main.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/libraries") +async def get_libraries(): + return [{"name": "Library1"}, {"name": "Library2"}] diff --git a/memos/server.py b/memos/server.py new file mode 100644 index 0000000..1706d5e --- /dev/null +++ b/memos/server.py @@ -0,0 +1,4 @@ +import uvicorn + +def run_server(): + uvicorn.run("memos.main:app", host="0.0.0.0", port=8080, reload=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..56c529c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +fastapi +uvicorn +httpx +typer diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e184403 --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup, find_packages + +setup( + name='memos', + version='0.1', + packages=find_packages(), + install_requires=[ + 'fastapi', + 'uvicorn', + 'httpx', + 'typer' + ], + entry_points={ + 'console_scripts': [ + 'memos=memos.commands:app', + ], + }, +)