diff --git a/taxcalc.egg-info/PKG-INFO b/taxcalc.egg-info/PKG-INFO index b93fe2de9..8667eb489 100644 --- a/taxcalc.egg-info/PKG-INFO +++ b/taxcalc.egg-info/PKG-INFO @@ -18,13 +18,6 @@ Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown License-File: LICENSE -Requires-Dist: setuptools -Requires-Dist: numpy -Requires-Dist: pandas -Requires-Dist: bokeh -Requires-Dist: numba -Requires-Dist: requests -Requires-Dist: paramtools>=0.18.3 | | | | --- | --- | diff --git a/taxcalc/__init__.py b/taxcalc/__init__.py index 044f29d19..2d4875ac2 100644 --- a/taxcalc/__init__.py +++ b/taxcalc/__init__.py @@ -15,3 +15,5 @@ from taxcalc.cli import * __version__ = '4.3.0' +__min_python3_version__ = 10 +__max_python3_version__ = 12 diff --git a/taxcalc/cli/tc.py b/taxcalc/cli/tc.py index af8ca3a0a..f27fc3c40 100644 --- a/taxcalc/cli/tc.py +++ b/taxcalc/cli/tc.py @@ -138,11 +138,23 @@ def cli_tc_main(): default=False, action="store_true") args = parser.parse_args() - # show Tax-Calculator version and quit if --version option specified + # check Python version + pyv = sys.version_info + pymin = tc.__min_python3_version__ + pymax = tc.__max_python3_version__ + if pyv[0] != 3 or pyv[1] < pymin or pyv[1] > pymax: # pragma: no cover + pyreq = f'at least Python 3.{pymin} and at most Python 3.{pymax}' + sys.stderr.write( + f'ERROR: Tax-Calculator requires {pyreq}\n' + f' but Python {pyv[0]}.{pyv[1]} is installed\n' + ) + return 1 + # show Tax-Calculator version and quit if --version option is specified if args.version: - sys.stdout.write('Tax-Calculator {}\n'.format(tc.__version__)) + pyver = f'Python 3.{pyv[1]}' + sys.stdout.write(f'Tax-Calculator {tc.__version__} on {pyver}\n') return 0 - # write test input and expected output files if --test option specified + # write test input and expected output files if --test option is specified if args.test: _write_expected_test_output() inputfn = TEST_INPUT_FILENAME @@ -181,7 +193,7 @@ def cli_tc_main(): dumpvar_set = None if args.dvars and (args.dump or args.sqldb): if os.path.exists(args.dvars): - with open(args.dvars) as dfile: + with open(args.dvars, 'r', encoding='utf-8') as dfile: dump_vars_str = dfile.read() dumpvar_set = tcio.custom_dump_variables(dump_vars_str) if tcio.errmsg: @@ -213,8 +225,8 @@ def cli_tc_main(): # end of cli_tc_main function code -EXPECTED_TEST_OUTPUT_FILENAME = 'test-{}-out.csv'.format(str(TEST_TAXYEAR)[2:]) -ACTUAL_TEST_OUTPUT_FILENAME = 'test-{}-#-#-#.csv'.format(str(TEST_TAXYEAR)[2:]) +EXPECTED_TEST_OUTPUT_FILENAME = f'test-{str(TEST_TAXYEAR)[2:]}-out.csv' +ACTUAL_TEST_OUTPUT_FILENAME = f'test-{str(TEST_TAXYEAR)[2:]}-#-#-#.csv' def _write_expected_test_output(): @@ -226,14 +238,14 @@ def _write_expected_test_output(): '1, 2, 3, 1, 40000, 40000, 0, 0, 3000, 4000\n' '2, 2, 3, 1,200000, 200000, 0, 0, 15000, 20000\n' ) - with open(TEST_INPUT_FILENAME, 'w') as ifile: + with open(TEST_INPUT_FILENAME, 'w', encoding='utf-8') as ifile: ifile.write(input_data) expected_output_data = ( 'RECID,YEAR,WEIGHT,INCTAX,LSTAX,PAYTAX\n' '1,2018,0.00,131.88,0.00,6120.00\n' '2,2018,0.00,28879.00,0.00,21721.60\n' ) - with open(EXPECTED_TEST_OUTPUT_FILENAME, 'w') as ofile: + with open(EXPECTED_TEST_OUTPUT_FILENAME, 'w', encoding='utf-8') as ofile: ofile.write(expected_output_data) @@ -242,8 +254,12 @@ def _compare_test_output_files(): Private function that compares expected and actual tc --test output files; returns 0 if pass test, otherwise returns 1. """ - explines = open(EXPECTED_TEST_OUTPUT_FILENAME, 'r').readlines() - actlines = open(ACTUAL_TEST_OUTPUT_FILENAME, 'r').readlines() + explines = open( + EXPECTED_TEST_OUTPUT_FILENAME, 'r', encoding='utf-8' + ).readlines() + actlines = open( + ACTUAL_TEST_OUTPUT_FILENAME, 'r', encoding='utf-8' + ).readlines() if ''.join(explines) == ''.join(actlines): sys.stdout.write('PASSED TEST\n') retcode = 0