Skip to content

Commit d242bc7

Browse files
Rework build to use setuptools exclusively and enable use of pyproject.toml;
rework test suite to use tox and simplify test suite (also added a test number to each test case for easier reference).
1 parent 2194d81 commit d242bc7

36 files changed

+1065
-1119
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.pyc
2+
.tox/
23
build/
34
dist/
45
doc/build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ of exclusions. See the
77
[homepage](https://oracle.github.io/python-cx_Oracle/index.html) for a
88
feature list.
99

10-
cx_Oracle 8 has been tested with Python versions 3.5 through 3.8. You can use
10+
cx_Oracle 8 has been tested with Python versions 3.6 through 3.9. You can use
1111
cx_Oracle with Oracle 11.2, 12c, 18c and 19c client libraries. Oracle's
1212
standard client-server version interoperability allows connection to both older
1313
and newer databases. For example Oracle 19c client libraries can connect to

doc/src/release_notes.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ Version 8.1 (TBD)
1111
#) Updated embedded ODPI-C to `version 4.1.0
1212
<https://oracle.github.io/odpi/doc/releasenotes.html#
1313
version-4-1-0-tbd>`__.
14+
#) Dropped support for Python 3.5. Added support for Python 3.9.
1415
#) Added internal methods for getting/setting OCI attributes that are
1516
otherwise not supported by cx_Oracle. These methods should only be used as
1617
directed by Oracle.
1718
#) Minor code improvement supplied by Alex Henrie
1819
(`PR 472 <https://github.com/oracle/python-cx_Oracle/pull/472>`__).
19-
#) Improved documentation.
20+
#) Builds are now done with setuptools and most metadata has moved from
21+
`setup.py` to `setup.cfg` in order to take advantage of Python packaging
22+
improvements.
23+
#) Tests can now be run with tox in order to automate testing of the different
24+
environments that are supported.
25+
#) Improved documentation and test suite.
2026

2127

2228
Version 8.0.1 (August 2020)

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools >= 40.6.0", "wheel"]
3+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[metadata]
2+
name = cx_Oracle
3+
description = Python interface to Oracle
4+
long_description = file: README.md
5+
long_description_content_type = text/markdown
6+
keywords = Oracle, database
7+
author = "Anthony Tuininga",
8+
author_email = "[email protected]",
9+
license = BSD License
10+
url = https://oracle.github.io/python-cx_Oracle
11+
project_urls =
12+
Installation = https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
13+
Samples = https://github.com/oracle/python-cx_Oracle/tree/master/samples
14+
Documentation = http://cx-oracle.readthedocs.io
15+
Release Notes = https://cx-oracle.readthedocs.io/en/latest/release_notes.html#releasenotes
16+
Issues = https://github.com/oracle/python-cx_Oracle/issues
17+
Source = https://github.com/oracle/python-cx_Oracle
18+
python_requires = >=3.6
19+
classifiers =
20+
Development Status :: 6 - Mature
21+
Intended Audience :: Developers
22+
License :: OSI Approved :: BSD License
23+
Natural Language :: English
24+
Operating System :: OS Independent
25+
Programming Language :: C
26+
Programming Language :: Python :: 3 :: Only
27+
Topic :: Database

setup.py

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Distutils script for cx_Oracle.
1+
"""Setup script for cx_Oracle.
22
33
Windows platforms:
44
python setup.py build --compiler=mingw32 install
@@ -8,21 +8,18 @@
88
99
"""
1010

11-
import distutils.core
1211
import os
12+
import pkg_resources
13+
import setuptools
1314
import sys
1415

1516
# check minimum supported Python version
16-
if sys.version_info[:2] < (3, 5):
17-
raise Exception("Python 3.5 or higher is required. " +
17+
if sys.version_info[:2] < (3, 6):
18+
raise Exception("Python 3.6 or higher is required. " +
1819
"For python 2, use 'pip install cx_Oracle==7.3'")
1920

20-
# if setuptools is detected, use it to add support for eggs
21-
try:
22-
from setuptools import setup, Extension
23-
except:
24-
from distutils.core import setup
25-
from distutils.extension import Extension
21+
# check minimum supported version of setuptools
22+
pkg_resources.require("setuptools>=40.6.0")
2623

2724
# define build constants
2825
BUILD_VERSION = "8.1.0-dev"
@@ -39,43 +36,12 @@
3936
elif sys.platform == "darwin":
4037
extraLinkArgs.append("-shared-libgcc")
4138

42-
class test(distutils.core.Command):
43-
description = "run the test suite for the extension"
44-
user_options = []
45-
46-
def finalize_options(self):
47-
pass
48-
49-
def initialize_options(self):
50-
pass
51-
52-
def run(self):
53-
self.run_command("build")
54-
buildCommand = self.distribution.get_command_obj("build")
55-
sys.path.insert(0, os.path.abspath("test"))
56-
sys.path.insert(0, os.path.abspath(buildCommand.build_lib))
57-
fileName = os.path.join("test", "test.py")
58-
exec(open(fileName).read())
59-
60-
# define classifiers for the package index
61-
classifiers = [
62-
"Development Status :: 6 - Mature",
63-
"Intended Audience :: Developers",
64-
"License :: OSI Approved :: BSD License",
65-
"Natural Language :: English",
66-
"Operating System :: OS Independent",
67-
"Programming Language :: C",
68-
"Programming Language :: Python :: 3 :: Only",
69-
"Topic :: Database"
70-
]
71-
7239
# define cx_Oracle sources
7340
sourceDir = "src"
7441
sources = [os.path.join(sourceDir, n) \
7542
for n in sorted(os.listdir(sourceDir)) if n.endswith(".c")]
7643
depends = ["src/cxoModule.h"]
7744

78-
7945
# define ODPI-C sources, libraries and include directories; if the environment
8046
# variables ODPIC_INC_DIR and ODPIC_LIB_DIR are both set, assume these
8147
# locations contain a compiled installation of ODPI-C; otherwise, use the
@@ -98,7 +64,7 @@ def run(self):
9864
libraryDirs = []
9965

10066
# setup the extension
101-
extension = Extension(
67+
extension = setuptools.Extension(
10268
name = "cx_Oracle",
10369
include_dirs = includeDirs,
10470
extra_compile_args = extraCompileArgs,
@@ -110,22 +76,7 @@ def run(self):
11076
library_dirs = libraryDirs)
11177

11278
# perform the setup
113-
setup(
114-
name = "cx_Oracle",
79+
setuptools.setup(
11580
version = BUILD_VERSION,
116-
description = "Python interface to Oracle",
117-
cmdclass = dict(test = test),
11881
data_files = [ ("cx_Oracle-doc", ["LICENSE.txt", "README.txt"]) ],
119-
long_description = \
120-
"Python interface to Oracle Database conforming to the Python DB "
121-
"API 2.0 specification.\n"
122-
"See http://www.python.org/topics/database/DatabaseAPI-2.0.html.",
123-
author = "Anthony Tuininga",
124-
author_email = "[email protected]",
125-
url = "https://oracle.github.io/python-cx_Oracle",
126-
python_requires = ">=3.5",
127-
ext_modules = [extension],
128-
keywords = "Oracle",
129-
license = "BSD License",
130-
classifiers = classifiers)
131-
82+
ext_modules = [extension])

test/README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,45 @@ This directory contains the test suite for cx_Oracle.
22

33
1. The schemas and SQL objects that are referenced in the test suite can be
44
created by running the Python script [SetupTest.py][1]. The script requires
5-
SYSDBA privileges and will prompt for these credentials as well as the
6-
names of the schemas that will be created, unless a number of environment
7-
variables are set as documented in the Python script [TestEnv.py][2]. Run
8-
the script using the following command:
5+
administrative privileges and will prompt for these credentials as well as
6+
the names of the schemas that will be created, unless a number of
7+
environment variables are set as documented in the Python script
8+
[TestEnv.py][2]. Run the script using the following command:
99

1010
python SetupTest.py
1111

1212
Alternatively, the [SQL script][3] can be run directly via SQL\*Plus, which
1313
will always prompt for the names of the schemas that will be created. Run
1414
the script using the following command:
1515

16-
sqlplus sys/syspassword@hostname/servicename @sql/SetupTest.sql
16+
sqlplus system/systempassword@hostname/servicename @sql/SetupTest.sql
1717

1818
2. Run the test suite by issuing the following command in the top-level
1919
directory of your cx_Oracle installation:
2020

21-
python setup.py test
21+
tox
2222

2323
Alternatively, you can run the test suite directly within this directory:
2424

25-
python test.py
25+
python TestEnv.py
2626

2727
3. After running the test suite, the schemas can be dropped by running the
28-
Python script [DropTest.py][4]. The script requires SYSDBA privileges and
29-
will prompt for these credentials as well as the names of the schemas
30-
that will be dropped, unless a number of environment variables are set as
31-
documented in the Python script [TestEnv.py][2]. Run the script using the
32-
following command:
28+
Python script [DropTest.py][4]. The script requires administrative
29+
privileges and will prompt for these credentials as well as the names of the
30+
schemas that will be dropped, unless a number of environment variables are
31+
set as documented in the Python script [TestEnv.py][2]. Run the script using
32+
the following command:
3333

3434
python DropTest.py
3535

3636
Alternatively, the [SQL script][5] can be run directly via SQL\*Plus, which
3737
will always prompt for the names of the schemas that will be dropped. Run
3838
the script using the following command:
3939

40-
sqlplus sys/syspassword@hostname/servicename @sql/DropTest.sql
40+
sqlplus system/systempassword@hostname/servicename @sql/DropTest.sql
4141

4242
[1]: https://github.com/oracle/python-cx_Oracle/blob/master/test/SetupTest.py
4343
[2]: https://github.com/oracle/python-cx_Oracle/blob/master/test/TestEnv.py
4444
[3]: https://github.com/oracle/python-cx_Oracle/blob/master/test/sql/SetupTest.sql
4545
[4]: https://github.com/oracle/python-cx_Oracle/blob/master/test/DropTest.py
4646
[5]: https://github.com/oracle/python-cx_Oracle/blob/master/test/sql/DropTest.sql
47-

test/TestEnv.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
33
#
44
# Portions Copyright 2007-2015, Anthony Tuininga. All rights reserved.
55
#
@@ -146,6 +146,14 @@ def RunSqlScript(conn, scriptName, **kwargs):
146146
print(" %s/%s %s" % (lineNum, position, text))
147147

148148
def RunTestCases():
149+
print("Running tests for cx_Oracle version", cx_Oracle.version,
150+
"built at", cx_Oracle.buildtime)
151+
print("File:", cx_Oracle.__file__)
152+
print("Client Version:",
153+
".".join(str(i) for i in cx_Oracle.clientversion()))
154+
with GetConnection() as connection:
155+
print("Server Version:", connection.version)
156+
print()
149157
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
150158

151159
def GetConnection(**kwargs):
@@ -161,7 +169,32 @@ def GetPool(user=None, password=None, **kwargs):
161169
encoding="UTF-8", nencoding="UTF-8", **kwargs)
162170

163171
def GetClientVersion():
164-
return cx_Oracle.clientversion()
172+
name = "CLIENT_VERSION"
173+
value = PARAMETERS.get(name)
174+
if value is None:
175+
value = cx_Oracle.clientversion()[:2]
176+
PARAMETERS[name] = value
177+
return value
178+
179+
def GetServerVersion():
180+
name = "SERVER_VERSION"
181+
value = PARAMETERS.get(name)
182+
if value is None:
183+
conn = GetConnection()
184+
value = tuple(int(s) for s in conn.version.split("."))[:2]
185+
PARAMETERS[name] = value
186+
return value
187+
188+
def SkipSodaTests():
189+
client = GetClientVersion()
190+
if client < (18, 3):
191+
return True
192+
server = GetServerVersion()
193+
if server < (18, 0):
194+
return True
195+
if server > (20, 1) and client < (20, 1):
196+
return True
197+
return False
165198

166199
class RoundTripInfo:
167200

@@ -225,3 +258,9 @@ def tearDown(self):
225258
del self.cursor
226259
del self.connection
227260

261+
262+
def load_tests(loader, standard_tests, pattern):
263+
return loader.discover(os.path.dirname(__file__))
264+
265+
if __name__ == "__main__":
266+
RunTestCases()

test/test.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)