File: tox.ini

package info (click to toggle)
sqlalchemy 2.0.45%2Bds1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 26,868 kB
  • sloc: python: 416,938; makefile: 231; sh: 7
file content (359 lines) | stat: -rw-r--r-- 12,671 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359

[tox]
envlist = py

[greenletextras]
extras=
     asyncio
     sqlite: aiosqlite
     sqlite_file: aiosqlite

     # asyncpg doesnt build on free threading backends
     py{38,39,310,311,312,313,314}-postgresql: postgresql_asyncpg

     mysql: asyncmy
     mysql: aiomysql

     # aioodbc builds on free threading but segfaults once you use it
     py{38,39,310,311,312,313,314}-mssql: aioodbc

[testenv]
cov_args=--cov=sqlalchemy --cov-report term --cov-append --cov-report xml --exclude-tag memory-intensive --exclude-tag timing-intensive -k "not aaa_profiling"

# this needs to be set as of tox 4.4.0 *if* we have extras (e.g. .[aiosqlite])
# inside of deps.  But we put them in extras now.
# see https://github.com/tox-dev/tox/issues/2898
# constrain_package_deps=false

usedevelop=
     cov: True

extras=
     # this can be limited to specific python versions IF there is no
     # greenlet available for the most recent python.  otherwise
     # keep this present in all cases
     # py{38,39,310,311,312,313,314,313t,314t}: {[greenletextras]extras}

     {[greenletextras]extras}

     postgresql: postgresql
     postgresql: postgresql_pg8000
     postgresql: postgresql_psycopg

     mysql: mysql
     mysql: pymysql

     # see https://jira.mariadb.org/browse/CONPY-318.
     # installed manually as part of deps w/ version pin
     # mysql: mariadb_connector

     oracle: oracle
     oracle: oracle_oracledb
     mssql: mssql
     mssql-py{38,39,310,311,312,313}: mssql_pymssql

install_command=
     # TODO: I can find no way to get pip / tox / anyone to have this
     # --only-binary option local to the pymssql install, rather than global
     # as it is here.
     python -I -m pip install --only-binary=pymssql {opts} {packages}

deps=
     typing-extensions>=4.13.0rc1; python_version > '3.7'

     # see https://jira.mariadb.org/browse/CONPY-318.
     # using < to block all future versions for now as it's not clear
     # if newer versions will fix the segfault or not
     mysql: mariadb<1.1.13

     pytest>=7.0.0,<10
     # tracked by https://github.com/pytest-dev/pytest-xdist/issues/907
     pytest-xdist!=3.3.0

     dbapimain-sqlite: git+https://github.com/omnilib/aiosqlite.git\#egg=aiosqlite

     dbapimain-postgresql: git+https://github.com/psycopg/psycopg2.git\#egg=psycopg2
     dbapimain-postgresql: git+https://github.com/MagicStack/asyncpg.git\#egg=asyncpg
     dbapimain-postgresql: git+https://github.com/tlocke/pg8000.git\#egg=pg8000
     dbapimain-postgresql: git+https://github.com/psycopg/psycopg.git\#egg=psycopg&subdirectory=psycopg
     # dbapimain-postgresql: git+https://github.com/psycopg/psycopg.git\#egg=psycopg-c&subdirectory=psycopg_c

     dbapimain-mysql: git+https://github.com/PyMySQL/mysqlclient-python.git\#egg=mysqlclient
     dbapimain-mysql: git+https://github.com/PyMySQL/PyMySQL.git\#egg=pymysql

#    dbapimain-mysql: git+https://github.com/mariadb-corporation/mariadb-connector-python\#egg=mariadb

     dbapimain-oracle: git+https://github.com/oracle/python-cx_Oracle.git\#egg=cx_Oracle

     py313-mssql: git+https://github.com/mkleehammer/pyodbc.git\#egg=pyodbc
     dbapimain-mssql: git+https://github.com/mkleehammer/pyodbc.git\#egg=pyodbc

     cov: pytest-cov

allowlist_externals=sh

