Skip to content

Commit b773a9a

Browse files
committed
refactor: clean up setup.py
1 parent 894ba74 commit b773a9a

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

setup.py

+13-19
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,13 @@
22
import os
33
import sys
44

5-
from setuptools import Command, find_packages, setup
5+
from setuptools import find_packages, setup
66
from setuptools.command.install import install as InstallCommandBase
77
from setuptools.command.test import test as TestCommand
88
from setuptools.dist import Distribution
99
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommandBase
1010

1111

12-
class NoopCommand(Command):
13-
def initialize_options(self):
14-
pass
15-
16-
def finalize_options(self):
17-
pass
18-
19-
def run(self):
20-
pass
21-
22-
2312
class BasePytestCommand(TestCommand):
2413
user_options = []
2514
test_dir = None
@@ -39,7 +28,6 @@ def run_tests(self):
3928
if src_dir:
4029
src_dir += "/"
4130
args = [self.test_dir, "--cov=redshift_connector", "--cov-report=xml", "--cov-report=html"]
42-
print(args)
4331

4432
errno = pytest.main(args)
4533
sys.exit(errno)
@@ -78,6 +66,17 @@ def get_tag(self):
7866
return python, abi, plat
7967

8068

69+
custom_cmds = {
70+
"bdist_wheel": BDistWheelCommand,
71+
"unit_test": UnitTestCommand,
72+
"integration_test": IntegrationTestCommand,
73+
}
74+
75+
if os.getenv("CUSTOMINSTALL", False):
76+
custom_cmds["install"] = InstallCommand
77+
elif "install" in custom_cmds:
78+
del custom_cmds["install"]
79+
8180
# read the contents of your README file
8281
this_directory = os.path.abspath(os.path.dirname(__file__))
8382
with open(os.path.join(this_directory, "README.rst"), encoding="utf-8") as f:
@@ -121,10 +120,5 @@ def get_tag(self):
121120
include_package_data=True,
122121
package_data={"redshift-connector": ["*.py", "*.crt", "LICENSE", "NOTICE"]},
123122
packages=find_packages(exclude=["test*"]),
124-
cmdclass={
125-
"install": InstallCommand,
126-
"bdist_wheel": BDistWheelCommand,
127-
"unit_test": UnitTestCommand,
128-
"integration_test": IntegrationTestCommand,
129-
},
123+
cmdclass=custom_cmds,
130124
)

0 commit comments

Comments
 (0)