quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

mypy fails with error about duplicate module named "setup.py" #6687

Closed mhucka closed 3 months ago

mhucka commented 3 months ago

Description of the issue

After a fresh installation of either Cirq 1.4.1 or 1.5.0.dev, running the command

mypy --config-file=dev_tools/conf/mypy.ini .

as described in section "Continuous integration and local testing" in the dev docs leads to an error about 'Duplicate module named "setup"'.

How to reproduce the issue

Here I use Cirq 1.4.1 as an example, but the same error arises in 1.5.0.dev.

I installed Cirq 1.4.1 by cloning the main branch of the GitHub repo, then did the following to get the release tagged with 1.4.1 into a local branch:

git checkout v1.4.1 -b testing-1.4.1

Then I followed the instructions in "Setting up an environment", modifying them slightly for my MacOS 13.6.7 environment running Python version 3.10.10. I did the virtualenv installation,

mkvirtualenv cirq-py3
workon cirq-py3
pip install --upgrade pip    
pip install -r dev_tools/requirements/dev.env.txt

I ran ./check/pytest . to make sure things looked reasonable; this produced an error involving sympy (which I'm currently investigating) but no other errors, and IMHO, nothing that looked relevant to the particular mypy error being reported in this issue. Then did the following, per instructions:

source dev_tools/pypath

Then I tried running the 3 steps in the section "Continuous integration and local testing". The step for mypy produced the following output:

> mypy --config-file=dev_tools/conf/mypy.ini .
cirq-core/setup.py: error: Duplicate module named "setup" (also at "./cirq-aqt/setup.py")
cirq-core/setup.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info
cirq-core/setup.py: note: Common resolutions include: a) using `--exclude` to avoid checking one of them, b) adding `__init__.py` somewhere, c) using `--explicit-package-bases` or adjusting MYPYPATH
Found 1 error in 1 file (errors prevented further checking)

Cirq version

> pwd
/Users/mhucka/project-files/google/repos/cirq-testing/Cirq
> grep __version__ cirq-core/cirq/_version.py
__version__ = "1.4.1"
> python --version
Python 3.10.10
> mypy --version
mypy 1.2.0 (compiled: yes)
> sw_vers
ProductName:        macOS
ProductVersion:     13.6.7
BuildVersion:       22G720