paylogic / py2deb

Python to Debian package converter
https://py2deb.readthedocs.org/
MIT License
280 stars 30 forks source link

module 'platform' has no attribute 'linux_distribution' #32

Open theduckchannel opened 4 years ago

theduckchannel commented 4 years ago

py2deb -v crazydiskmark Tue 01 Sep 2020 07:27:41 PM UTC 2020-09-01 16:27:48 shadowBox pip_accel[89399] INFO Unpacking distribution(s) .. 2020-09-01 16:27:48 shadowBox pip_accel[89399] INFO Executing command: pip install --download=/home/fredlins/.pip-accel/sources --find-links=file:///home/fredlins/.pip-accel/sources --no-binary=:all: --no-index --no-clean --build-directory=/tmp/pip-accel-build-dir-nl_2re2q --ignore-installed crazydiskmark 2020-09-01 16:27:48 shadowBox pip.commands.install[89399] INFO Ignoring indexes: https://pypi.python.org/simple 2020-09-01 16:27:48 shadowBox py2deb.cli[89399] ERROR Caught an unhandled exception! Traceback (most recent call last): File "/home/fredlins/.local/lib/python3.8/site-packages/py2deb/cli.py", line 200, in main archives, relationships = converter.convert(arguments) File "/home/fredlins/.local/lib/python3.8/site-packages/py2deb/converter.py", line 736, in convert self.packages_to_convert = list(self.get_source_distributions(pip_install_arguments)) File "/home/fredlins/.local/lib/python3.8/site-packages/py2deb/converter.py", line 793, in get_source_distributions for requirement in self.pip_accel.get_requirements(arguments): File "/home/fredlins/.local/lib/python3.8/site-packages/pip_accel/init.py", line 297, in get_requirements return self.unpack_source_dists(arguments, use_wheels=use_wheels) File "/home/fredlins/.local/lib/python3.8/site-packages/pip_accel/init.py", line 393, in unpack_source_dists requirements = self.get_pip_requirement_set(arguments, use_remote_index=False, use_wheels=use_wheels) File "/home/fredlins/.local/lib/python3.8/site-packages/pip_accel/init.py", line 497, in get_pip_requirement_set requirement_set = command.run(opts, args) File "/home/fredlins/.local/lib/python3.8/site-packages/pip/commands/install.py", line 245, in run with self._build_session(options) as session: File "/home/fredlins/.local/lib/python3.8/site-packages/pip/basecommand.py", line 65, in _build_session session = PipSession( File "/home/fredlins/.local/lib/python3.8/site-packages/pip/download.py", line 316, in init self.headers["User-Agent"] = user_agent() File "/home/fredlins/.local/lib/python3.8/site-packages/pip/download.py", line 92, in user_agent zip(["name", "version", "id"], platform.linux_distribution()), AttributeError: module 'platform' has no attribute 'linux_distribution'

chy-causer commented 3 years ago

Can confirm that this is an issue for me in a virtual environment running Python 3.9. The reason is that py2deb has a requirement on pip-accel <=0.43, which in turn has a requirement on pip <7.2.

This version of pip is not compatible with modern Python versions (3.8+).

ygbourhis commented 2 years ago

I confirm the issue with Python 3.8.10 on Ubuntu 20.04.3 LTS.

kakaday22 commented 2 years ago

I have a local patch to get it working in 3.8+

sed -i '/import platform/a import distro as os_version' "/usr/local/lib/python${VERSION}/site-packages/pip/download.py" sed -i 's/platform.linux_distribution/os_version.linux_distribution/g' "/usr/local/lib/python${VERSION}/site-packages/pip/download.py"

where, VERSION=3.8