effigies / looseversion

A backwards/forwards-compatible fork of distutils.version.LooseVersion
Other
13 stars 1 forks source link

installing looseversion v1.0.1 from PyPI source tarball doesn't work as expected #7

Closed boegel closed 1 year ago

boegel commented 1 year ago

I'm seeing a weird problem when I'm installing from the source tarball obtained from PyPI: it's not actually being installed?

The output below is from macOS 12.6, but I'm also seeing this on a Red Hat Enterprise Linux 8 system using Python 3.9.5 + pip 21.1.1.

$  python -V
Python 3.9.6

$ pip --version
pip 21.2.4 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)

$ curl -OL https://files.pythonhosted.org/packages/5e/f3/17b292003f739362d025cc4b659a604464920cf94714d28c22aa481f5f0c/looseversion-1.0.1.tar.gz
$ tar xfvz looseversion-1.0.1.tar.gz
$ cd looseversion-1.0.1

$ pip install --prefix /tmp/$USER/looseversion .
...
Successfully built looseversion
Installing collected packages: looseversion
Successfully installed looseversion-1.0.1

$ ls /tmp/$USER/looseversion/lib/python3.9/site-packages
looseversion-1.0.1.dist-info

$ cd $HOME
$ PYTHONPATH=/tmp/$USER/looseversion/lib/python3.9/site-packages python -c 'from looseversion import LooseVersion'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'looseversion'

Any idea why only a looseversion-1.0.1.dist-info directory is being installed (which only contains metadata), and why looseversion.py is not being actually installed?

effigies commented 1 year ago

I don't know. Does upgrading pip make any difference?

boegel commented 1 year ago

No, same problem with pip 22.2.2 . Full output produced by pip install:

$ pip install --prefix /tmp/$USER/looseversion .
Processing /private/tmp/kehoste/looseversion-1.0.1
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: looseversion
  Building wheel for looseversion (pyproject.toml) ... done
  Created wheel for looseversion: filename=looseversion-1.0.1-py3-none-any.whl size=3235 sha256=e2085c38dc77bd07db12a54e3b70920f7bdf808b8f91cf4147e6142dc6e7a410
  Stored in directory: /Users/kehoste/Library/Caches/pip/wheels/53/3e/db/5a114fc81b49312ae9c4fc653e3e53350a2fa74f9fb111a4ff
Successfully built looseversion
Installing collected packages: looseversion
Successfully installed looseversion-1.0.1

Maybe something is missing in pyproject.toml to indicate that looseversion.py should be installed (since looseversion is a single-module package, with no proper Python packages)?

merwok commented 1 year ago

Nothing improper about modules that are not packages!

In setup.py, the parameter name is py_modules, and it’s probably spelled the same way for setup.cfg. Current file is missing the _.

effigies commented 1 year ago

So pymodules = looseversion.py works for building a wheel but seems to be undocumented. It might be an ancient distutils practice...

I think if you change it to py_modules = looseversion, that might work. If you figure it out, could you submit a PR?

effigies commented 1 year ago

Another option could be to update the build configuration to be entirely in pyproject.toml. Since that's a bit more strongly-typed than setup.cfg, it might be easier to debug.

merwok commented 1 year ago

pymodules was never a setup parameter, and the values were always module names not filenames (no .py). Very strange that it seemed to build a correct wheel! Probably another mechanism was including the file (maybe MANIFEST.in or another setup option), then it ended up installed because some other part of the code matched all Python files or something like that.

effigies commented 1 year ago

I think you're right. Dropping the pymodules line altogether doesn't break anything, so I guess it was just luck. And I did test py_modules = looseversion does work. Will submit a PR momentarily.

effigies commented 1 year ago

@boegel 1.0.2 has been uploaded to PyPI.

boegel commented 1 year ago

Thanks a lot, I can confirm that looseversion 1.0.2 is working as expected :+1: