diff --git a/.github/workflows/main.yml b/.github/workflows/ruff.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/ruff.yml diff --git a/.gitignore b/.gitignore index 7aa23ee..e721d1a 100644 --- a/.gitignore +++ b/.gitignore @@ -165,3 +165,4 @@ queries # 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/ +.ruff_cache \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30e882a..e8aa2ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,4 +3,5 @@ repos: rev: v0.11.10 hooks: - id: ruff + args: [--fix] - id: ruff-format \ No newline at end of file diff --git a/README.md b/README.md index 5884a85..6c40f35 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,113 @@ -# pythonbooks -<<<<<<< HEAD +[![Ruff](https://github.com/khoshov/pythonbooks/actions/workflows/ruff.yml/badge.svg)](https://github.com/khoshov/pythonbooks/actions/workflows/ruff.yml) +## Установка и использование UV -## -- python -m pre_commit run --all-files -- pre-commit run --all-files -======= -## -pre-commit run --all-files -python -m pre_commit run --all-files ->>>>>>> c2e78f81458663ba5834fa5b4731ef2b58bd57be +
+📦 Способы установки UV + +### 1. Установка через автономные установщики (рекомендуется) + +**Для macOS и Linux:** +```bash +curl -LsSf https://astral.sh/uv/install.sh | sh +``` + +**Для Windows (PowerShell):** +```powershell +powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" +``` + +### 2. Установка через PyPI (альтернативный способ) +```bash +pip install uv +``` + +### Обновление UV +После установки вы можете обновить UV до последней версии: +```bash +uv self update +``` + +🔗 Подробнее об установке: [Официальная документация](https://docs.astral.sh/uv/getting-started/installation/) +
+ +--- + +
+🚀 Основные команды UV + +### Управление Python-окружением + +**Установка конкретной версии Python:** +```bash +uv python install 3.13 # Установит Python 3.13 +``` + +### Управление зависимостями + +**Синхронизация зависимостей проекта:** +```bash +uv sync # Аналог pip install + pip-compile +``` + +**Запуск команд в окружении проекта:** +```bash +uv run # Например: uv run pytest +``` + +**Запуск Django-сервера:** +```bash +uv run manage.py runserver # Альтернатива python manage.py runserver +``` +
+ +--- + +
+🔍 Интеграция с Ruff + +[Ruff](https://github.com/astral-sh/ruff) - это молниеносный линтер для Python, также разработанный Astral. + +**Установка Ruff через UV:** +```bash +uvx ruff # Установит последнюю версию Ruff +``` + +**Проверка кода с помощью Ruff:** +```bash +uvx ruff check . # Проверит все файлы в текущей директории +``` +
+ +--- + +## Запуск проекта в Docker + +**Сборка и запуск контейнеров:** +```bash +docker-compose up --build # Соберет и запустит сервисы +``` + +## Структура + +```python + +pythonbooks +│ +├── .github/workflows +│ └── ruff.yml +│ +├── apps +│ └── books +│ +├── config +│ +├── .gitignore +├── .pre-commit-config.yaml +├── manage.py +├── requirements.txt - зависимости +├── .env +└── README.md +``` \ No newline at end of file diff --git a/backend/pythonbooks/pythonbooks/__init__.py b/apps/__init__.py similarity index 100% rename from backend/pythonbooks/pythonbooks/__init__.py rename to apps/__init__.py diff --git a/apps/books/__init__.py b/apps/books/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/books/admin.py b/apps/books/admin.py new file mode 100644 index 0000000..846f6b4 --- /dev/null +++ b/apps/books/admin.py @@ -0,0 +1 @@ +# Register your models here. diff --git a/apps/books/apps.py b/apps/books/apps.py new file mode 100644 index 0000000..ece2db9 --- /dev/null +++ b/apps/books/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BooksConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "apps.books" diff --git a/apps/books/migrations/__init__.py b/apps/books/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/books/models.py b/apps/books/models.py new file mode 100644 index 0000000..6b20219 --- /dev/null +++ b/apps/books/models.py @@ -0,0 +1 @@ +# Create your models here. diff --git a/apps/books/tests.py b/apps/books/tests.py new file mode 100644 index 0000000..a39b155 --- /dev/null +++ b/apps/books/tests.py @@ -0,0 +1 @@ +# Create your tests here. diff --git a/apps/books/views.py b/apps/books/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/apps/books/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/backend/pythonbooks/pythonbooks/asgi.py b/backend/pythonbooks/pythonbooks/asgi.py deleted file mode 100644 index 5141a19..0000000 --- a/backend/pythonbooks/pythonbooks/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for pythonbooks project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pythonbooks.settings") - -application = get_asgi_application() diff --git a/backend/pythonbooks/pythonbooks/urls.py b/backend/pythonbooks/pythonbooks/urls.py deleted file mode 100644 index 52d6d59..0000000 --- a/backend/pythonbooks/pythonbooks/urls.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -URL configuration for pythonbooks project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" - -from django.contrib import admin -from django.urls import path - -urlpatterns = [ - path("admin/", admin.site.urls), -] diff --git a/backend/pythonbooks/pythonbooks/wsgi.py b/backend/pythonbooks/pythonbooks/wsgi.py deleted file mode 100644 index 73bd91b..0000000 --- a/backend/pythonbooks/pythonbooks/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for pythonbooks project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pythonbooks.settings") - -application = get_wsgi_application() diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/asgi.py b/config/asgi.py new file mode 100644 index 0000000..856079b --- /dev/null +++ b/config/asgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_asgi_application() diff --git a/backend/pythonbooks/pythonbooks/settings.py b/config/settings.py similarity index 94% rename from backend/pythonbooks/pythonbooks/settings.py rename to config/settings.py index b9d6376..507d928 100644 --- a/backend/pythonbooks/pythonbooks/settings.py +++ b/config/settings.py @@ -37,6 +37,7 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "apps.books.apps.BooksConfig", ] MIDDLEWARE = [ @@ -49,7 +50,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = "pythonbooks.urls" +ROOT_URLCONF = "config.urls" TEMPLATES = [ { @@ -66,7 +67,7 @@ }, ] -WSGI_APPLICATION = "pythonbooks.wsgi.application" +WSGI_APPLICATION = "config.wsgi.application" # Database @@ -101,13 +102,13 @@ # Internationalization # https://docs.djangoproject.com/en/5.2/topics/i18n/ - -LANGUAGE_CODE = "en-us" - +LANGUAGE_CODE = "en" +LANGUAGES = [ + ("en", "English"), + ("ru", "Russian"), +] TIME_ZONE = "UTC" - USE_I18N = True - USE_TZ = True diff --git a/config/urls.py b/config/urls.py new file mode 100644 index 0000000..083932c --- /dev/null +++ b/config/urls.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path("admin/", admin.site.urls), +] diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..8509335 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") + +application = get_wsgi_application() diff --git a/backend/pythonbooks/manage.py b/manage.py similarity index 75% rename from backend/pythonbooks/manage.py rename to manage.py index 2e5eba3..e2fade5 100644 --- a/backend/pythonbooks/manage.py +++ b/manage.py @@ -1,13 +1,10 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" - import os import sys def main(): """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pythonbooks.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: