Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

'LegacyVersion' object has no attribute 'major' #299

Closed
JessicaTegner opened this issue Jul 20, 2021 · 12 comments
Closed

'LegacyVersion' object has no attribute 'major' #299

JessicaTegner opened this issue Jul 20, 2021 · 12 comments

Comments

@JessicaTegner
Copy link
Contributor

Hi

I get the following error when trying to process my generated packages

  • System: Ubuntu (Github Hosted Runner)
  • PyUpdater version: 4.0

Log output is the following

2021-07-18T23:44:46.1915991Z [INFO] Processing packages...
2021-07-18T23:44:46.1916666Z 449 INFO: Processing packages...
2021-07-18T23:44:46.1917239Z [INFO] Patch support enabled
2021-07-18T23:44:46.1917940Z 450 INFO: Patch support enabled
2021-07-18T23:44:46.1918500Z [INFO] Generating package list
2021-07-18T23:44:46.1919091Z 450 INFO: Generating package list
2021-07-18T23:44:46.1920509Z 450 DEBUG: Extracting update archive info for: VisCon-win-1.0.11.zip
2021-07-18T23:44:46.1921585Z [ERROR] 'LegacyVersion' object has no attribute 'major'
2021-07-18T23:44:46.1925370Z 450 ERROR: 'LegacyVersion' object has no attribute 'major'
2021-07-18T23:44:46.1926470Z 450 DEBUG: 'LegacyVersion' object has no attribute 'major'
2021-07-18T23:44:46.1927165Z Traceback (most recent call last):
2021-07-18T23:44:46.1929530Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/cli/init.py", line 79, in main
2021-07-18T23:44:46.1930458Z _real_main(args)
2021-07-18T23:44:46.1931738Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/cli/init.py", line 55, in _real_main
2021-07-18T23:44:46.1932674Z dispatch_command(args, pyi_args)
2021-07-18T23:44:46.1933965Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/cli/init.py", line 68, in dispatch_command
2021-07-18T23:44:46.1934890Z cmd(args, pyi_args)
2021-07-18T23:44:46.1936308Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/cli/commands.py", line 305, in _cmd_pkg
2021-07-18T23:44:46.1937312Z pyu.process_packages(ns.verbose)
2021-07-18T23:44:46.1938638Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/core/init.py", line 77, in process_packages
2021-07-18T23:44:46.1939694Z self.ph.process_packages(report_errors)
2021-07-18T23:44:46.1941214Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/core/package_handler/init.py", line 107, in process_packages
2021-07-18T23:44:46.1943249Z pkg_manifest, patch_manifest = self._get_package_list(report_errors)
2021-07-18T23:44:46.1945165Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/core/package_handler/init.py", line 180, in _get_package_list
2021-07-18T23:44:46.1946192Z new_pkg = Package(p)
2021-07-18T23:44:46.1947808Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/core/package_handler/package.py", line 154, in init
2021-07-18T23:44:46.1948870Z self.extract_info(filename)
2021-07-18T23:44:46.1950290Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/pyupdater/core/package_handler/package.py", line 186, in extract_info
2021-07-18T23:44:46.1951346Z v = Version(package_basename)
2021-07-18T23:44:46.1952594Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/dsdev_utils/helpers.py", line 147, in init
2021-07-18T23:44:46.1953537Z self._parse_version_str(version)
2021-07-18T23:44:46.1954843Z File "/opt/hostedtoolcache/Python/3.9.6/x64/lib/python3.9/site-packages/dsdev_utils/helpers.py", line 151, in _parse_version_str
2021-07-18T23:44:46.1955838Z self.major = version_data.major
2021-07-18T23:44:46.1956828Z AttributeError: 'LegacyVersion' object has no attribute 'major'
2021-07-18T23:44:46.1958134Z 'LegacyVersion' object has no attribute 'major'

@abionics
Copy link

@NicklasTegner I had the same issue
Try to use this versions, it helps me:

pyinstaller==4.3
dsdev_utils==1.0.5

@JessicaTegner
Copy link
Contributor Author

Hi. Downgrading dsdev_utils to the version above seems to work.
@JMSwag any word on what's going on here / why?

@JMSwag
Copy link
Member

JMSwag commented Aug 4, 2021

There was a change in a dependent library. I'll take a look.

@jaymegordo
Copy link

+1 getting this error as well

@dennisvang
Copy link

dennisvang commented Dec 6, 2021

Here's the cause: Digital-Sapphire/dsdev-utils#9 (comment)

Basically, your version string is probably not PEP440 compliant, so packaging.version.parse() returns a LegacyVersion instead of the Version that is expected by pyupdater 4.0.

One workaround is to make your versioning PEP440 compliant.

@JessicaTegner
Copy link
Contributor Author

@dennisvang can you give some examples of PEP440 compliant, versioning strings.

@dennisvang
Copy link

dennisvang commented Dec 8, 2021

@NicklasTegner lots of examples are available in the PEP440 linked above.

More specifically, here: PEP440 - examples of compliant version schemes.

Also see PEP440 - compatibility with other version schemes

@dennisvang
Copy link

dennisvang commented Dec 9, 2021

@NicklasTegner After having a closer look, it turns out my suggested workaround is not very helpful in this specific case, because the actual "version string" is a filename here, e.g. my-app-1.2.3.zip, which you cannot influence directly...

See Package.extract_info, line 186 from your traceback.

The underlying cause is in dsdev-utils, because the custom regex-based parsing has been replaced by packaging.version.parse.

I'll try to fix this on the pyupdater side for now, as it's causing me trouble as well.

@dennisvang
Copy link

dennisvang commented Dec 9, 2021

By the way, note that tests.test_package_handler.TestPackage fails with the exact same error.

@mathieukaelin
Copy link

mathieukaelin commented May 13, 2022

@dennisvang Any update on this issue?
In my case, I have solved this issue by using dsdev-utils==1.0.5. I have initially tried to downgrad it from 1.3.0 to 1.2.0 and 1.1.0 without any effect.
My setup:

  • pyupdater==4.0
  • pyinstaller==5.0.1
  • ddsdev-utils==1.0.5

@dennisvang
Copy link

@mathieukaelin Sorry, no updates, unfortunately:

PR #322 (mentioned above) should fix this, but I haven't seen any movement from the maintainers since then...

You could try it out by installing directly from my fork (see pip VCS support), e.g. something like:

pip install pyupdater@git+https://github.com/dennisvang/PyUpdater.git@multifix

However, this is not a proper permanent solution.

Alternatively you could downgrade to pyupdater 3.1.1, which does work, mostly.

@mathieukaelin
Copy link

mathieukaelin commented May 13, 2022

@dennisvang Thanks for the advice and for your work on this issue. I think I will downgrade to pyupdater 3.1.1. Especially given the fact that apparently it may be not be possible to migrate from pyupdater 4.0 to 5.0 in the futur according to Project Update v5 - Clean Slate issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants