Skip to content

Commit

Permalink
use empty package-dir in pyproject.toml (#715)
Browse files Browse the repository at this point in the history
fixes: #868

this appears to be a known issue stemming from the use of import hooks
to comply with pep 660 - see for example
python/mypy#13392 and
pypa/setuptools#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)
  • Loading branch information
richrines1 authored Jan 9, 2024
1 parent 8132cc0 commit accfd82
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cirq-superstaq/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
3 changes: 3 additions & 0 deletions general-superstaq/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
3 changes: 3 additions & 0 deletions qiskit-superstaq/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
3 changes: 3 additions & 0 deletions supermarq-benchmarks/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit accfd82

Please sign in to comment.