# PYTHONPATH - erased so that we use the build that's present
# in .tox as the SQLAlchemy library to be imported
#
# PYTHONNOUSERSITE - this *MUST* be set so that the ./lib/ import
# set up explicitly in test/conftest.py is *disabled*, again so that
# when SQLAlchemy is built into the .tox area, we use that and not the
# local checkout, at least when usedevelop=False
#
# BASECOMMAND - using an env variable here so we can use it
# as a substitution in a command (see https://bitbucket.org/hpk42/tox/issues/307/)
#
# only use --dropfirst option if we're *not* using -n;
# if -n is used, we're working in brand new DBs anyway, dropfirst
# will collide on CI environments
setenv=
    PYTHONPATH=
    PYTHONNOUSERSITE=1
    PYTEST_EXCLUDES=-m "not memory_intensive and not mypy"

    # ensure older pip is installed for EOL python versions
    py37: VIRTUALENV_PIP=24.0

    PYTEST_COLOR={tty:--color=yes}
    MYPY_COLOR={tty:--color-output}

    BASECOMMAND=python -m pytest {env:PYTEST_COLOR} --rootdir {toxinidir} --log-info=sqlalchemy.testing

    WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}

    {py313t,py314t}: PYTHON_GIL=0    # when running with 313t, 314t, go for broke

    # affect setup.py to skip or build the cython extensions.
    nocext: DISABLE_SQLALCHEMY_CEXT=1
    cext: REQUIRE_SQLALCHEMY_CEXT=1

    cov: COVERAGE={[testenv]cov_args}
    backendonly: PYTEST_EXCLUDES="-m backend"

    memusage: PYTEST_EXCLUDES="-m memory_intensive"
    memusage: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite}
    memusage: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2}
    memusage: WORKERS={env:TOX_WORKERS:-n2}

    oracle: WORKERS={env:TOX_WORKERS:-n2  --max-worker-restart=5}
    oracle: ORACLE={env:TOX_ORACLE:--db oracle}
    oracle: EXTRA_ORACLE_DRIVERS={env:EXTRA_ORACLE_DRIVERS:--dbdriver cx_oracle --dbdriver oracledb --dbdriver oracledb_async}
    oracle-nogreenlet: EXTRA_ORACLE_DRIVERS={env:EXTRA_ORACLE_DRIVERS:--dbdriver cx_oracle --dbdriver oracledb}

    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
    sqlite-py{38,39,310,311,312,313,314}: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver pysqlite_numeric --dbdriver aiosqlite}
    sqlite-nogreenlet: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver pysqlite_numeric}

    sqlite_file: SQLITE={env:TOX_SQLITE_FILE:--db sqlite_file}
    sqlite_file: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite}
    sqlite_file-nogreenlet: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite}

    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
    postgresql: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver asyncpg --dbdriver pg8000 --dbdriver psycopg --dbdriver psycopg_async}
    postgresql-nogreenlet: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver pg8000 --dbdriver psycopg}
    postgresql-{py313t,py314t}: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver pg8000 --dbdriver psycopg --dbdriver psycopg_async}

    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
    mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver asyncmy --dbdriver aiomysql --dbdriver mariadbconnector}
    mysql-nogreenlet: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector}

    # for mssql, aioodbc frequently segfaults under free-threaded builds
    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
    mssql: EXTRA_MSSQL_DRIVERS={env:EXTRA_MSSQL_DRIVERS:--dbdriver pyodbc --dbdriver aioodbc --dbdriver pymssql}
    mssql-py314: EXTRA_MSSQL_DRIVERS={env:EXTRA_MSSQL_DRIVERS:--dbdriver pyodbc  --dbdriver aioodbc}
    mssql-{py313t,py314t,nogreenlet: EXTRA_MSSQL_DRIVERS={env:EXTRA_MSSQL_DRIVERS:--dbdriver pyodbc --dbdriver pymssql}

    oracle,mssql,sqlite_file: IDENTS=--write-idents db_idents.txt



# tox as of 2.0 blocks all environment variables from the
# outside, unless they are here (or in TOX_TESTENV_PASSENV,
# wildcards OK).  Need at least these
passenv=
    ORACLE_HOME
    NLS_LANG
    TOX_POSTGRESQL
    TOX_POSTGRESQL_PY2K
    TOX_MYSQL
    TOX_MYSQL_PY2K
    TOX_ORACLE
    TOX_MSSQL
    TOX_SQLITE
    TOX_SQLITE_FILE
    TOX_WORKERS
    EXTRA_SQLITE_DRIVERS
    EXTRA_PG_DRIVERS
    EXTRA_MYSQL_DRIVERS
    EXTRA_ORACLE_DRIVERS
    PYTHON_GIL

commands=

  # removing *.so from lib/ is only useful when usedevelop=True is enabled,
  # otherwise the library was already installed in the tox env with or
  # without the cython extensions built.  We use usedevelop=True for coverage
  # mode.
  nocext: sh -c "rm -f lib/sqlalchemy/*.so"

  nogreenlet: pip uninstall -y greenlet
  {env:BASECOMMAND} {env:WORKERS} {env:SQLITE:} {env:EXTRA_SQLITE_DRIVERS:} {env:POSTGRESQL:} {env:EXTRA_PG_DRIVERS:} {env:MYSQL:} {env:EXTRA_MYSQL_DRIVERS:} {env:ORACLE:} {env:EXTRA_ORACLE_DRIVERS:} {env:MSSQL:} {env:EXTRA_MSSQL_DRIVERS:} {env:IDENTS:} {env:PYTEST_EXCLUDES:} {env:COVERAGE:} {posargs}
  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt


[testenv:pep484]
deps=
     greenlet >= 1
     importlib_metadata; python_version < '3.8'
     mypy >= 1.19.0
     types-greenlet
commands =
    mypy  {env:MYPY_COLOR} ./lib/sqlalchemy

extras =
     {[greenletextras]extras}

[testenv:mypy]
deps=
     pytest>=7.0.0rc1,<10
     pytest-xdist
     types-greenlet
     importlib_metadata; python_version < '3.8'
     mypy >= 1.19.0
     patch==1.*
extras=
     {[greenletextras]extras}

commands =
    pytest {env:PYTEST_COLOR} -m mypy {posargs}

[testenv:mypy-cov]

deps=
     {[testenv:mypy]deps}
     pytest-cov

extras=
     {[greenletextras]extras}

commands =
    pytest {env:PYTEST_COLOR} -m mypy {env:COVERAGE} {posargs}

setenv=
    COVERAGE={[testenv]cov_args}

# thanks to https://julien.danjou.info/the-best-flake8-extensions/
[testenv:lint]
basepython = python3

extras=
     {[greenletextras]extras}

deps=
      flake8-pyproject
      flake8>=7.3.0
      flake8-import-order>=0.19.2
      flake8-builtins
      flake8-future-annotations>=0.0.5
      flake8-docstrings>=1.6.0
      flake8-import-single==0.1.5
      flake8-unused-arguments
      flake8-rst-docstrings
      # flake8-rst-docstrings dependency, leaving it here
      # in case it requires a version pin
      pydocstyle
      pygments
      black==25.11.0
      slotscheck>=0.17.0

      # required by generate_tuple_map_overloads
      zimports>=0.7.0
allowlist_externals =
    env
    git
    sh
commands =
     flake8p ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}

     # run "unused argument" lints on asyncio, as we have a lot of
     # proxy methods here
     flake8p  --ignore='' --select='U100,U101' ./lib/sqlalchemy/ext/asyncio ./lib/sqlalchemy/orm/scoping.py

     black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py
     # test with cython and without cython exts running
     slotscheck -m sqlalchemy
     env DISABLE_SQLALCHEMY_CEXT_RUNTIME=1 slotscheck -m sqlalchemy
     python ./tools/format_docs_code.py --check
     python ./tools/generate_tuple_map_overloads.py --check
     python ./tools/generate_proxy_methods.py --check
     python ./tools/sync_test_files.py --check
     python ./tools/generate_sql_functions.py --check
     python ./tools/normalize_file_headers.py --check
     python ./tools/walk_packages.py


# this is a test.
#
# "pep8" env was renamed to "lint".
# Kept for backwards compatibility until rename is completed elsewhere.
[testenv:pep8]
basepython = {[testenv:lint]basepython}
deps = {[testenv:lint]deps}
allowlist_externals = {[testenv:lint]allowlist_externals}
commands = {[testenv:lint]commands}
extras = {[testenv:lint]extras}



# command run in the github action when cext are active.
# unfortunately it seems impossible to use generative tags with envs
# that are not the default.  so in the interim, build out three separate
# envs with explicit names

[testenv:githubbase]
extras=
setenv=
     PYTHONNOUSERSITE=1

     WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}
     PYTEST_COLOR={tty:--color=yes}
     PYTEST_EXCLUDES=-m "not memory_intensive and not mypy and not timing_intensive and not gc_intensive"
     SQLITE=--db sqlite

commands=
  python -m pytest {env:PYTEST_COLOR} {env:WORKERS} {env:PYTEST_EXCLUDES:} {env:SQLITE} {posargs}
  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt

[testenv:github-cext-greenlet]
extras=
     asyncio
     aiosqlite
setenv=
     {[testenv:githubbase]setenv}
     REQUIRE_SQLALCHEMY_CEXT=1
     SQLITE=--db sqlite --db aiosqlite
commands=
  python -m pytest {env:PYTEST_COLOR} {env:WORKERS} {env:PYTEST_EXCLUDES:} {env:SQLITE} {posargs}
  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt

[testenv:github-cext]
extras=
setenv=
     {[testenv:githubbase]setenv}
     REQUIRE_SQLALCHEMY_CEXT=1
deps = {[testenv:githubbase]deps}
commands=
  python -m pytest {env:PYTEST_COLOR} {env:WORKERS} {env:PYTEST_EXCLUDES:} {env:SQLITE} {posargs}
  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt


[testenv:github-nocext]
extras=
setenv=
     {[testenv:githubbase]setenv}
     DISABLE_SQLALCHEMY_CEXT=1
deps = {[testenv:githubbase]deps}
commands=
  python -m pytest {env:PYTEST_COLOR} {env:WORKERS} {env:PYTEST_EXCLUDES:} {env:SQLITE} {posargs}
  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt