From 3179cd1f5e628976092c209fc357bb295f467aae Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 21 Feb 2022 11:41:42 +0900 Subject: [PATCH] Add create-package.sh --- .github/workflows/pypi-publish.yml | 2 ++ docs/getting-started.md | 24 ++++++++++++++++++++++++ tools/create-package.sh | 11 +++++++++++ 3 files changed, 37 insertions(+) create mode 100755 tools/create-package.sh diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 7dbd94c3..f1ee88ab 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -37,9 +37,11 @@ jobs: - name: collectstatic run: | poetry run task collectstatic + working-directory: ./backend - name: Build a binary wheel and a source tarball run: | poetry build + working-directory: ./backend - name: Publish a Python distribution to PyPI uses: pypa/gh-action-pypi-publish@master with: diff --git a/docs/getting-started.md b/docs/getting-started.md index c3ab1b29..61e8e2d1 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -103,3 +103,27 @@ Then run the `dev` command to serve with hot reload at : ```bash yarn dev ``` + +## How to create a Python package + +During development, you may want to create a Python package and verify it works correctly. In such a case, you can create a package by running the following command in the root directory of your project: + +```bash +./tools/create-package.sh +``` + +This command builds the frontend, copies the files, and packages them. This will take a few minutes. After finishing the command, you will find `sdist` and `wheel` in `backend/dist`: + +```bash +Building doccano (1.5.5.post335.dev0+6be6d198) + - Building sdist + - Built doccano-1.5.5.post335.dev0+6be6d198.tar.gz + - Building wheel + - Built doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl +``` + +Then, you can install the package via `pip install` command: + +```bash +pip install doccano-1.5.5.post335.dev0+6be6d198-py3-none-any.whl +``` diff --git a/tools/create-package.sh b/tools/create-package.sh new file mode 100755 index 00000000..e9896c8a --- /dev/null +++ b/tools/create-package.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +mkdir -p backend/client + +cd frontend +export PUBLIC_PATH="/static/_nuxt/" +yarn build +cp -r dist ../backend/client/ + +cd ../backend +poetry run task collectstatic +poetry build