mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-01-27 10:20:10 +00:00
Don't rely on deprecated flake8 setuptools entrypoint (#1557)
Define and use own command class for that
This commit is contained in:
committed by
GitHub
parent
6e4ca1717c
commit
76cfcf3ae8
51
setup.py
51
setup.py
@@ -55,6 +55,55 @@ CONSOLE_SCRIPTS = ['patroni = patroni:main',
|
||||
"patroni_aws = patroni.scripts.aws:main"]
|
||||
|
||||
|
||||
class Flake8(Command):
|
||||
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
from flake8.main import application
|
||||
|
||||
self.flake8 = application.Application()
|
||||
self.flake8.initialize([])
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def package_files(self):
|
||||
seen_package_directories = ()
|
||||
directories = self.distribution.package_dir or {}
|
||||
empty_directory_exists = "" in directories
|
||||
packages = self.distribution.packages or []
|
||||
for package in packages:
|
||||
if package in directories:
|
||||
package_directory = directories[package]
|
||||
elif empty_directory_exists:
|
||||
package_directory = os.path.join(directories[""], package)
|
||||
else:
|
||||
package_directory = package
|
||||
|
||||
if not package_directory.startswith(seen_package_directories):
|
||||
seen_package_directories += (package_directory + ".",)
|
||||
yield package_directory
|
||||
|
||||
def targets(self):
|
||||
return [package for package in self.package_files()] + ['tests', 'setup.py']
|
||||
|
||||
def run(self):
|
||||
self.flake8.run_checks(self.targets())
|
||||
self.flake8.formatter.start()
|
||||
self.flake8.report_errors()
|
||||
self.flake8.report_statistics()
|
||||
self.flake8.report_benchmarks()
|
||||
self.flake8.formatter.stop()
|
||||
try:
|
||||
self.flake8.exit()
|
||||
except SystemExit as e:
|
||||
# Cause system exit only if exit code is not zero (terminates
|
||||
# other possibly remaining/pending setuptools commands).
|
||||
if e.code:
|
||||
raise
|
||||
|
||||
|
||||
class PyTest(Command):
|
||||
|
||||
user_options = [('cov=', None, 'Run coverage'), ('cov-xml=', None, 'Generate junit xml report'),
|
||||
@@ -106,7 +155,7 @@ def read(fname):
|
||||
|
||||
def setup_package(version):
|
||||
# Assemble additional setup commands
|
||||
cmdclass = {'test': PyTest}
|
||||
cmdclass = {'test': PyTest, 'flake8': Flake8}
|
||||
|
||||
install_requires = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user