Skip to content

Commit

Permalink
feat: migrate from setup.py to pyproject.toml (#45)
Browse files Browse the repository at this point in the history
* migrate to pyproject.toml

* update README
  • Loading branch information
wd0517 authored Aug 15, 2023
1 parent 9188c22 commit 5dc2a33
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 84 deletions.
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.

0 comments on commit 5dc2a33

Please sign in to comment.