django-on-hatch
目次
詳細
このリポジトリはHatchプロジェクトマネージャーを使ったDjangoプロジェクトの開発またはテスト(お試し)ツールです。
配布用としてDjangoアプリをアップロードする環境を自動構築または配布用としてアップロードされたDjangoアプリをこのDjangoプロジェクトに組み込んでテストすることができます。
使用方法は以下からご覧ください。
インストール
実行環境は「Windows Sybsystem for Linux 2」のUbuntuです。
Pythonの環境は任意です。
私はpyenvを使用してPython3.7の環境を設定しています。
$ pyenv local 3.7
$ python3 --version
Python 3.7.0
仮想環境を作成して有効にし、Hatchをインストールします。
$ python3 -m venv .venv && . .venv/bin/activate
$ pip install --upgrade pip
$ pip install hatch keyrings.alt
リポジトリを落として「wagtail-polls」ディレクトリに入ります。
$ git clone https://github.com/kenno-warise/wagtail-polls.git
$ cd wagtail-polls
hatchコマンドでデータベースの作成・スーパーユーザーの作成・サーバーの起動を行います。
$ hatch run makemigrations polls && hatch run migrate
$ hatch run createsuperuser
$ hatch run runserver
ショートカットとしてHatchの「run」コマンドで実行できるDjangoのコマンドはpyproject.tomlの「tool.hatch.envs.default.scripts」テーブルによって登録しています。
[tool.hatch.envs.default.scripts]
makemigrations = "python3 manage.py makemigrations {args}"
migrate = "python3 manage.py migrate"
createsuperuser = "python3 manage.py createsuperuser"
runserver = "python3 manage.py runserver"
startapp = "python3 manage.py startapp {args}"
shell = "python3 manage.py shell"
test = "python3 manage.py test {args}"
cov = "coverage run --include=app/* --omit=app/test*,app/__init__.py,app/migrations manage.py test {args}"
cov-report = "coverage report -m"
アップロード
Hatchの「version」コマンドでDjangoアプリのバージョン情報を確認できます。
$ hatch version
0.0.1
DjangoアプリをパッケージングしてPyPIにアップロードする。
pyproject.tomlに配布するファイルと配布しないファイルを設定できます。
[tool.hatch.build]
include = ["app_2/*"] # templatesとstaticも含まれます。
exclude = ["app_2/migrations/*"]
上記以外にあれば追記します。
バージョンを更新する場合は「version」コマンドを実行します。
$ hatch version micro
Old: 0.0.1
New: 0.0.2
ビルドを実行します。
$ hatch build
アーティファクトを公開します。
$ hatch publish
Djangoプロジェクトに設定(テスト)
アップロード済みのDjangoアプリを設定します。
myproject/settings.py
pkgの部分をDjangoアプリ名に当てはめます。
INSTALLED_APPS = [
...,
"pkg",
]
myproject/urls.py
pkgの部分をDjangoアプリ名に当てはめます。
...
from django.urls import path, include
urlpatterns = [
...,
path('', include('pkg.urls')),
]
requirements.txt
pkgの部分をDjangoアプリ名に当てはめます。
django==2.2.5
pkg
必要であればマイグレートとスーパーユーザーを作成します。
$ hatch run migrate
$ hatch run createsuperuser
サーバーを起動します。
$ hatch run runserver
License
django-on-hatch is distributed under the terms of the MIT license.
Metadata
Release files for warise-polls 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| warise_polls-0.0.2.tar.gz | 9.5 kB | Without provenance | Details for warise_polls-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| warise_polls-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for warise_polls-0.0.2-py3-none-any.whl |
Total release size: 20.7 kB
Release files / warise_polls-0.0.2.tar.gz
| Download URL | warise_polls-0.0.2.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3da2322e70bdc8258a64a81b0cb9552f14e18a49b8b82b80a8694c65e9150237
|
|
BLAKE2b-256 checksum How to use checksums |
62ebee8ebb1e1ca2b81506d9a3a24a09a190401a37b3ba88f7c9248bca1b9cfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.1
|
Release files / warise_polls-0.0.2-py3-none-any.whl
| Download URL | warise_polls-0.0.2-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd577c1095b2d136d9038c0a24555497a9bff185990a56dd3503c6c9b3a69265
|
|
BLAKE2b-256 checksum How to use checksums |
d09715e984d189fb9e834e44478bdfb52ea1c82ccbe5e46a3ef06c98513d76d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.24.1
|
Security for warise-polls 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.