circup 1.1.5__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {circup-1.1.5 → circup-1.2.0}/.pre-commit-config.yaml +3 -2
  2. {circup-1.1.5/circup.egg-info → circup-1.2.0}/PKG-INFO +1 -1
  3. {circup-1.1.5 → circup-1.2.0}/circup/__init__.py +39 -14
  4. {circup-1.1.5 → circup-1.2.0/circup.egg-info}/PKG-INFO +1 -1
  5. {circup-1.1.5 → circup-1.2.0}/circup.egg-info/SOURCES.txt +1 -0
  6. circup-1.2.0/tests/bad_python.py +6 -0
  7. {circup-1.1.5 → circup-1.2.0}/tests/test_circup.py +9 -0
  8. {circup-1.1.5 → circup-1.2.0}/.github/ISSUE_TEMPLATE.md +0 -0
  9. {circup-1.1.5 → circup-1.2.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  10. {circup-1.1.5 → circup-1.2.0}/.github/workflows/build.yml +0 -0
  11. {circup-1.1.5 → circup-1.2.0}/.github/workflows/release.yml +0 -0
  12. {circup-1.1.5 → circup-1.2.0}/.gitignore +0 -0
  13. {circup-1.1.5 → circup-1.2.0}/.pylintrc +0 -0
  14. {circup-1.1.5 → circup-1.2.0}/CODE_OF_CONDUCT.rst +0 -0
  15. {circup-1.1.5 → circup-1.2.0}/CODE_OF_CONDUCT.rst.license +0 -0
  16. {circup-1.1.5 → circup-1.2.0}/CONTRIBUTING.rst +0 -0
  17. {circup-1.1.5 → circup-1.2.0}/CONTRIBUTING.rst.license +0 -0
  18. {circup-1.1.5 → circup-1.2.0}/LICENSE +0 -0
  19. {circup-1.1.5 → circup-1.2.0}/LICENSES/CC-BY-4.0.txt +0 -0
  20. {circup-1.1.5 → circup-1.2.0}/LICENSES/MIT.txt +0 -0
  21. {circup-1.1.5 → circup-1.2.0}/LICENSES/Unlicense.txt +0 -0
  22. {circup-1.1.5 → circup-1.2.0}/README.rst +0 -0
  23. {circup-1.1.5 → circup-1.2.0}/README.rst.license +0 -0
  24. {circup-1.1.5 → circup-1.2.0}/circup/config/bundle_config.json +0 -0
  25. {circup-1.1.5 → circup-1.2.0}/circup/config/bundle_config.json.license +0 -0
  26. {circup-1.1.5 → circup-1.2.0}/circup.egg-info/dependency_links.txt +0 -0
  27. {circup-1.1.5 → circup-1.2.0}/circup.egg-info/entry_points.txt +0 -0
  28. {circup-1.1.5 → circup-1.2.0}/circup.egg-info/requires.txt +6 -6
  29. {circup-1.1.5 → circup-1.2.0}/circup.egg-info/top_level.txt +0 -0
  30. {circup-1.1.5 → circup-1.2.0}/docs/_static/favicon.ico +0 -0
  31. {circup-1.1.5 → circup-1.2.0}/docs/_static/favicon.ico.license +0 -0
  32. {circup-1.1.5 → circup-1.2.0}/docs/conf.py +0 -0
  33. {circup-1.1.5 → circup-1.2.0}/docs/index.rst +0 -0
  34. {circup-1.1.5 → circup-1.2.0}/docs/index.rst.license +0 -0
  35. {circup-1.1.5 → circup-1.2.0}/docs/logo.png +0 -0
  36. {circup-1.1.5 → circup-1.2.0}/docs/logo.png.license +0 -0
  37. {circup-1.1.5 → circup-1.2.0}/readthedocs.yml +0 -0
  38. {circup-1.1.5 → circup-1.2.0}/requirements.txt +0 -0
  39. {circup-1.1.5 → circup-1.2.0}/requirements.txt.license +0 -0
  40. {circup-1.1.5 → circup-1.2.0}/setup.cfg +0 -0
  41. {circup-1.1.5 → circup-1.2.0}/setup.py +0 -0
  42. {circup-1.1.5 → circup-1.2.0}/tests/__init__.py +0 -0
  43. {circup-1.1.5 → circup-1.2.0}/tests/bad_module/__init__.py +0 -0
  44. {circup-1.1.5 → circup-1.2.0}/tests/bad_module/my_module.py +0 -0
  45. {circup-1.1.5 → circup-1.2.0}/tests/bundle.json +0 -0
  46. {circup-1.1.5 → circup-1.2.0}/tests/bundle.json.license +0 -0
  47. {circup-1.1.5 → circup-1.2.0}/tests/device.json +0 -0
  48. {circup-1.1.5 → circup-1.2.0}/tests/device.json.license +0 -0
  49. {circup-1.1.5 → circup-1.2.0}/tests/dir_module/__init__.py +0 -0
  50. {circup-1.1.5 → circup-1.2.0}/tests/dir_module/my_module.py +0 -0
  51. {circup-1.1.5 → circup-1.2.0}/tests/import_styles.py +0 -0
  52. {circup-1.1.5 → circup-1.2.0}/tests/local_module.py +0 -0
  53. {circup-1.1.5 → circup-1.2.0}/tests/local_module_cp7.mpy +0 -0
  54. {circup-1.1.5 → circup-1.2.0}/tests/local_module_cp7.mpy.license +0 -0
  55. {circup-1.1.5 → circup-1.2.0}/tests/mount_exists.txt +0 -0
  56. {circup-1.1.5 → circup-1.2.0}/tests/mount_exists.txt.license +0 -0
  57. {circup-1.1.5 → circup-1.2.0}/tests/mount_missing.txt +0 -0
  58. {circup-1.1.5 → circup-1.2.0}/tests/mount_missing.txt.license +0 -0
  59. {circup-1.1.5 → circup-1.2.0}/tests/remote_module.py +0 -0
  60. {circup-1.1.5 → circup-1.2.0}/tests/test_bundle_config.json +0 -0
  61. {circup-1.1.5 → circup-1.2.0}/tests/test_bundle_config.json.license +0 -0
  62. {circup-1.1.5 → circup-1.2.0}/tests/test_bundle_config_local.json +0 -0
  63. {circup-1.1.5 → circup-1.2.0}/tests/test_bundle_config_local.json.license +0 -0
  64. {circup-1.1.5 → circup-1.2.0}/tests/test_module.mpy +0 -0
  65. {circup-1.1.5 → circup-1.2.0}/tests/test_module.mpy.license +0 -0
@@ -15,11 +15,12 @@ repos:
15
15
  - id: pylint
16
16
  name: lint (code)
17
17
  types: [python]
18
- exclude: "^(docs/|examples/|setup.py$)"
18
+ exclude: "^(docs/|examples/|setup.py$|tests/bad_python.py$)"
19
19
  - repo: https://github.com/python/black
20
20
  rev: 22.3.0
21
21
  hooks:
22
- - id: black
22
+ - id: black
23
+ exclude: "^tests/bad_python.py$"
23
24
  - repo: https://github.com/fsfe/reuse-tool
24
25
  rev: v0.14.0
25
26
  hooks:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: circup
3
- Version: 1.1.5
3
+ Version: 1.2.0
4
4
  Summary: A tool to manage/update libraries on CircuitPython devices.
5
5
  Home-page: https://github.com/adafruit/circup
6
6
  Author: Adafruit Industries
@@ -1056,7 +1056,15 @@ def libraries_from_imports(code_py, mod_names):
1056
1056
  :param str code_py: Full path of the code.py file
1057
1057
  :return: sequence of library names
1058
1058
  """
1059
- imports = [info.name.split(".", 1)[0] for info in findimports.find_imports(code_py)]
1059
+ # pylint: disable=broad-except
1060
+ try:
1061
+ found_imports = findimports.find_imports(code_py)
1062
+ except Exception as ex: # broad exception because anything could go wrong
1063
+ logger.exception(ex)
1064
+ click.secho('Unable to read the auto file: "{}"'.format(str(ex)), fg="red")
1065
+ sys.exit(2)
1066
+ # pylint: enable=broad-except
1067
+ imports = [info.name.split(".", 1)[0] for info in found_imports]
1060
1068
  return [r for r in imports if r in mod_names]
1061
1069
 
1062
1070
 
@@ -1290,23 +1298,32 @@ def list_cli(ctx): # pragma: no cover
1290
1298
  @click.argument(
1291
1299
  "modules", required=False, nargs=-1, shell_complete=completion_for_install
1292
1300
  )
1293
- @click.option("pyext", "--py", is_flag=True)
1294
- @click.option("-r", "--requirement", type=click.Path(exists=True, dir_okay=False))
1295
- @click.option("--auto/--no-auto", "-a/-A")
1296
- @click.option("--auto-file", default="code.py")
1301
+ @click.option(
1302
+ "pyext",
1303
+ "--py",
1304
+ is_flag=True,
1305
+ help="Install the .py version of the module(s) instead of the mpy version.",
1306
+ )
1307
+ @click.option(
1308
+ "-r",
1309
+ "--requirement",
1310
+ type=click.Path(exists=True, dir_okay=False),
1311
+ help="specify a text file to install all modules listed in the text file."
1312
+ " Typically requirements.txt.",
1313
+ )
1314
+ @click.option("--auto", "-a", help="Install the modules imported in code.py.")
1315
+ @click.option(
1316
+ "--auto-file",
1317
+ default=None,
1318
+ help="Specify the name of a file on the board to read for auto install."
1319
+ " Also accepts an absolute path or a local ./ path.",
1320
+ )
1297
1321
  @click.pass_context
1298
1322
  def install(ctx, modules, pyext, requirement, auto, auto_file): # pragma: no cover
1299
1323
  """
1300
1324
  Install a named module(s) onto the device. Multiple modules
1301
1325
  can be installed at once by providing more than one module name, each
1302
1326
  separated by a space.
1303
-
1304
- Option --py installs .py version of module(s).
1305
-
1306
- Option -r allows specifying a text file to install all modules listed in
1307
- the text file.
1308
-
1309
- Option -a installs based on the modules imported by code.py
1310
1327
  """
1311
1328
  # TODO: Ensure there's enough space on the device
1312
1329
  available_modules = get_bundle_versions(get_bundles_list())
@@ -1317,8 +1334,16 @@ def install(ctx, modules, pyext, requirement, auto, auto_file): # pragma: no co
1317
1334
  with open(requirement, "r", encoding="utf-8") as rfile:
1318
1335
  requirements_txt = rfile.read()
1319
1336
  requested_installs = libraries_from_requirements(requirements_txt)
1320
- elif auto:
1321
- auto_file = os.path.join(ctx.obj["DEVICE_PATH"], auto_file)
1337
+ elif auto or auto_file:
1338
+ if auto_file is None:
1339
+ auto_file = "code.py"
1340
+ # pass a local file with "./" or "../"
1341
+ is_relative = auto_file.split(os.sep)[0] in [os.path.curdir, os.path.pardir]
1342
+ if not os.path.isabs(auto_file) and not is_relative:
1343
+ auto_file = os.path.join(ctx.obj["DEVICE_PATH"], auto_file or "code.py")
1344
+ if not os.path.isfile(auto_file):
1345
+ click.secho(f"Auto file not found: {auto_file}", fg="red")
1346
+ sys.exit(1)
1322
1347
  requested_installs = libraries_from_imports(auto_file, mod_names)
1323
1348
  else:
1324
1349
  requested_installs = modules
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: circup
3
- Version: 1.1.5
3
+ Version: 1.2.0
4
4
  Summary: A tool to manage/update libraries on CircuitPython devices.
5
5
  Home-page: https://github.com/adafruit/circup
6
6
  Author: Adafruit Industries
@@ -36,6 +36,7 @@ docs/logo.png.license
36
36
  docs/_static/favicon.ico
37
37
  docs/_static/favicon.ico.license
38
38
  tests/__init__.py
39
+ tests/bad_python.py
39
40
  tests/bundle.json
40
41
  tests/bundle.json.license
41
42
  tests/device.json
@@ -0,0 +1,6 @@
1
+ # SPDX-FileCopyrightText: 2021 Jeff Epler for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ # pylint: disable=all
5
+
6
+ if True:
@@ -1030,3 +1030,12 @@ def test_libraries_from_imports():
1030
1030
  "adafruit_esp32spi",
1031
1031
  "adafruit_hid",
1032
1032
  ]
1033
+
1034
+
1035
+ def test_libraries_from_imports_bad():
1036
+ """Ensure that we catch an import error"""
1037
+ TEST_BUNDLE_MODULES = {"one.py": {}, "two.py": {}, "three.py": {}}
1038
+ runner = CliRunner()
1039
+ with mock.patch("circup.get_bundle_versions", return_value=TEST_BUNDLE_MODULES):
1040
+ result = runner.invoke(circup.install, ["--auto-file", "./tests/bad_python.py"])
1041
+ assert result.exit_code == 2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -9,16 +9,16 @@ update_checker
9
9
  importlib_metadata
10
10
 
11
11
  [all]
12
- twine
12
+ sphinx
13
13
  pytest-cov
14
- wheel
14
+ coverage
15
15
  pytest-random-order>=1.0.0
16
- pytest-faulthandler
17
- pylint
18
- sphinx
19
16
  black
20
17
  pytest
21
- coverage
18
+ pylint
19
+ twine
20
+ wheel
21
+ pytest-faulthandler
22
22
 
23
23
  [dev]
24
24
  pytest
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes