#!/usr/bin/env python

import glob
import os
from setuptools import setup, find_packages
import sys

source_root = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(source_root, 'install'))

import cupy_builder  # NOQA
from cupy_builder import cupy_setup_build  # NOQA

ctx = cupy_builder.Context(source_root)
cupy_builder.initialize(ctx)
if not cupy_builder.preflight_check(ctx):
    sys.exit(1)


# TODO(kmaehashi): migrate to pyproject.toml (see #4727, #4619)
setup_requires = [
    'Cython>=0.29.22,<3',
    'fastrlock>=0.5',
]
install_requires = [
    'numpy>=1.17,<1.24',  # see #4773
    'fastrlock>=0.5',
]
extras_require = {
    'all': [
        'scipy>=1.4,<1.10',  # see #4773
        'Cython>=0.29.22,<3',
        'optuna>=2.0',
    ],
    'stylecheck': [
        'autopep8==1.5.5',
        'flake8==3.8.4',
        'pbr==5.5.1',
        'pycodestyle==2.6.0',
    ],
    'test': [
        # 4.2 <= pytest < 6.2 is slow collecting tests and times out on CI.
        'pytest>=6.2',
    ],
    # TODO(kmaehashi): Remove 'jenkins' requirements.
    'jenkins': [
        'pytest>=6.2',
        'pytest-timeout',
        'pytest-cov',
        'coveralls',
        'codecov',
        'coverage<5',  # Otherwise, Python must be built with sqlite
    ],
}
tests_require = extras_require['test']


# List of files that needs to be in the distribution (sdist/wheel).
# Notes:
# - Files only needed in sdist should be added to `MANIFEST.in`.
# - The following glob (`**`) ignores items starting with `.`.
cupy_package_data = [
    'cupy/cuda/cupy_thrust.cu',
    'cupy/cuda/cupy_cub.cu',
    'cupy/cuda/cupy_cufftXt.cu',  # for cuFFT callback
    'cupy/cuda/cupy_cufftXt.h',  # for cuFFT callback
    'cupy/cuda/cupy_cufft.h',  # for cuFFT callback
    'cupy/cuda/cufft.pxd',  # for cuFFT callback
    'cupy/cuda/cufft.pyx',  # for cuFFT callback
    'cupy/random/cupy_distributions.cu',
    'cupy/random/cupy_distributions.cuh',
] + [
    x for x in glob.glob('cupy/_core/include/cupy/**', recursive=True)
    if os.path.isfile(x)
]

package_data = {
    'cupy': [
        os.path.relpath(x, 'cupy') for x in cupy_package_data
    ],
}

package_data['cupy'] += cupy_setup_build.prepare_wheel_libs(ctx)

ext_modules = cupy_setup_build.get_ext_modules(False, ctx)
build_ext = cupy_setup_build.custom_build_ext

# Get __version__ variable
with open(os.path.join(source_root, 'cupy', '_version.py')) as f:
    exec(f.read())

long_description = None
if ctx.long_description_path is not None:
    with open(ctx.long_description_path) as f:
        long_description = f.read()


CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Intended Audience :: Science/Research
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3 :: Only
Programming Language :: Cython
Topic :: Software Development
Topic :: Scientific/Engineering
Operating System :: POSIX
Operating System :: Microsoft :: Windows
"""


setup(
    name=ctx.package_name,
    version=__version__,  # NOQA
    description='CuPy: NumPy & SciPy for GPU',
    long_description=long_description,
    author='Seiya Tokui',
    author_email='tokui@preferred.jp',
    maintainer='CuPy Developers',
    url='https://cupy.dev/',
    license='MIT License',
    project_urls={
        "Bug Tracker": "https://github.com/cupy/cupy/issues",
        "Documentation": "https://docs.cupy.dev/",
        "Source Code": "https://github.com/cupy/cupy",
    },
    classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
    packages=find_packages(exclude=['install', 'tests']),
    package_data=package_data,
    zip_safe=False,
    python_requires='>=3.7',
    setup_requires=setup_requires,
    install_requires=install_requires,
    tests_require=tests_require,
    extras_require=extras_require,
    ext_modules=ext_modules,
    cmdclass={'build_ext': build_ext},
)

setup.py
#!/usr/bin/env python

import glob
import os
from setuptools import setup, find_packages
import sys

source_root = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(source_root, 'install'))

import cupy_builder  # NOQA
from cupy_builder import cupy_setup_build  # NOQA

ctx = cupy_builder.Context(source_root)
cupy_builder.initialize(ctx)
if not cupy_builder.preflight_check(ctx):
    sys.exit(1)


# TODO(kmaehashi): migrate to pyproject.toml (see #4727, #4619)
setup_requires = [
    'Cython>=0.29.22,<3',
    'fastrlock>=0.5',
]
install_requires = [
    'numpy>=1.18,<1.24',  # see #4773
    'fastrlock>=0.5',
]
extras_require = {
    'all': [
        'scipy>=1.4,<1.10',  # see #4773
        'Cython>=0.29.22,<3',
        'optuna>=2.0',
    ],
    'stylecheck': [
        'autopep8==1.5.5',
        'flake8==3.8.4',
        'pbr==5.5.1',
        'pycodestyle==2.6.0',
    ],
    'test': [
        # 4.2 <= pytest < 6.2 is slow collecting tests and times out on CI.
        'pytest>=6.2',
    ],
    # TODO(kmaehashi): Remove 'jenkins' requirements.
    'jenkins': [
        'pytest>=6.2',
        'pytest-timeout',
        'pytest-cov',
        'coveralls',
        'codecov',
        'coverage<5',  # Otherwise, Python must be built with sqlite
    ],
}
tests_require = extras_require['test']


# List of files that needs to be in the distribution (sdist/wheel).
# Notes:
# - Files only needed in sdist should be added to `MANIFEST.in`.
# - The following glob (`**`) ignores items starting with `.`.
cupy_package_data = [
    'cupy/cuda/cupy_thrust.cu',
    'cupy/cuda/cupy_cub.cu',
    'cupy/cuda/cupy_cufftXt.cu',  # for cuFFT callback
    'cupy/cuda/cupy_cufftXt.h',  # for cuFFT callback
    'cupy/cuda/cupy_cufft.h',  # for cuFFT callback
    'cupy/cuda/cufft.pxd',  # for cuFFT callback
    'cupy/cuda/cufft.pyx',  # for cuFFT callback
    'cupy/random/cupy_distributions.cu',
    'cupy/random/cupy_distributions.cuh',
] + [
    x for x in glob.glob('cupy/_core/include/cupy/**', recursive=True)
    if os.path.isfile(x)
]

package_data = {
    'cupy': [
        os.path.relpath(x, 'cupy') for x in cupy_package_data
    ],
}

package_data['cupy'] += cupy_setup_build.prepare_wheel_libs(ctx)

ext_modules = cupy_setup_build.get_ext_modules(False, ctx)
build_ext = cupy_setup_build.custom_build_ext

# Get __version__ variable
with open(os.path.join(source_root, 'cupy', '_version.py')) as f:
    exec(f.read())

long_description = None
if ctx.long_description_path is not None:
    with open(ctx.long_description_path) as f:
        long_description = f.read()


CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Intended Audience :: Science/Research
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3 :: Only
Programming Language :: Cython
Topic :: Software Development
Topic :: Scientific/Engineering
Operating System :: POSIX
Operating System :: Microsoft :: Windows
"""


setup(
    name=ctx.package_name,
    version=__version__,  # NOQA
    description='CuPy: NumPy & SciPy for GPU',
    long_description=long_description,
    author='Seiya Tokui',
    author_email='tokui@preferred.jp',
    maintainer='CuPy Developers',
    url='https://cupy.dev/',
    license='MIT License',
    project_urls={
        "Bug Tracker": "https://github.com/cupy/cupy/issues",
        "Documentation": "https://docs.cupy.dev/",
        "Source Code": "https://github.com/cupy/cupy",
    },
    classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
    packages=find_packages(exclude=['install', 'tests']),
    package_data=package_data,
    zip_safe=False,
    python_requires='>=3.7',
    setup_requires=setup_requires,
    install_requires=install_requires,
    tests_require=tests_require,
    extras_require=extras_require,
    ext_modules=ext_modules,
    cmdclass={'build_ext': build_ext},
)

setup.py
diff --git a/.pfnci/coverage.md b/.pfnci/coverage.md
index d7a86b2efbf..5e3a9ac3211 100644
--- a/.pfnci/coverage.md
+++ b/.pfnci/coverage.md
@@ -45,8 +45,7 @@
 |                       | 3.8          |                             |                             |                             |                             | ✅                           |                             |                              | ✅                            |                              |                               |                                     |                                     |                                  | 2   |
 |                       | 3.9          |                             | ✅                           |                             |                             |                             | ✅                           |                              |                              | ✅                            | ✅                             | ✅                                   |                                     | ✅                                | 6   |
 |                       | pre          |                             |                             |                             |                             |                             |                             |                              |                              |                              |                               |                                     |                                     |                                  | 0 🚨 |
-| numpy                 | 1.17         | ✅                           |                             |                             | ✅                           |                             |                             | ✅                            |                              |                              |                               |                                     |                                     |                                  | 3   |
-|                       | 1.18         |                             |                             |                             |                             | ✅                           |                             |                              |                              |                              |                               |                                     |                                     |                                  | 1   |
+| numpy                 | 1.18         | ✅                           |                             |                             | ✅                           | ✅                           |                             | ✅                            |                              |                              |                               |                                     |                                     |                                  | 4   |
 |                       | 1.19         |                             |                             | ✅                           |                             |                             |                             |                              |                              |                              |                               |                                     |                                     |                                  | 1   |
 |                       | 1.20         |                             | ✅                           |                             |                             |                             |                             |                              | ✅                            |                              |                               |                                     | ✅                                   |                                  | 3   |
 |                       | 1.21         |                             |                             |                             |                             |                             | ✅                           |                              |                              | ✅                            | ✅                             | ✅                                   |                                     |                                  | 4   |
diff --git a/.pfnci/linux/tests/cuda102.Dockerfile b/.pfnci/linux/tests/cuda102.Dockerfile
index c7151c04dac..2ba29c36e1f 100644
--- a/.pfnci/linux/tests/cuda102.Dockerfile
+++ b/.pfnci/linux/tests/cuda102.Dockerfile
@@ -23,4 +23,4 @@ RUN pyenv install 3.7.11 && \
     pyenv global 3.7.11 && \
     pip install -U setuptools pip
 
-RUN pip install -U numpy==1.17.* scipy==1.4.* optuna==2.* cython==0.29.*
+RUN pip install -U numpy==1.18.* scipy==1.4.* optuna==2.* cython==0.29.*
diff --git a/.pfnci/linux/tests/cuda112.Dockerfile b/.pfnci/linux/tests/cuda112.Dockerfile
index 39207ea2dd9..62b24687a2e 100644
--- a/.pfnci/linux/tests/cuda112.Dockerfile
+++ b/.pfnci/linux/tests/cuda112.Dockerfile
@@ -19,4 +19,4 @@ RUN pyenv install 3.7.11 && \
     pyenv global 3.7.11 && \
     pip install -U setuptools pip
 
-RUN pip install -U numpy==1.17.* scipy==1.5.* optuna==2.* cython==0.29.*
+RUN pip install -U numpy==1.18.* scipy==1.5.* optuna==2.* cython==0.29.*
diff --git a/.pfnci/linux/tests/rocm-4-0.Dockerfile b/.pfnci/linux/tests/rocm-4-0.Dockerfile
index 22b3fb1c7b3..d416a9e2a0c 100644
--- a/.pfnci/linux/tests/rocm-4-0.Dockerfile
+++ b/.pfnci/linux/tests/rocm-4-0.Dockerfile
@@ -32,4 +32,4 @@ RUN pyenv install 3.7.11 && \
     pyenv global 3.7.11 && \
     pip install -U setuptools pip
 
-RUN pip install -U numpy==1.17.* scipy==1.4.* optuna==2.* cython==0.29.*
+RUN pip install -U numpy==1.18.* scipy==1.4.* optuna==2.* cython==0.29.*
diff --git a/.pfnci/matrix.yaml b/.pfnci/matrix.yaml
index 08d74cba0c8..5853e806d14 100644
--- a/.pfnci/matrix.yaml
+++ b/.pfnci/matrix.yaml
@@ -15,7 +15,7 @@
   cusparselt: null
   cudnn: "7.6"
   python: "3.7"
-  numpy: "1.17"
+  numpy: "1.18"
   scipy: "1.4"
   optuna: "2"
   cython: "0.29"
@@ -72,7 +72,7 @@
   cusparselt: "0.1.0"
   cudnn: "8.1"
   python: "3.7"
-  numpy: "1.17"
+  numpy: "1.18"
   scipy: "1.5"
   optuna: "2"
   cython: "0.29"
@@ -141,7 +141,7 @@
   cusparselt: null
   cudnn: null
   python: "3.7"
-  numpy: "1.17"
+  numpy: "1.18"
   scipy: "1.4"
   optuna: "2"
   cython: "0.29"
diff --git a/.pfnci/schema.yaml b/.pfnci/schema.yaml
index f7d39cf1070..fec616d3b89 100644
--- a/.pfnci/schema.yaml
+++ b/.pfnci/schema.yaml
@@ -210,13 +210,6 @@ python:
 # When adding a new NumPy version, you may also need to add the version to the
 # list of supported Python versions in SciPy.
 numpy:
-  "1.17":
-    spec: "==1.17.*"
-    python:
-      # - "3.5"
-      # - "3.6"
-      - "3.7"
-      - "3.8"
   "1.18":
     spec: "==1.18.*"
     python:
@@ -260,7 +253,7 @@ scipy:
       # - "1.14"
       # - "1.15"
       # - "1.16"
-      - "1.17"
+      # - "1.17"
       - "1.18"
       - "1.19"
       - "1.20"
@@ -274,7 +267,7 @@ scipy:
       - "3.9"
     numpy:
       # - "1.16"
-      - "1.17"
+      # - "1.17"
       - "1.18"
       - "1.19"
       - "1.20"
@@ -287,7 +280,7 @@ scipy:
       - "3.9"
     numpy:
       # - "1.16"
-      - "1.17"
+      # - "1.17"
       - "1.18"
       - "1.19"
       - "1.20"
@@ -300,7 +293,7 @@ scipy:
       - "3.9"
     numpy:
       # - "1.16"
-      - "1.17"
+      # - "1.17"
       - "1.18"
       - "1.19"
       - "1.20"
diff --git a/docs/source/install.rst b/docs/source/install.rst
index 04aec2d17a5..db6fc2fd5f6 100644
--- a/docs/source/install.rst
+++ b/docs/source/install.rst
@@ -25,7 +25,7 @@ Python Dependencies
 
 NumPy/SciPy-compatible API in CuPy v10 is based on NumPy 1.21 and SciPy 1.7, and has been tested against the following versions:
 
-* `NumPy <https://numpy.org/>`_: v1.17 / v1.18 / v1.19 / v1.20 / v1.21
+* `NumPy <https://numpy.org/>`_: v1.18 / v1.19 / v1.20 / v1.21
 
 * `SciPy <https://scipy.org/>`_ (*optional*): v1.4 / v1.5 / v1.6 / v1.7
 
diff --git a/setup.py b/setup.py
index e46e27bb17b..c1d81e157eb 100644
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@
     'fastrlock>=0.5',
 ]
 install_requires = [
-    'numpy>=1.17,<1.24',  # see #4773
+    'numpy>=1.18,<1.24',  # see #4773
     'fastrlock>=0.5',
 ]
 extras_require = {

Drop support for NumPy 1.17 in v10 (NEP 29)
CuPy should drop support for these legacy versions, following [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html#support-table).
