scrapyd icon indicating copy to clipboard operation
scrapyd copied to clipboard

Replace distutils.version.LooseVersion with packaging.version Version

Open pawelmhm opened this issue 3 years ago • 1 comments

In scrapyd/eggstorage.py we use LooseVersion from distutils https://github.com/scrapy/scrapyd/blob/b45c20547b91f34938ee574f86ba966d4b17b05c/scrapyd/eggstorage.py#L37

The distutils package is deprecated and slated for removal in Python 3.12.

PEP 632 recommends using packaging.version. There is one problem, that LooseVersion was designed as a tool for anarchists and packaging.version is not a tool for anarchists, it raises error when version is not matching PEP 440. I suspect this may break some projects because many projects don't use semantic versioning but just use version control hashes as version numbers.

IMO we should just rewrite this sorting in eggstorage to keep old behavior without distutils, I don't see a problem in hashes as version numbers, so we can just keep old way, but maybe worth discussing how to do it? What community expects here? What are your practices and expectations here?

Expected output here:

  • [ ] patch that replaces LooseVersion with something else
  • [ ] unit tests that show that current behavior is preserved and does not break people projects, they can go somewhere here: https://github.com/scrapy/scrapyd/blob/b45c20547b91f34938ee574f86ba966d4b17b05c/scrapyd/tests/test_eggstorage.py or here if we add separate utility for sorting https://github.com/scrapy/scrapyd/blob/b45c20547b91f34938ee574f86ba966d4b17b05c/scrapyd/tests/test_utils.py

pawelmhm avatar Dec 24 '21 10:12 pawelmhm

I agree with preserving the old way. There's no clear reason for us to remove it, and it should be straight-forward to have some local version of LooseVersion.

jpmckinney avatar Dec 24 '21 19:12 jpmckinney