insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.26k stars 308 forks source link

docs: README.md: source install instructions use pip to avoid google namespace package differences #669

Open mdengler opened 9 months ago

mdengler commented 9 months ago

Avoids this issue: https://github.com/protocolbuffers/protobuf/issues/7877#issuecomment-691371728

Summary: google packages are mixing "native namespace packages" and "eggs that internally use pkg_resources-style packages", causing ImportError when people install from source using python setup.py install; instead, people should install from source with python -m pip install. The google packages are running afoul of the "Warning" from https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#creating-a-namespace-package .

mdengler commented 9 months ago

Before:

$ python setup.py install --user --verbose                                                                           
[...lots of output trimmed, all successful installs...]
Finished processing dependencies for gcalcli==4.3.0                                                                                                           

$ gcalcli                       
Traceback (most recent call last):                                                                                                                            
  File "/home/martin/.local/bin/gcalcli", line 33, in <module>                                                                                                
    sys.exit(load_entry_point('gcalcli==4.3.0', 'console_scripts', 'gcalcli')())                                                                              
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                 
  File "/home/martin/.local/bin/gcalcli", line 25, in importlib_load_entry_point                                                                              
    return next(matches).load()                                                                                                                               
           ^^^^^^^^^^^^^^^^^^^^                                                                                                                               
  File "/usr/lib64/python3.11/importlib/metadata/__init__.py", line 202, in load                                                                              
    module = import_module(match.group('module'))                                                                                                             
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                             
  File "/usr/lib64/python3.11/importlib/__init__.py", line 126, in import_module                                                                              
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                               
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                               
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import                                                                                             
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load                                                                                          
  File "<frozen importlib._bootstrap>", line 1147, 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 "/home/martin/.local/lib/python3.11/site-packages/gcalcli-4.3.0-py3.11.egg/gcalcli/cli.py", line 30, in <module>                                       
  File "/home/martin/.local/lib/python3.11/site-packages/gcalcli-4.3.0-py3.11.egg/gcalcli/gcal.py", line 15, in <module>                                      
  File "/home/martin/.local/lib/python3.11/site-packages/google_api_python_client-2.99.0-py3.11.egg/apiclient/__init__.py", line 3, in <module>               
    from googleapiclient import channel, discovery, errors, http, mimeparse, model                                                                            
  File "/home/martin/.local/lib/python3.11/site-packages/google_api_python_client-2.99.0-py3.11.egg/googleapiclient/discovery.py", line 42, in <module>       
    import google.api_core.client_options                                                                                                                     
ModuleNotFoundError: No module named 'google.api_core'                                                                                                        

After the fix:

$ python -m pip install --user .                                                                                     
Processing /home/martin/src/gcalcli
[...lots of output trimmed...]
Successfully installed gcalcli-4.3.0                                                                                                                          

$ gcalcli     
usage: gcalcli [-h] [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver] [--auth_host_port [AUTH_HOST_PORT ...]]
               [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--version] [--client-id CLIENT_ID] [--client-secret CLIENT_SECRET]
               [--config-folder CONFIG_FOLDER] [--noincluderc] [--calendar CALENDAR] [--default-calendar DEFAULTCALENDAR] [--locale LOCALE] [--refresh]
               [--nocache] [--conky] [--nocolor] [--lineart {fancy,unicode,ascii}]
               {list,search,edit,delete,agenda,agendaupdate,updates,conflicts,calw,calm,quick,add,import,remind} ...
gcalcli: error: the following arguments are required: command

# success