From accfd826c3f4e5ed5d865c780e169ee374842c4a Mon Sep 17 00:00:00 2001 From: richrines1 <85512171+richrines1@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:05:35 -0600 Subject: [PATCH] use empty package-dir in pyproject.toml (#715) fixes: #868 this appears to be a known issue stemming from the use of import hooks to comply with pep 660 - see for example https://github.com/python/mypy/issues/13392 and https://github.com/pypa/setuptools/issues/3518. What's happening is that for editable installs `setuptools` creates files like `.../site-packages/__editable__.general_superstaq-0.5.5.pth` which are supposed to point python to the source directory. Previously these would just be text files containing a single path, e.g. ``` /<...>/client-superstaq/general-superstaq ``` but after switching to pyproject.toml it becomes an executable hook, e.g. ```python import __editable___general_superstaq_0_5_5_finder; __editable___general_superstaq_0_5_5_finder.install() ``` where `__editable___general_superstaq_0_5_5_finder.py` is another file saved in the site-packages directory. this breaks static analysis tools because they won't execute the required code afaict this pr seems to be the cleanest workaround - after these changes setuptools seems to generate the old-style `.pth` files (i.e. text files containing paths to the source directories), and `mypy` behaves as expected (at least for me) --- cirq-superstaq/pyproject.toml | 3 +++ general-superstaq/pyproject.toml | 3 +++ qiskit-superstaq/pyproject.toml | 3 +++ supermarq-benchmarks/pyproject.toml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/cirq-superstaq/pyproject.toml b/cirq-superstaq/pyproject.toml index 3efc40e9b..ba2bb950b 100644 --- a/cirq-superstaq/pyproject.toml +++ b/cirq-superstaq/pyproject.toml @@ -19,6 +19,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] include = ["cirq_superstaq*"] +[tool.setuptools.package-dir] +"" = "." + [tool.setuptools.package-data] cirq_superstaq = ["py.typed"] diff --git a/general-superstaq/pyproject.toml b/general-superstaq/pyproject.toml index 4aa279031..fc685c09f 100644 --- a/general-superstaq/pyproject.toml +++ b/general-superstaq/pyproject.toml @@ -19,6 +19,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] include = ["general_superstaq*"] +[tool.setuptools.package-dir] +"" = "." + [tool.setuptools.package-data] general_superstaq = ["py.typed"] diff --git a/qiskit-superstaq/pyproject.toml b/qiskit-superstaq/pyproject.toml index 1d418a817..bed160557 100644 --- a/qiskit-superstaq/pyproject.toml +++ b/qiskit-superstaq/pyproject.toml @@ -19,6 +19,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] include = ["qiskit_superstaq*"] +[tool.setuptools.package-dir] +"" = "." + [tool.setuptools.package-data] qiskit_superstaq = ["py.typed"] diff --git a/supermarq-benchmarks/pyproject.toml b/supermarq-benchmarks/pyproject.toml index aea0fcdf8..0adaae45e 100644 --- a/supermarq-benchmarks/pyproject.toml +++ b/supermarq-benchmarks/pyproject.toml @@ -19,6 +19,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] include = ["supermarq*"] +[tool.setuptools.package-dir] +"" = "." + [tool.setuptools.package-data] supermarq = ["py.typed"]