dlenski / python-zxing

python wrapper for the ZXing barcode library
GNU Lesser General Public License v3.0
121 stars 36 forks source link

Cannot install from tarball #10

Closed vladvrabie closed 3 years ago

vladvrabie commented 3 years ago

I tried installing the package using PEP 508 direct reference specifications in my setup.py:

install_requires=[ 'zxing @ [git+]https://github.com/dlenski/python-zxing/tarball/master', ]

and I get 2 exceptions:

subprocess.CalledProcessError: Command '['git', 'describe', '--tags', '--dirty=_dirty']' returned non-zero exit status 128.

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-sjxlzlyf\\zxing\\zxing\\version.py'

The problem is here: https://github.com/dlenski/python-zxing/blob/5bc2e3f86c4391575e042011d8fdbbc93164e819/setup.py#L23-L35

The try fails because the tarball does not contain a .git folder. So in the exception you assume there is a local zxing/version.py file to read, but there isn't (because you have it in the .gitignore).

Possible solution: check if the file zxing/version.py exists or not

dlenski commented 3 years ago

Thanks for the report. :+1:

So in the exception you assume there is a local zxing/version.py file to read, but there isn't (because you have it in the .gitignore).

Possible solution: check if the file zxing/version.py exists or not

Yeah, basically there is a chicken-and-egg problem here due to the fact that the version.py can't be updated with the latest commit ID because the commit ID isn't known until it's committed. :man_facepalming:

I've removed this mechanism from most of my other Python packages and should just do so here too.