Skip to content

GitLab CI Dependency Scanning fails with numpy

Summary

When using Dependency Scanning template with python and the package numpy, it will exit with error code 1 due to ModuleNotFoundError: No module named 'Cython.

Steps to reproduce

Have numpy used in a python program.

Example Project

Example here

What is the current bug behavior?

When collecting numpy, which is a requirement of pandas, it will try and use cython which is not available.

What is the expected correct behavior?

It will not exit with code 1.

Relevant logs and/or screenshots

From build log

Collecting pandas
  Downloading https://files.pythonhosted.org/packages/b7/93/b544dd08092b457d88e10fc1e0989d9397fd32ca936fdfcbb2584178dd2b/pandas-0.25.3.tar.gz (12.6MB)
  Saved ./dist/pandas-0.25.3.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-download-bvjxd7wr/pandas/setup.py'"'"'; __file__='"'"'/tmp/pip-download-bvjxd7wr/pandas/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-download-bvjxd7wr/pandas/pip-egg-info
         cwd: /tmp/pip-download-bvjxd7wr/pandas/
    Complete output (101 lines):
    Processing numpy/random/_bounded_integers.pxd.in
    Processing numpy/random/_common.pyx
    Traceback (most recent call last):
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 61, in process_pyx
        from Cython.Compiler.Version import version as cython_version
    ModuleNotFoundError: No module named 'Cython'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 238, in <module>
        main()
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 234, in main
        find_process_files(root_dir)
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 225, in find_process_files
        process(root_dir, fromfile, tofile, function, hash_db)
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 191, in process
        processor_function(fromfile, tofile)
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/tools/cythonize.py", line 66, in process_pyx
        raise OSError('Cython needs to be installed in Python as a module')
    OSError: Cython needs to be installed in Python as a module
    Cythonizing sources
    Running from numpy source directory.
    /tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py:425: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 450, in <module>
    
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 433, in setup_package
        def finalize_options(self):
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 240, in generate_cython
        """Custom distutils command to clean the .so and .pyc files."""
    RuntimeError: Running cythonize failed!
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-download-bvjxd7wr/pandas/setup.py", line 840, in <module>
        **setuptools_kwargs
      File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 720, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 782, in resolve
        replace_conflicting=replace_conflicting
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1065, in best_match
        return self.obtain(req, installer)
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1077, in obtain
        return installer(requirement)
      File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 787, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 679, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 705, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1144, in run_setup
        run_setup(setup_script, args)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 253, in run_setup
        raise
      File "/usr/local/lib/python3.6/contextlib.py", line 99, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/local/lib/python3.6/contextlib.py", line 99, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/usr/local/lib/python3.6/site-packages/setuptools/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 450, in <module>
    
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 433, in setup_package
        def finalize_options(self):
      File "/tmp/easy_install-x482g_kz/numpy-1.18.0rc1/setup.py", line 240, in generate_cython
        """Custom distutils command to clean the .so and .pyc files."""
    RuntimeError: Running cythonize failed!
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
exit status 1

Output of checks

This bug happens on GitLab.com

Edited by Fabien Catteau