Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backblaze-b2: update to 3.6.0 #40928

Merged
merged 5 commits into from
Dec 7, 2022
Merged

Conversation

ahesford
Copy link
Member

@ahesford ahesford commented Dec 6, 2022

Testing the changes

  • I tested the changes in this PR: NO

@kartikynwa

@kartikynwa
Copy link
Contributor

@ahesford At run, it complains that python3-docutils is outdated. I updated that package to 0.19. After that it complains that python3-tqdm version should be at least 4.50. I tried updating it to 4.64.1 (latest stable version) but setuptools_scm complains that it needs to .git folder to get the version number. Not sure what to do about that.

@ahesford ahesford force-pushed the backblaze branch 2 times, most recently from a420a0c to 309a714 Compare December 6, 2022 17:21
@ahesford
Copy link
Member Author

ahesford commented Dec 6, 2022

Please try now; I bumped docutils and tqdm.

@ahesford ahesford marked this pull request as draft December 6, 2022 18:08
@ahesford ahesford marked this pull request as ready for review December 6, 2022 23:56
@kartikynwa
Copy link
Contributor

kartikynwa commented Dec 7, 2022

@ahesford Needs two more changes:

This is the patch I used
diff --git a/b2/console_tool.py b/b2/console_tool.py
index 1115cc79..760be547 100644
--- a/b2/console_tool.py
+++ b/b2/console_tool.py
@@ -500,11 +500,8 @@ def name_and_alias(cls):
     @classmethod
     def register_subcommand(cls, command_class):
         assert cls.subcommands_registry is not None, 'Initialize the registry class'
-        name, alias = command_class.name_and_alias()
+        name, _ = command_class.name_and_alias()
         decorator = cls.subcommands_registry.register(key=name)(command_class)
-        # Register alias if present
-        if alias is not None:
-            cls.subcommands_registry[alias] = command_class
         return decorator
 
     @classmethod
@@ -531,6 +528,8 @@ def get_parser(cls, subparsers=None, parents=None, for_docs=False):
                 aliases=[alias] if alias is not None and not for_docs else (),
                 for_docs=for_docs,
             )
+            # Register class that will handle this particular command, for both name and alias.
+            parser.set_defaults(command_class=cls)
 
         cls._setup_parser(parser)
 
@@ -655,7 +654,9 @@ def name_and_alias(cls):
         return NAME, None
 
     def run(self, args):
-        return self.subcommands_registry.get_class(args.command)
+        # Commands could be named via name or alias, so we fetch
+        # the command from args assigned during parser preparation.
+        return args.command_class
 
 
 @B2.register_subcommand
diff --git a/noxfile.py b/noxfile.py
index aaa2bac3..25cf8de1 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -24,7 +24,13 @@
 NO_STATICX = os.environ.get('NO_STATICX') is not None
 NOX_PYTHONS = os.environ.get('NOX_PYTHONS')
 
-PYTHON_VERSIONS = ['3.7', '3.8', '3.9', '3.10'] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')
+PYTHON_VERSIONS = [
+    '3.7',
+    '3.8',
+    '3.9',
+    '3.10',
+    '3.11',
+] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')
 PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1]
 
 PY_PATHS = ['b2', 'test', 'noxfile.py', 'setup.py']

After these the package works fine. I have tried login, ls, download and upload. All working great. Thanks for your work.

BTW do you know why I faced this problem with python3-tqdm?

complains that it needs to .git folder to get the version number

In your PR I see that you changed the hostmakedepends to setuptools_scm which I already tried. Apart from that is changing the source from github to pypi enough? I thought of trying that too but the pypi tarball also did not have a .git folder in it.

@ahesford
Copy link
Member Author

ahesford commented Dec 7, 2022

I pulled the patch from the corresponding upstream commit.

Fetching from PyPI is sufficient to make setuptools_scm work as expected. The GitHub archive is missing some release bits that the package looks for when determining a version.

As for python3-tqdm, this is an optional dependency of python3-b2sdk. The package is supposed to fall back gracefully to a simple text progress indicator when the package is not installed. We shouldn't add a hard requirement here.

@kartikynwa
Copy link
Contributor

@ahesford backblaze-b2 fails without tqdm. I am not sure why this is:

Output
in void-packages on  update-b2 [✘!?] took 3s
 ❯ xbps-query -l | grep '\(backblaze-b2\|tqdm\)'
ii backblaze-b2-3.6.0_1                    Command Line Interface for Backblaze's B2 storage service

in void-packages on  update-b2 [✘!?]
 ❯ b2 help
Traceback (most recent call last):
  File "/usr/local/bin/b2", line 33, in <module>
    sys.exit(load_entry_point('b2==3.6.0', 'console_scripts', 'b2')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/b2", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 198, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.11/site-packages/b2/console_tool.py", line 34, in <module>
    from b2sdk.v2 import (
  File "/usr/lib/python3.11/site-packages/b2sdk/v2/__init__.py", line 11, in <module>
    from b2sdk._v3 import *  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/b2sdk/_v3/__init__.py", line 48, in <module>
    from b2sdk.version_utils import rename_argument, rename_function
  File "/usr/lib/python3.11/site-packages/b2sdk/version_utils.py", line 16, in <module>
    from pkg_resources import parse_version
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3259, in <module>
    @_call_aside
     ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3234, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3272, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 581, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 909, in require
    needed = self.resolve(parse_requirements(requirements))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 795, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'tqdm<5.0.0,>=4.5.0' distribution was not found and is required by b2sdk

On the other hand it works if tqdm is present

Output
in void-packages on  update-b2 [✘!?] took 420ms
 ❯ xbps-query -l | grep '\(backblaze-b2\|tqdm\)'
ii backblaze-b2-3.6.0_1                    Command Line Interface for Backblaze's B2 storage service
ii python3-tqdm-4.64.1_1                   Fast, extensible progress bar for Python and CLI (Python3)

in void-packages on  update-b2 [✘!?]
 ❯ b2 help
b2 [-h]
   {authorize-account,authorize_account,cancel-all-unfinished-large-files,cancel_all_unfinished_large_files,cancel-large-file,cancel_large_file,clear-account,clear_account,copy-file-by-id,copy_file_by_id,create-bucket,create_bucket,create-key,create_key,delete-bucket,delete_bucket,delete-file-version,delete_file_version,delete-key,delete_key,download-file-by-id,download_file_by_id,download-file-by-name,download_file_by_name,get-account-info,get_account_info,get-bucket,get_bucket,get-file-info,get_file_info,get-download-auth,get_download_auth,get-download-url-with-auth,get_download_url_with_auth,hide-file,hide_file,list-buckets,list_buckets,list-keys,list_keys,list-parts,list_parts,list-unfinished-large-files,list_unfinished_large_files,ls,make-url,make_url,make-friendly-url,make_friendly_url,sync,update-bucket,update_bucket,upload-file,upload_file,update-file-legal-hold,update_file_legal_hold,update-file-retention,update_file_retention,replication-setup,replication_setup,replication-delete,replication_delete,replication-pause,replication_pause,replication-unpause,replication_unpause,replication-status,replication_status,version}
   ...

I am guessing this happens because in b2sdk's requirement.txt tqdm is listed as a dependency. But in the code I can see that the import is optional.

@kartikynwa
Copy link
Contributor

@ahesford I just tested that if I remove tqdm from b2sdk's requirements.txt, backblaze is able to fall back on simpler text based progress indication:

image

@ahesford
Copy link
Member Author

ahesford commented Dec 7, 2022

OK, I just added the dependency to python3-b2sdk. I also noticed that six dropped off the requirements list, so we can drop that.

@kartikynwa
Copy link
Contributor

@ahesford Working fine now. Thanks a lot. Just tested it.

@ahesford ahesford merged commit 55988eb into void-linux:master Dec 7, 2022
@ahesford ahesford deleted the backblaze branch December 7, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backblaze-b2 package is broken and outdated
2 participants