Giter VIP home page Giter VIP logo

circup's Introduction

CircUp

Documentation Status Discord Build Status Code Style: Black

A tool to manage and update libraries (modules) on a CircuitPython device.

Circup requires Python 3.5 or higher.

In a virtualenv, pip install circup should do the trick. This is the simplest way to make it work.

If you have no idea what a virtualenv is, try the following command, pip3 install --user circup.

Note

If you use the pip3 command to install CircUp you must make sure that your path contains the directory into which the script will be installed. To discover this path,

  • On Unix-like systems, type python3 -m site --user-base and append bin to the resulting path.
  • On Windows, type the same command, but append Scripts to the resulting path.

Each CircuitPython library on the device usually has a version number as metadata within the module.

This utility looks at all the libraries on the device and checks if they are the most recent (compared to the versions found in the most recent version of the Adafruit CircuitPython Bundle and Circuitpython Community Bundle). If the libraries are out of date, the utility helps you update them.

The Adafruit CircuitPython Bundle can be found here:

https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest

Full details of these libraries, what they're for and how to get them, can be found here:

https://circuitpython.org/libraries

The Circuitpython Community Bundle can be found here:

https://github.com/adafruit/CircuitPython_Community_Bundle/releases/latest

If you need more detailed help using Circup see the Learn Guide article "Use CircUp to easily keep your CircuitPython libraries up to date".

First, plug in a device running CircuiPython. This should appear as a mounted storage device called CIRCUITPY.

To get help, just type the command:

$ circup
Usage: circup [OPTIONS] COMMAND [ARGS]...

  A tool to manage and update libraries on a CircuitPython device.

Options:
  --verbose           Comprehensive logging is sent to stdout.
  --path DIRECTORY    Path to CircuitPython directory. Overrides automatic
                      path detection.
  --host TEXT         Hostname or IP address of a device. Overrides automatic
                      path detection.
  --password TEXT     Password to use for authentication when --host is used.
  --timeout INTEGER   Specify the timeout in seconds for any network
                      operations.
  --board-id TEXT     Manual Board ID of the CircuitPython device. If provided
                      in combination with --cpy-version, it overrides the
                      detected board ID.
  --cpy-version TEXT  Manual CircuitPython version. If provided in combination
                      with --board-id, it overrides the detected CPy version.
  --version           Show the version and exit.
  --help              Show this message and exit.

Commands:
  bundle-add     Add bundles to the local bundles list, by "user/repo"...
  bundle-remove  Remove one or more bundles from the local bundles list.
  bundle-show    Show the list of bundles, default and local, with URL,...
  example        Copy named example(s) from a bundle onto the device.
  freeze         Output details of all the modules found on the connected...
  install        Install a named module(s) onto the device.
  list           Lists all out of date modules found on the connected...
  show           Show a list of available modules in the bundle.
  uninstall      Uninstall a named module(s) from the connected device.
  update         Update modules on the device. Use --all to automatically
                 update all modules without Major Version warnings.

To automatically install all modules imported by code.py, $ circup install --auto:

$ circup install --auto
Found device at /Volumes/CIRCUITPY, running CircuitPython 7.0.0-alpha.5.
Searching for dependencies for: ['adafruit_bmp280']
Ready to install: ['adafruit_bmp280', 'adafruit_bus_device', 'adafruit_register']

Installed 'adafruit_bmp280'.
Installed 'adafruit_bus_device'.
Installed 'adafruit_register'.

To search for a specific module containing the name bme: $ circup show bme:

$ circup show bme
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.1.0-beta.2.
adafruit_bme280
adafruit_bme680
2 shown of 257 packages.

To show version information for all the modules currently on a connected CIRCUITPYTHON device:

$ circup freeze
adafruit_binascii==v1.0
adafruit_bme280==2.3.1
adafruit_ble==1.0.2

With $ circup freeze -r, Circup will save, in the current working directory, a requirements.txt file with a list of all modules currently installed on the connected device.

To list all the modules that require an update:

$ circup list
The following modules are out of date or probably need an update.

Module             Version  Latest
------------------ -------- --------
adafruit_binascii  v1.0     1.0.1
adafruit_ble       1.0.2    4.0

To interactively update the out-of-date modules:

$ circup update
Found 3 module[s] needing update.
Please indicate which modules you wish to update:

Update 'adafruit_binascii'? [y/N]: Y
OK
Update 'adafruit_ble'? [y/N]: Y
OK

Install a module or modules onto the connected device with:

$ circup install adafruit_thermal_printer
Installed 'adafruit_thermal_printer'.

$ circup install adafruit_thermal_printer adafruit_bus_io
Installed 'adafruit_thermal_printer'.
Installed 'adafruit_bus_io'.

If you need to work with the original .py version of a module, use the --py flag.

$ circup install --py adafruit_thermal_printer Installed 'adafruit_thermal_printer'.

You can also install a list of modules from a requirements.txt file in the current working directory with:

$ circup install -r requirements.txt
Installed 'adafruit_bmp280'.
Installed 'adafruit_lis3mdl'.
Installed 'adafruit_lsm6ds'.
Installed 'adafruit_sht31d'.
Installed 'neopixel'.

Uninstall a module or modules like this:

$ circup uninstall adafruit_thermal_printer
Uninstalled 'adafruit_thermal_printer'.

$ circup uninstall adafruit_thermal_printer adafruit_bus_io
Uninstalled 'adafruit_thermal_printer'.
Uninstalled 'adafruit_bus_io'.

Use the --verbose flag to see the logs as the command is working:

$ circup --verbose freeze
Logging to /home/ntoll/.cache/circup/log/circup.log

10/18/2020 00:54:43 INFO: ### Started Circup ###
10/18/2020 00:54:43 INFO: Found device: /Volumes/CIRCUITPY
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.0.0-alpha.1-1352-gf0b37313c.
10/18/2020 00:54:44 INFO: Freeze
10/18/2020 00:54:44 INFO: Found device: /Volumes/CIRCUITPY
... etc ...

The --path flag let's you pass in a different path to the CircuitPython mounted volume. This is helpful when you have renamed or have more than one CircuitPython devices attached:

$ circup --path /run/media/user/CIRCUITPY1 list

The --version flag will tell you the current version of the circup command itself:

$ circup --version
CircUp, A CircuitPython module updater. Version 0.0.1

To use circup via the Web Workflow. on devices that support it. Use the --host and --password arguments before your circup command.:

$ circup --host 192.168.1.119 --password s3cr3t install adafruit_hid
$ circup --host cpy-9573b2.local --password s3cr3t install adafruit_hid

That's it!

When enabled, circup will autocomplete library names, simliar to other command line tools.

For example:

circup install n + tab -circup install neopixel (+tab: offers neopixel and neopixel_spi completions)

circup install a + tab -circup install adafruit\_ + m a g + tab -circup install adafruit_magtag

In order to activate shell completion, you need to inform your shell that completion is available for your script. Any Click application automatically provides support for that.

For Bash, add this to ~/.bashrc:

eval "$(_CIRCUP_COMPLETE=bash_source circup)"

For Zsh, add this to ~/.zshrc:

eval "$(_CIRCUP_COMPLETE=zsh_source circup)"

For Fish, add this to ~/.config/fish/completions/foo-bar.fish:

eval (env _CIRCUP_COMPLETE=fish_source circup)

Open a new shell to enable completion. Or run the eval command directly in your current shell to enable it temporarily. ### Activation Script

The above eval examples will invoke your application every time a shell is started. This may slow down shell startup time significantly.

Alternatively, export the generated completion code as a static script to be executed. You can ship this file with your builds; tools like Git do this. At least Zsh will also cache the results of completion files, but not eval scripts.

For Bash:

_CIRCUP_COMPLETE=bash_source circup circup-complete.sh

For Zsh:

_CIRCUP_COMPLETE=zsh_source circup circup-complete.sh

For Fish:

_CIRCUP_COMPLETE=fish_source circup circup-complete.sh

In .bashrc or .zshrc, source the script instead of the eval command:

. /path/to/circup-complete.sh

For Fish, add the file to the completions directory:

_CIRCUP_COMPLETE=fish_source circup ~/.config/fish/completions/circup-complete.fish

Note

If you find a bug, or you want to suggest an enhancement or new feature feel free to create an issue or submit a pull request here:

https://github.com/adafruit/circup

Discussion of this tool happens on the Adafruit CircuitPython Discord channel.

circup's People

Contributors

aricooperdavis avatar askpatrickw avatar cpforbes avatar dependabot[bot] avatar dgriswo avatar dhalbert avatar foamyguy avatar furbrain avatar imnotjames avatar jepler avatar joedevivo avatar jposada202020 avatar justmobilize avatar kattni avatar ladyada avatar lesamouraipourpre avatar lynt-smitka avatar makermelissa avatar neradoc avatar ntoll avatar siddacious avatar sjev avatar slootsky avatar sommersoft avatar stevenabadie avatar tannewt avatar tekktrik avatar tyeth avatar vladak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circup's Issues

Upgrade SemVer to >= 2.13

Semver's latest stable is 2.13.
https://python-semver.readthedocs.io/en/stable/

It includes deprecation warnings from 2.10. Specifically for Circup:

~/code/github/adafruit/circup/circup.py:147: DeprecationWarning: Function 'semver.compare' is deprecated. Deprecated since version 2.10.0. This function will be removed in semver 3. Use the respective 'semver.VersionInfo.compare' instead.

Add optional search argument to circup show

circup show lc7 would search the libraries for matches and be the functional equivalent of circup show |grep lc7 which is not very new programmer friendly.

circup show should stay unchanged and list all the libraries in the bundle.

circup show lc7
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.1.0-beta.2-151-g737828ccb-dirty.
Usage: circup show [OPTIONS]
Try 'circup show --help' for help.

Error: Got unexpected extra argument (lc7)

code/local/circuit-python-scripts via ๐Ÿ cp_base took 2s
โžœ circup show |grep lc7
adafruit_lc709203f

This is very helpful when you have a new stemma board in front of you. :-)

Installing from PyPI errors

Typing pip3 install circup results in the following error:

Collecting circup
  Downloading https://files.pythonhosted.org/packages/67/94/fb0526baa550ddfc503b49edbe4932c7e1999e8aa1488cc30f1057cc0547/circup-0.0.1.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/5h/13ngwp912tq9gr12796g77br0000gn/T/pip-install-6xwg6yoc/circup/setup.py", line 21, in <module>
        with open(os.path.join(base_dir, "CHANGES.rst"), encoding="utf8") as f:
    FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/5h/13ngwp912tq9gr12796g77br0000gn/T/pip-install-6xwg6yoc/circup/CHANGES.rst'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/5h/13ngwp912tq9gr12796g77br0000gn/T/pip-install-6xwg6yoc/circup/

Errors (possibly due to upgrading to Python 3.9

I just upgraded to Python3.9 and am getting the following issue:

circup update --all
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 582, in _build_master
    ws.require(__requires__)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 899, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 790, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (click 7.1.2 (/Users/mattpackwood/Library/Python/3.9/lib/python/site-packages), Requirement.parse('Click==7.0'), {'circup'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/System/Volumes/Data/Users/mattpackwood/Library/Python/3.8/bin/circup", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3257, in <module>
    def _initialize_master_working_set():
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3240, in _call_aside
    f(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3269, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 584, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 597, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 785, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Click==7.0' distribution was not found and is required by circup

circup install should support more than one package at a time

Just like pip, circup should let you install more than on packagae at a time.

This should work:
circup install adafruit_lc709203f adafruit_dotstar adafruit_io adafruit_logging adafruit_requests

it fails
Error: Got unexpected extra arguments (adafruit_dotstar adafruit_io adafruit_logging adafruit_requests)

Mu Editor Integration

This would be useful to add to Mu (the original author of this library was also one of the lead developers for mu). I don't believe mu supports plugins, so it would have to be added as a feature.

Use latest **tag** as basis of latest version value

Whilst debugging the code that updates modules in-place I've just seen/realised that there appears to be some sort of automation tool that replaces the __version__ value in the source file (which has been set to "0.0.0-auto.0") to the semver value used as the name of the tag.

Ergo, circup needs to use the latest tag as the bases of the latest remote version.

--version does not show the correct version

Since the fix for #19 the --version outputs the place holder.

CircUp, A CircuitPython module updater. Version 0.0.0-auto.0

It should output the correct version. (note: Pip list does show the correct version).

Missing dependency

  • Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
    Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): windows 10 64-bit

  • Python version (run python -version or python3 -version): Python 3.9.0

  • Error message you are receiving, including any Python exception traces:

code.py output:
Traceback (most recent call last):
  File "code.py", line 4, in <module>
  File "adafruit_emc2101.py", line 30, in <module>
ImportError: no module named 'adafruit_register'
  • List the steps to reproduce the problem below (if possible attach code or commands
    to run):

On a pretty clean install of circuitpython, run circup install adafruit_emc2101

It says there are no dependencies, but when you run it, it complains of missing adafruit_register.

Check CircuitPython version

Feature request

Add support for checking the installed version of CircuitPython and advising if there is a newer version (or beta version) available.
While CircUp won't be able to install the update, it could provide a link to the download location or download it if requested.

Circup should support installing more than one package at a time

Just like pip, circup should let you install more than on packagae at a time.

This should work:
circup install adafruit_lc709203f adafruit_dotstar adafruit_io adafruit_logging adafruit_requests

It fails
Error: Got unexpected extra arguments (adafruit_dotstar adafruit_io adafruit_logging adafruit_requests)

Error upgrading

  • Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
    Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): macOS 11.0.1 (20B29)

  • Python version (run python -version or python3 -version): Python 3.9.0

  • Error message you are receiving, including any Python exception traces:

    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-install-3v99wxbx/circup_9246775460bf450a8492b2ae1fdc046c/setup.py'"'"'; __file__='"'"'/private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-install-3v99wxbx/circup_9246775460bf450a8492b2ae1fdc046c/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-pip-egg-info-tedtn3re
         cwd: /private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-install-3v99wxbx/circup_9246775460bf450a8492b2ae1fdc046c/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-install-3v99wxbx/circup_9246775460bf450a8492b2ae1fdc046c/setup.py", line 21, in <module>
        with open(os.path.join(base_dir, "CHANGES.rst"), encoding="utf8") as f:
    FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/s7/typ53r597p33k6rpcwn9lg_40000gn/T/pip-install-3v99wxbx/circup_9246775460bf450a8492b2ae1fdc046c/CHANGES.rst'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

  • List the steps to reproduce the problem below (if possible attach code or commands
    to run):
    python3 -m pip install --upgrade --user apprise circup

Extract metadata from modules within directories

Currently, circup only extracts __version__ and __repo__ metadata from single file Python modules. It should be able to work with more complicated modules whose code is housed in separate directories.

I propose to use the following plan to attempt to gather the needed metadata:

  • Look first in __init__.py within the directory. This is the conventional place to put such metadata.
  • Iterate over the remaining *.py files until both version and repo matches are found in a single file.
  • Stop as soon as something valid is found.
  • If nothing is found, report this as a problem module (and in the meantime, report this to the upstream maintainer).

Extracting __version__ value from .mpy

If you run strings on a .mpy, you can find the version number close to __version__. It seems to be always just before, but I haven't done an extensive check, e.g.

$ strings neopixel.mpy
...
neopixel_write
neopixel_write
3.3.7
__version__
__repo__
...

Handle default branch name properly

The name of the default branch can change. Currently many use master. Many people are switching to main.
Ideally we can handle it being anything.

This affects the url used to retrieve the requirements.txt file in libraries_from_requirements().

Add a command to install modules from requirements file

It would be useful to track required libraries for a project with a library requirements file, like requirements.txt. Maybe this could be added to the existing install function with an -r option that takes a file name. This would install all of the libraries to the device. circup install -r requirements.txt

Additionally an option could be added to freeze to save the output to a requirements file. Otherwise, could just document to use the normal direct output to the file. circup freeze -r requirements.txt

Release Failed with 400 - File already exists

Capturing this issue...

HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
NOTE: Try --verbose to see response content.
File already exists. See https://pypi.org/help/#file-name-reuse for more information.

Initial investigation:

  1. This release action is the same as Blinka, so its probably not the definition of the action
  2. @kattni Since this has not been released since August and its not happening automatically... could the username\password in Github secrets be incorrect?

Read the docs setup and Badges in README

@kattni can you (or can you ask the right person) to setup read the docs for circup?

If this was a library, the url would probably be something like https://circuitpython.readthedocs.io/projects/circup/en/latest/ but just let me know what will be and then I'll add all the badges (build, RTD, etc..) to the README.

Minimum supported version of Python?

@Limor I'm assuming Python 3 (specifically Python 3.5 or 3.6 -- which one?) as the minimum Python requirement for the circup utility.

While I'm happy to make appropriate changes so this works with Python 2, I'm not sure it's really useful nor helpful since Python 2's EOL is 1st January 2020 (less than four months away). ;-)

crash on macos due to extended attribute files (._*)

When running circup on macOS 10.15.7, with python 3.8, I encounter the following error:

โฏ circup update --all
Found device at /Volumes/CIRCUITPY, running CircuitPython 6.0.1.
Found 1 module[s] needing update.
Something went wrong, [Errno 2] No such file or directory: '.___init__.mpy' (check the logs)

From the log file:

12/29/2020 14:54:12 ERROR: [Errno 2] No such file or directory: '.___init__.mpy'
Traceback (most recent call last):
  File "/Users/spyro/Library/Python/3.8/lib/python/site-packages/circup.py", line 695, in update
    module.update()
  File "/Users/spyro/Library/Python/3.8/lib/python/site-packages/circup.py", line 175, in update
    shutil.rmtree(self.path)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 715, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 672, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 670, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: '.___init__.mpy'

Which seems to be a general problem with shutil.rmtree:

>>> import shutil
>>> shutil.rmtree("/Volumes/CIRCUITPY/lib/adafruit_display_text/")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 715, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 672, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/shutil.py", line 670, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: '.___init__.mpy'

The extended attribute files are not created by circup, but is there if you copied the modules to the board manually in the past. It would be better if circup did not choke on them.

I fixed it for me by using: shutil.rmtree(temp_dir, ignore_errors=True) everywhere rmtree is used, but I don't know if that's the appropriate way to do that, or what other genuine errors it might hide, or if I'm the only one with the problem, or if it's a matter of python version or...

logger string formatting type errors

Running circup.py commands under python 3.7 on Win7 I end up with a bunch of errors like this printed:

Message: 'Current library bundle up to date ({}).'
Arguments: ('20200801',)
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\o_O\AppData\Local\Programs\Python\Python37-32\lib\logging\__init__.py", line 983, in emit
    msg = self.format(record)
  File "C:\Users\o_O\AppData\Local\Programs\Python\Python37-32\lib\logging\__init__.py", line 829, in format
    return fmt.format(record)
  File "C:\Users\o_O\AppData\Local\Programs\Python\Python37-32\lib\logging\__init__.py", line 569, in format
    record.message = record.getMessage()
  File "C:\Users\o_O\AppData\Local\Programs\Python\Python37-32\lib\logging\__init__.py", line 331, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting

that all point back to lines of code in circup like logger.info("some string {}", some_var).

It seems that the logger module is not using the new style template replacements {} but instead may be expecting %s. This answer on Stack overflow points the issue and solution: https://stackoverflow.com/a/12843139/507810

Ask users if an out of date module should be updated in place.

If the utility finds an out-of-date module the user should be presented with a yes/no option to update the module (involving the download of the module / zipped directory to be used to replace what's currently on the device). It'll probably look something like:

Update module "adafruit_fxas21002c"? [y/N] Y
Downloading... Copying... Done.
Update module "adafruit_gc_iot_core"? [y/N] N
Skipping "adafruit_fxas21002c".

etc...

DUNDER_ASSIGN_RE method for determining __repo__ in extract_metadata() does not work on multi-line values

The way extract_metadata() walks a .py file assumes all dunder values are on the same line as the variable name does not work if the repo url is long enough that black reformats it and wrap with parenthesis.

So far, I've only seen this with 1 library:

__version__ = "2.0.4"
__repo__ = (
    "https://github.com/adafruit/Adafruit_CircuitPython_BLE_BerryMed_Pulse_Oximeter.git"
)

I wonder if we can't import __repo__ and __version__ or the whole library and get all the dunder globals... but I've not thought about it much yet.

Error while running CircUp Show during bundle release

I kind of got lucky finding this one. At the time I ran it, the release had been created, but the bundle asset hadn't been finished being generated.

bash-3.2$ circup show
Found device at /Volumes/CIRCUITPY, running CircuitPython 5.0.0-alpha.4.
Downloading latest version information.

Traceback (most recent call last):
  File "/usr/local/bin/circup", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/circup.py", line 719, in show
    available_modules = get_bundle_versions()
  File "/usr/local/lib/python3.7/site-packages/circup.py", line 403, in get_bundle_versions
    ensure_latest_bundle()
  File "/usr/local/lib/python3.7/site-packages/circup.py", line 505, in ensure_latest_bundle
    get_bundle(tag)
  File "/usr/local/lib/python3.7/site-packages/circup.py", line 547, in get_bundle
    r.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/download/20191029/adafruit-circuitpython-bundle-py-20191029.zip

Dependency issue when installing adafruit_nunchuk

I run 'circup install adafruit_nunchuk' on a blank QT Py and it doesn't install adafruit_bus_device. It returns

Found device at /media/ghampton/CIRCUITPY, running CircuitPython 6.1.0.
Searching for dependencies for: ['adafruit_nunchuk']
Ready to install: ['adafruit_nunchuk']

Installed 'adafruit_nunchuk'.

and the serial out on the QT Py shows

Traceback (most recent call last):
  File "code.py", line 6, in <module>
  File "adafruit_nunchuk.py", line 30, in <module>
ImportError: no module named 'adafruit_bus_device'

Code done running.

Give users a warning if new version of library is a major semver change

When we release new major versions of libraries such as 1.2.3 => 2.0.0, it is often because there were potential or definite code-breaking changes. It would be awesome if users could be warned and possibly ask for confirmation in such a case so they aren't scratching their heads about why their code suddenly isn't working.

Error when trying to run

I am trying to run and get an error

There was a problem downloading the bundle. Please try again in a moment.

I am running macOS 11.2

Detect and output script dependencies

A recent feature request for learn.adafruit.com was to automatically detect and bundle any library dependencies for a CircuitPython script as part of the download.

An example would be for the script found here:
https://learn.adafruit.com/adafruit-ultimate-gps/circuitpython-python-uart-usage#example-parsing-code-3003973-6

We'd want to know that adafruit_gps is utilized, but also any adafruit libraries that adafruit_gps imports.

I'm not sure if it's feasible, but I'm hoping something like circup dependencies project.py would be something that would be possible as a new feature.

The only alternative I've found that can get me close to this functionality is the findimports project.

This would also likely be dependent on #68 as we wouldn't want to run this on a connected board.

no output when running

hiya i tried running python circup.py list and there's no output. i tried on win10 and mac OS with the feather m0 plugged in and some libraries on it

image

please add output to tell me if a board was detected or not, or what point it stopped :)

Add logging functionality to the tool

In the first instance this is "human friendly" logging. Perhaps allow for a --verbose flag so the user can see exactly what's going on, otherwise emit to a .circup.log file in the user's home (or some other sensible equivalent, depending on the OS).

cc/@ladyada

Install dependencies

When you are installing one package it may also have other dependencies called out, install those as well.

Not sure how this will work yet, but is the next thing that messes me up in my own workflow where I'm having to get one package then another package.

Not included: uninstall dependencies. Pip doesn't even do that yet.

Bad version strings make circup crash

โฏ circup --path /Volumes/UMFS2/ list
Found device at /Volumes/UMFS2/, running CircuitPython 6.1.0.
A newer version of CircuitPython (6.2.0-beta.0) is available.
Traceback (most recent call last):
  File "circup.py", line 1054, in <module>
    main()
  File "/Library/Python/3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Library/Python/3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Python/3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "circup.py", line 881, in list
    modules = [m.row for m in find_modules(ctx.obj["DEVICE_PATH"]) if m.outofdate]
  File "circup.py", line 881, in <listcomp>
    modules = [m.row for m in find_modules(ctx.obj["DEVICE_PATH"]) if m.outofdate]
  File "circup.py", line 193, in row
    major_update = str(self.major_update)
  File "circup.py", line 174, in major_update
    == VersionInfo.parse(self.bundle_version).major
  File "/Users/spyro/Library/Python/3.8/lib/python/site-packages/semver.py", line 726, in parse
    raise ValueError("%s is not valid SemVer string" % version)
ValueError: v3.3.0 is not valid SemVer string

The culprint is adafruit_si7021 whose bundle version string is v3.3.0.
Also looking at all the version strings pulled from the latest bundle, adafruit_rplidar has 0.0.1-auto.0 and makes circup crash too.
Every other modules follows the 1.2.3 format.

I guess fixing the tag in Adafruit_CircuitPython_SI7021 is the simplest way to fix that, but we may want to make circup more resilient to that kind of issue.
https://github.com/adafruit/Adafruit_CircuitPython_SI7021/tags

I wonder why adafruit_rplidar has a wrong version (latest release is 1.1.4)
https://github.com/adafruit/Adafruit_CircuitPython_RPLIDAR/tags

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.