Skip to content

Commit

Permalink
Restore the test_requirements.txt file
Browse files Browse the repository at this point in the history
I have adjusted setup.py to read test requirements from this file
instead.
  • Loading branch information
drmfinlay committed May 2, 2024
1 parent f5633ad commit d0d4e44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 14 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<rel>(?P<ver>\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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'",
Expand Down
2 changes: 2 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest == 3.9.*;python_version<'3.8'
pytest == 7.4.*;python_version>='3.8'

0 comments on commit d0d4e44

Please sign in to comment.