Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate from setup.py to pyproject.toml #45

Merged
merged 4 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,45 @@

This adds compatibility for [TiDB](https://github.com/pingcap/tidb) to Django.

## Install
## Installation Guide

### Prerequisites

Before installing django-tidb, ensure you have a MySQL driver installed. You can choose either `mysqlclient`(recommended) or `pymysql`.

#### Install mysqlclient (Recommended)

Please refer to the [mysqlclient official guide](https://github.com/PyMySQL/mysqlclient#install)

#### Install pymysql

To install pymysql, use the following command:

```bash
pip install pymysql
```

Then add the following code at the beginning of your Django's `manage.py`:

```python
import pymysql

pymysql.install_as_MySQLdb()
```

### Installing django-tidb

Once you have a MySQL driver in place, proceed to install django-tidb:

```bash
pip install django-tidb
```

## Usage

Set `'ENGINE': 'django_tidb'` in your settings to this:

```
```python
DATABASES = {
'default': {
'ENGINE': 'django_tidb',
Expand All @@ -43,7 +71,7 @@ SECRET_KEY = 'django_tests_secret_key'

create your virtualenv with:

```
```bash
$ virtualenv venv
$ source venv/bin/activate
```
Expand All @@ -52,7 +80,7 @@ you can use the command ```deactivate``` to exit from the virtual environment.

run all integration tests.

```
```bash
$ DJANGO_VERSION=3.2.12 python run_testing_worker.py
```

Expand Down
2 changes: 1 addition & 1 deletion django_tidb/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def char(self, compiler, connection, **extra_context):
connection,
function="CHAR",
template="%(function)s(%(expressions)s USING utf8mb4)",
**extra_context
**extra_context,
)


Expand Down
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "django-tidb"
authors = [
{ name="Xiang Zhang", email="zhangxiang02@pingcap.com" },
{ name="Di Wang", email="wangdi@pingcap.com" }
]
description = "Django backend for TiDB"
readme = "README.md"
requires-python = ">=3.6"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.1",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://github.com/pingcap/tidb"
"Bug Reports" = "https://github.com/pingcap/django-tidb/issues"
"Source" = "https://github.com/pingcap/django-tidb"

[tool.setuptools]
packages = ["django_tidb"]

[tool.setuptools.dynamic]
version = {attr = "django_tidb.__version__"}
22 changes: 0 additions & 22 deletions setup.cfg

This file was deleted.

57 changes: 0 additions & 57 deletions setup.py

This file was deleted.