circup 2.2.2__py3-none-any.whl → 2.2.4__py3-none-any.whl
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.
- circup/command_utils.py +41 -7
- circup/commands.py +22 -0
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/METADATA +1 -1
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/RECORD +8 -8
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/WHEEL +1 -1
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/entry_points.txt +0 -0
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/licenses/LICENSE +0 -0
- {circup-2.2.2.dist-info → circup-2.2.4.dist-info}/top_level.txt +0 -0
circup/command_utils.py
CHANGED
|
@@ -673,14 +673,15 @@ def imports_from_code(full_content):
|
|
|
673
673
|
return sorted(imports)
|
|
674
674
|
|
|
675
675
|
|
|
676
|
-
def get_all_imports(
|
|
677
|
-
backend, auto_file_content, mod_names, current_module, visited=None
|
|
676
|
+
def get_all_imports( # pylint: disable=too-many-arguments,too-many-locals, too-many-branches
|
|
677
|
+
backend, auto_file_content, auto_file_path, mod_names, current_module, visited=None
|
|
678
678
|
):
|
|
679
679
|
"""
|
|
680
680
|
Recursively retrieve imports from files on the backend
|
|
681
681
|
|
|
682
682
|
:param Backend backend: The current backend object
|
|
683
683
|
:param str auto_file_content: Content of the python file to analyse
|
|
684
|
+
:param str auto_file_path: Path to the python file to analyse
|
|
684
685
|
:param list mod_names: Lits of supported bundle mod names
|
|
685
686
|
:param str current_module: Name of the call context module if recursive call
|
|
686
687
|
:param set visited: Modules previously visited
|
|
@@ -714,18 +715,37 @@ def get_all_imports(
|
|
|
714
715
|
install_module = install
|
|
715
716
|
# possible files for the module: .py or __init__.py (if directory)
|
|
716
717
|
file_name = os.path.join(*install_module.split(".")) + ".py"
|
|
717
|
-
|
|
718
|
+
try:
|
|
719
|
+
file_location = os.path.join(
|
|
720
|
+
*auto_file_path.replace(str(backend.device_location), "").split(
|
|
721
|
+
"/"
|
|
722
|
+
)[:-1]
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
full_location = os.path.join(file_location, file_name)
|
|
726
|
+
|
|
727
|
+
except TypeError:
|
|
728
|
+
# file is in root of CIRCUITPY
|
|
729
|
+
full_location = file_name
|
|
730
|
+
|
|
731
|
+
exists = backend.file_exists(full_location)
|
|
718
732
|
if not exists:
|
|
719
733
|
file_name = os.path.join(*install_module.split("."), "__init__.py")
|
|
720
|
-
|
|
734
|
+
full_location = file_name
|
|
735
|
+
exists = backend.file_exists(full_location)
|
|
721
736
|
if not exists:
|
|
722
737
|
continue
|
|
723
738
|
install_module += ".__init__"
|
|
724
739
|
# get the content and parse it recursively
|
|
725
|
-
auto_file_content = backend.get_file_content(
|
|
740
|
+
auto_file_content = backend.get_file_content(full_location)
|
|
726
741
|
if auto_file_content:
|
|
727
742
|
sub_imports = get_all_imports(
|
|
728
|
-
backend,
|
|
743
|
+
backend,
|
|
744
|
+
auto_file_content,
|
|
745
|
+
auto_file_path,
|
|
746
|
+
mod_names,
|
|
747
|
+
install_module,
|
|
748
|
+
visited,
|
|
729
749
|
)
|
|
730
750
|
requested_installs.extend(sub_imports)
|
|
731
751
|
|
|
@@ -775,7 +795,9 @@ def libraries_from_auto_file(backend, auto_file, mod_names):
|
|
|
775
795
|
# from file name to module name (in case it's in a subpackage)
|
|
776
796
|
click.secho(f"Finding imports from: {auto_file}", fg="green")
|
|
777
797
|
current_module = auto_file.rstrip(".py").replace(os.path.sep, ".")
|
|
778
|
-
return get_all_imports(
|
|
798
|
+
return get_all_imports(
|
|
799
|
+
backend, auto_file_content, auto_file, mod_names, current_module
|
|
800
|
+
)
|
|
779
801
|
|
|
780
802
|
|
|
781
803
|
def get_device_path(host, port, password, path):
|
|
@@ -819,3 +841,15 @@ def sorted_by_directory_then_alpha(list_of_files):
|
|
|
819
841
|
sorted_full_list.append(files[cur_name])
|
|
820
842
|
|
|
821
843
|
return sorted_full_list
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
def is_virtual_env_active():
|
|
847
|
+
"""
|
|
848
|
+
Check if a virtual environment is currently active.
|
|
849
|
+
|
|
850
|
+
We don't check the more commonly recommended way of checking if
|
|
851
|
+
sys.prefix != sys.base_prefix as this will always be true if running circup
|
|
852
|
+
from a pipx install. This way ensures the user manually activated a
|
|
853
|
+
virtual environment, regardless how circup is installed.
|
|
854
|
+
"""
|
|
855
|
+
return "VIRTUAL_ENV" in os.environ
|
circup/commands.py
CHANGED
|
@@ -41,6 +41,7 @@ from circup.command_utils import (
|
|
|
41
41
|
get_bundles_dict,
|
|
42
42
|
completion_for_example,
|
|
43
43
|
get_bundle_examples,
|
|
44
|
+
is_virtual_env_active,
|
|
44
45
|
)
|
|
45
46
|
|
|
46
47
|
|
|
@@ -354,6 +355,7 @@ def install(
|
|
|
354
355
|
device_modules = ctx.obj["backend"].get_device_versions()
|
|
355
356
|
if to_install is not None:
|
|
356
357
|
to_install = sorted(to_install)
|
|
358
|
+
is_global_install_ok = None
|
|
357
359
|
click.echo(f"Ready to install: {to_install}\n")
|
|
358
360
|
for library in to_install:
|
|
359
361
|
ctx.obj["backend"].install_module(
|
|
@@ -366,6 +368,26 @@ def install(
|
|
|
366
368
|
)
|
|
367
369
|
|
|
368
370
|
if stubs:
|
|
371
|
+
# Check we are in a virtual environment
|
|
372
|
+
if not is_virtual_env_active():
|
|
373
|
+
if is_global_install_ok is None:
|
|
374
|
+
click.secho(
|
|
375
|
+
(
|
|
376
|
+
"No virtual environment detected.\n"
|
|
377
|
+
"It is recommended to run circup inside a virtual environment "
|
|
378
|
+
"when installing stubs. Without a virtual environment, the stubs "
|
|
379
|
+
"will be installed to the global python."
|
|
380
|
+
),
|
|
381
|
+
fg="yellow",
|
|
382
|
+
)
|
|
383
|
+
is_global_install_ok = click.confirm(
|
|
384
|
+
click.style(
|
|
385
|
+
"Would you still like to install stubs (to the global python)?",
|
|
386
|
+
fg="yellow",
|
|
387
|
+
)
|
|
388
|
+
)
|
|
389
|
+
if not is_global_install_ok:
|
|
390
|
+
continue
|
|
369
391
|
library_stubs = "adafruit-circuitpython-{}".format(
|
|
370
392
|
library.replace("adafruit_", "")
|
|
371
393
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
circup/__init__.py,sha256=9A98U3DyA14tm-7_d88fGSlLfEKz9T_85t8kXkErqRg,662
|
|
2
2
|
circup/backends.py,sha256=g9Q9xCGZidwsEDL2Ga2cm50YYB54IiqlKUPcxj-pWZA,40008
|
|
3
3
|
circup/bundle.py,sha256=FEP4F470aJtwmm8jgTM3DgR3dj5SVwbX1tbyIRKVHn8,5327
|
|
4
|
-
circup/command_utils.py,sha256=
|
|
5
|
-
circup/commands.py,sha256=
|
|
4
|
+
circup/command_utils.py,sha256=FNEhTYbbCT9UzKv4NG5lhbWHlObSEl4DQ7iDd8O0-cs,30581
|
|
5
|
+
circup/commands.py,sha256=jrgJDmqx4U1K--_OnZoOt1d9n1QRNnInK_nBeWrThMw,28542
|
|
6
6
|
circup/logging.py,sha256=hu4v8ljkXo8ru-cqs0W3PU-xEVvTO_qqMKDJM18OXbQ,1115
|
|
7
7
|
circup/module.py,sha256=33_kdy5BZn6COyIjAFZMpw00rTtPiryQZWFXQkMF8FY,7435
|
|
8
8
|
circup/shared.py,sha256=IBW3v0rry1wLr8yR8_xHfe0QC5SFGzv6bdnPv96vZaM,8944
|
|
@@ -12,9 +12,9 @@ circup/wwshell/README.rst,sha256=M_jFP0hwOcngF0RdosdeqmVOISNcPzyjTW3duzIu9A8,361
|
|
|
12
12
|
circup/wwshell/README.rst.license,sha256=GhA0SoZGP7CReDam-JJk_UtIQIpQaZWQFzR26YSuMm4,107
|
|
13
13
|
circup/wwshell/__init__.py,sha256=CAPZiYrouWboyPx4KiWLBG_vf_n0MmArGqaFyTXGKWk,398
|
|
14
14
|
circup/wwshell/commands.py,sha256=-I5l7XeoDmvWWuZg5wHdt9qe__SBQ1EGmKwCDTBMeus,7454
|
|
15
|
-
circup-2.2.
|
|
16
|
-
circup-2.2.
|
|
17
|
-
circup-2.2.
|
|
18
|
-
circup-2.2.
|
|
19
|
-
circup-2.2.
|
|
20
|
-
circup-2.2.
|
|
15
|
+
circup-2.2.4.dist-info/licenses/LICENSE,sha256=bVlIMmSL_pqLCqae4hzixy9pYXD808IbgsMoQXTNLBk,1076
|
|
16
|
+
circup-2.2.4.dist-info/METADATA,sha256=DmXRgPwq1G5-zZoilQRa6vtK1eP3clouiQy4LOt0teA,13617
|
|
17
|
+
circup-2.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
18
|
+
circup-2.2.4.dist-info/entry_points.txt,sha256=FjTmwYD_ApgLRGifUrr_Ui1voW6fEzodQc3DKNzoAPc,69
|
|
19
|
+
circup-2.2.4.dist-info/top_level.txt,sha256=Qx6E0eZgSBE10ciNKsLZx8-TTy_9fEVZh7NLmn24KcU,7
|
|
20
|
+
circup-2.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|