mottosso / Qt.py

Minimal Python 2 & 3 shim around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5.
MIT License
896 stars 252 forks source link

Cannot install v1.3.8 from sdist #390

Closed AWhetter closed 5 months ago

AWhetter commented 6 months ago

The sdist (the tarball uploaded to pypi) is missing the Qt-stubs directory. Therefore installing from the sdist fails with the following:

λ python3.9 -m venv venv
λ venv/bin/pip install --upgrade pip
...
λ venv/bin/pip install --no-binary=Qt.py Qt.py
Collecting Qt.py
  Using cached Qt.py-1.3.8.tar.gz (26 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      running egg_info
      writing Qt.py.egg-info/PKG-INFO
      writing dependency_links to Qt.py.egg-info/dependency_links.txt
      writing requirements to Qt.py.egg-info/requires.txt
      writing top-level names to Qt.py.egg-info/top_level.txt
      error: package directory 'Qt-stubs' does not exist
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I'm unsure how this happened. The README mentions that the sdist is built by running the setup.py, and the setup.py correctly includes the necessary files:

λ git checkout 1.3.8
λ python3.9 -m venv .venv
λ .venv/bin/python setup.py sdist
...
copying Qt-stubs/Qt.pyi -> Qt.py-1.3.8/Qt-stubs
...

Maybe an older version of setuptools was used in the release process than what I'm testing with. Running the setup.py directly is deprecated (https://packaging.python.org/en/latest/discussions/setup-py-deprecated/). Perhaps the release instructions need to be updated to mention running python -m build?

mottosso commented 6 months ago

If I remember correctly, an sdist generally does not include data files, as it is meant as a "source distribution". I think you need bdist for this, or a wheel.

AWhetter commented 5 months ago

Data files aren't generated at build time, and are therefore considered a source file. It's difficult to find a single place as a source for this but data files are included by source distributions by setuptools (https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html#controlling-files-in-the-distribution) and flit (https://flit.pypa.io/en/latest/rationale.html?highlight=data%20files#why-use-flit "Data files within a package directory are automatically included. Missing data files has been a common packaging mistake with other tools.").

In addition, the pip documentation describes installing from source distributions as a valid workflow: https://packaging.python.org/en/latest/tutorials/installing-packages/#source-distributions-vs-wheels

mottosso commented 5 months ago

Maybe an older version of setuptools was used in the release process than what I'm testing with.

Ah, then this is possible. At best, it was distributed by pip from February 2023 (the date of the last release) but more likely a number of months if not years before that since it happens from one of my personal machines and I can't remember the last time I updated pip

If you make an sdist using that same setup.py, can you confirm that the generated file contains the files you expect?

AWhetter commented 5 months ago

In the example at the end of the issue description I was using setuptools v58.1.0 and that worked. If I'm using the latest and greatest everything then it also works:

λ python --version
Python 3.11.6
λ python -m venv .venv
λ .venv/bin/pip install --upgrade pip
...
Successfully installed pip-23.3.2
λ .venv/bin/pip install build
...
Successfully installed build-1.0.3 packaging-23.2 pyproject_hooks-1.0.0
λ .venv/bin/python -m build
...
copying Qt-stubs/Qt.pyi -> Qt.py-1.3.8/Qt-stubs
...
λ tar tvf dist/Qt.py-1.3.8.tar.gz
...
-rw-r--r-- ashley/ashley   512 2024-01-21 21:34 Qt.py-1.3.8/Qt-stubs/Qt.pyi
...

So the setup.py appears to be correct.

mottosso commented 5 months ago

I've pushed an unchanged 1.3.9 using the latest version of pip and Python 3.11.4 now, hopefully that settles it, let me know.

AWhetter commented 5 months ago

I've used 1.3.10 and it works great. Thank you!