Repository: numba/numba

Issue:
Installating dependencies with `python setup.py install` raises SyntaxError
From [our CI logs at `clifford`](https://dev.azure.com/hadfieldhugo/clifford/_build/results?buildId=860&view=logs&j=20371dfd-8a56-50ce-58d3-e9a0ee10bdaf&t=ad1eeb00-51f4-552d-0963-a34fcfebd808), where we run `python setup.py install`:

```
##[section]Starting: Install package windows
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.164.2
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\9449467f-87fd-4517-b49f-6b9b0ca2a0b7.cmd""


< a bunch of uninteresting stuff about building an egg for clifford itself >

Processing clifford-1.4.0.dev0-py3.5.egg
creating c:\miniconda\envs\myenvironment\lib\site-packages\clifford-1.4.0.dev0-py3.5.egg
Extracting clifford-1.4.0.dev0-py3.5.egg to c:\miniconda\envs\myenvironment\lib\site-packages
Adding clifford 1.4.0.dev0 to easy-install.pth file

Installed c:\miniconda\envs\myenvironment\lib\site-packages\clifford-1.4.0.dev0-py3.5.egg
Processing dependencies for clifford==1.4.0.dev0
Searching for sparse
Reading https://pypi.org/simple/sparse/
Downloading https://files.pythonhosted.org/packages/3a/25/562a0cebb6fc36f16989469350ac96e9dbe2cc11dba0c22c34d0eff2f5dd/sparse-0.10.0-py2.py3-none-any.whl#sha256=7b838e2709765a2476f7cfbce1b0d00678061199e9b211a180ff3f7a2961a76b
Best match: sparse 0.10.0
Processing sparse-0.10.0-py2.py3-none-any.whl
Installing sparse-0.10.0-py2.py3-none-any.whl to c:\miniconda\envs\myenvironment\lib\site-packages
writing requirements to c:\miniconda\envs\myenvironment\lib\site-packages\sparse-0.10.0-py3.5.egg\EGG-INFO\requires.txt
Adding sparse 0.10.0 to easy-install.pth file

Installed c:\miniconda\envs\myenvironment\lib\site-packages\sparse-0.10.0-py3.5.egg
Searching for numba>0.46
Reading https://pypi.org/simple/numba/
Downloading https://files.pythonhosted.org/packages/18/0a/975f110caed972e27e9bd8c4abc094867496bb308dad09496510e1df5e2d/numba-0.50.0rc1.tar.gz#sha256=9a83cb5f911f8b6e2fc03cefe2a9a971dad3c90322888b4b0f73b14aace046c4
Best match: numba 0.50.0rc1
Processing numba-0.50.0rc1.tar.gz
Writing C:\Users\VSSADM~1\AppData\Local\Temp\easy_install-axh8gze7\numba-0.50.0rc1\setup.cfg
Running numba-0.50.0rc1\setup.py -q bdist_egg --dist-dir C:\Users\VSSADM~1\AppData\Local\Temp\easy_install-axh8gze7\numba-0.50.0rc1\egg-dist-tmp-o3jyddbk
Traceback (most recent call last):
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
    yield saved
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 44, in _execfile
    code = compile(script, filename, 'exec')
  File "C:\Users\VSSADM~1\AppData\Local\Temp\easy_install-axh8gze7\numba-0.50.0rc1\setup.py", line 305
    build_requires = [f'numpy >={min_numpy_build_version}']
                                                         ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 50, in <module>
    python_requires='>=3.5',
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\__init__.py", line 140, in setup
    return distutils.core.setup(**attrs)
  File "C:\Miniconda\envs\myEnvironment\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Miniconda\envs\myEnvironment\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Miniconda\envs\myEnvironment\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\install.py", line 67, in run
    self.do_egg_install()
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\install.py", line 117, in do_egg_install
    cmd.run()
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 415, in run
    self.easy_install(spec, not self.no_deps)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 657, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 704, in install_item
    self.process_distribution(spec, dist, deps)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 749, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\pkg_resources\__init__.py", line 777, in resolve
    replace_conflicting=replace_conflicting
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\pkg_resources\__init__.py", line 1060, in best_match
    return self.obtain(req, installer)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\pkg_resources\__init__.py", line 1072, in obtain
    return installer(requirement)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 676, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 702, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 887, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 1155, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\command\easy_install.py", line 1141, in run_setup
    run_setup(setup_script, args)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
    raise
  File "C:\Miniconda\envs\myEnvironment\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "C:\Miniconda\envs\myEnvironment\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
    saved_exc.resume()
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 141, in resume
    six.reraise(type, exc, self._tb)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\_vendor\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
    yield saved
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
    yield
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "C:\Miniconda\envs\myEnvironment\lib\site-packages\setuptools\sandbox.py", line 44, in _execfile
    code = compile(script, filename, 'exec')
  File "C:\Users\VSSADM~1\AppData\Local\Temp\easy_install-axh8gze7\numba-0.50.0rc1\setup.py", line 305
    build_requires = [f'numpy >={min_numpy_build_version}']
                                                         ^
SyntaxError: invalid syntax
##[error]Cmd.exe exited with code '1'.
##[section]Finishing: Install package windows
```

Unfortunately, `python_requires >= 3.6` does not work if the file containing it cannot be read by python 3,5




Discussion:
xref numpy/numpy#16345 where we made this mistake in numpy.
Thanks for the report. IIRC they were put in to make it impossible to install Numba with an unsupported python. However, as demonstrated, this is a problem, the unsupported syntax in use means the user doesn't get an informative error message. Should just fix this cf. NumPy.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -298,10 +298,10 @@ def check_file_at_path(path2file):
 
 packages = find_packages(include=["numba", "numba.*"])
 
-build_requires = [f'numpy >={min_numpy_build_version}']
+build_requires = ['numpy >={}'.format(min_numpy_build_version)]
 install_requires = [
-    f'llvmlite >={min_llvmlite_version},<{max_llvmlite_version}',
-    f'numpy >={min_numpy_run_version}',
+    'llvmlite >={},<{}'.format(min_llvmlite_version, max_llvmlite_version),
+    'numpy >={}'.format(min_numpy_run_version),
     'setuptools',
 ]
 
@@ -342,7 +342,7 @@ def check_file_at_path(path2file):
     packages=packages,
     setup_requires=build_requires,
     install_requires=install_requires,
-    python_requires=f">={min_python_version}",
+    python_requires=">={}".format(min_python_version),
     license="BSD",
     cmdclass=cmdclass,
 )


Test patch: