@@ -15,6 +15,7 @@ def read(*parts):
1515 # intentionally *not* adding an encoding option to open
1616 return codecs .open (os .path .join (here , * parts ), 'r' ).read ()
1717
18+
1819def find_version (* file_paths ):
1920 version_file = read (* file_paths )
2021 version_match = re .search (r"^__version__ = ['\"]([^'\"]*)['\"]" ,
@@ -23,6 +24,17 @@ def find_version(*file_paths):
2324 return version_match .group (1 )
2425 raise RuntimeError ("Unable to find version string." )
2526
27+
28+ def parse_requirements (filename ):
29+ """
30+ 读取 requirements.txt
31+ """
32+ with open (os .path .join (here , filename ), 'r' , encoding = 'utf-8' ) as file_ :
33+ lines = map (lambda x : x .strip ('\n ' ), file_ .readlines ())
34+ lines = filter (lambda x : x and not x .startswith ('#' ) and not x .startswith ('-' ), lines )
35+ return list (lines )
36+
37+
2638class Tox (TestCommand ):
2739 def finalize_options (self ):
2840 TestCommand .finalize_options (self )
@@ -35,10 +47,12 @@ def run_tests(self):
3547 errcode = tox .cmdline (self .test_args )
3648 sys .exit (errcode )
3749
50+
3851# Get the long description from the README file
39- with open (os .path .join (here , "README.md" )) as in_file :
52+ with open (os .path .join (here , "README.md" ), 'r' ) as in_file :
4053 long_description = in_file .read ()
4154
55+
4256setup (
4357 name = "jserve" ,
4458 version = find_version ('jserve' , '__init__.py' ),
@@ -50,7 +64,10 @@ def run_tests(self):
5064 url = "https://github.com/jcppython/jserve-python" ,
5165 packages = ["jserve" ],
5266 python_requires = ">=3.6" ,
53- tests_require = ['tox' ],
67+ install_requires = parse_requirements ('requirements.txt' ),
68+ tests_require = (
69+ parse_requirements ('requirements.txt' ) +
70+ parse_requirements ('requirements-test.txt' )),
5471 cmdclass = {'test' : Tox },
5572 classifiers = [
5673 "Development Status :: 3 - Alpha" ,
0 commit comments