diff --git a/setup.py b/setup.py index 8a5a3b1a..62110649 100644 --- a/setup.py +++ b/setup.py @@ -29,14 +29,25 @@ directory = os.path.abspath(os.path.dirname(__file__)) path = os.path.join(directory, "version.txt") -version_string = open(path).readline() +with open(path) as f: + version_string = f.readline() match = re.match(r"\s*(?P(?P\d+\.\d+)(?:\.\S+)*)\s*", version_string) version = match.group("ver") release = match.group("rel") +#--------------------------------------------------------------------------- +# Gather test requirements from the 'test_requirements.txt' file. +# This is to allow installing test requirements with the following command: +# pip install dragonfly[test]. + +def read(name): + with open(os.path.join(os.path.dirname(__file__), name)) as f: + return f.read() + +test_requirements = read("test_requirements.txt").split("\n")[:-1] + #--------------------------------------------------------------------------- # Override the 'test' command to use pytest instead. -# Test requirements are located in the 'test_requirements.txt' file. class test(Command): description = 'run unit tests and doctests after in-place build' @@ -97,14 +108,9 @@ def _try_local_natlink_pyd(self): # module to sys.modules. if natlink: sys.modules["natlink"] = natlink - #--------------------------------------------------------------------------- # Set up package. -def read(*names): - return open(os.path.join(os.path.dirname(__file__), *names)).read() - - setup( name = "dragonfly", version = release, @@ -140,10 +146,7 @@ def read(*names): ], extras_require={ - "test": [ - "pytest == 3.9.*;python_version<'3.8'", - "pytest == 7.4.*;python_version>='3.8'", - ], + "test": test_requirements, "accessibility": [ "comtypes;platform_system=='Windows'", "enum34;python_version<'3.4'", diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 00000000..556af5e6 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,2 @@ +pytest == 3.9.*;python_version<'3.8' +pytest == 7.4.*;python_version>='3.8'