init commit

This commit is contained in:
arkohut 2024-05-27 10:35:20 +08:00
commit fc72c968d6
8 changed files with 102 additions and 0 deletions

45
.github/workflows/release.yml vendored Normal file
View File

@ -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

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.envrc
dist/
memos.egg-info/
build/
*.pyc

0
memos/__init__.py Normal file
View File

19
memos/commands.py Normal file
View File

@ -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()

7
memos/main.py Normal file
View File

@ -0,0 +1,7 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/libraries")
async def get_libraries():
return [{"name": "Library1"}, {"name": "Library2"}]

4
memos/server.py Normal file
View File

@ -0,0 +1,4 @@
import uvicorn
def run_server():
uvicorn.run("memos.main:app", host="0.0.0.0", port=8080, reload=True)

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
fastapi
uvicorn
httpx
typer

18
setup.py Normal file
View File

@ -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',
],
},
)