diff --git a/circup/command_utils.py b/circup/command_utils.py index 1aab0b7..fc8e483 100644 --- a/circup/command_utils.py +++ b/circup/command_utils.py @@ -721,7 +721,9 @@ def get_all_imports( # pylint: disable=too-many-arguments,too-many-locals, too- "/" )[:-1] ) + full_location = os.path.join(file_location, file_name) + except TypeError: # file is in root of CIRCUITPY full_location = file_name @@ -729,7 +731,7 @@ def get_all_imports( # pylint: disable=too-many-arguments,too-many-locals, too- exists = backend.file_exists(full_location) if not exists: file_name = os.path.join(*install_module.split("."), "__init__.py") - full_location = os.path.join(file_location, file_name) + full_location = file_name exists = backend.file_exists(full_location) if not exists: continue diff --git a/tests/mock_device/apps/test_app/import_styles.py b/tests/mock_device/apps/test_app/import_styles.py new file mode 100644 index 0000000..fc78e23 --- /dev/null +++ b/tests/mock_device/apps/test_app/import_styles.py @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2021 Jeff Epler for Adafruit Industries +# +# SPDX-License-Identifier: MIT +# pylint: disable=all +import os, sys +import adafruit_bus_device +from adafruit_button import Button +from adafruit_esp32spi import adafruit_esp32spi_socketpool +from adafruit_display_text import wrap_text_to_pixels, wrap_text_to_lines +import adafruit_hid.consumer_control +import import_styles_sub diff --git a/tests/mock_device/apps/test_app/import_styles_sub.py b/tests/mock_device/apps/test_app/import_styles_sub.py new file mode 100644 index 0000000..99cab83 --- /dev/null +++ b/tests/mock_device/apps/test_app/import_styles_sub.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2025 Neradoc +# +# SPDX-License-Identifier: MIT +# pylint: disable=all +import adafruit_ntp diff --git a/tests/mock_device/boot_out.txt b/tests/mock_device/boot_out.txt index e829b9d..38172a5 100644 --- a/tests/mock_device/boot_out.txt +++ b/tests/mock_device/boot_out.txt @@ -1,3 +1,3 @@ -Adafruit CircuitPython 10.0.0-alpha.6 on 2019-08-02; Adafruit CircuitPlayground Express with samd21g18 +Adafruit CircuitPython 9.0.0 on 2019-08-02; Adafruit CircuitPlayground Express with samd21g18 Board ID:this_is_a_board UID:AAAABBBBCCCC diff --git a/tests/mock_device/import_styles.py b/tests/mock_device/import_styles.py new file mode 100644 index 0000000..fc78e23 --- /dev/null +++ b/tests/mock_device/import_styles.py @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2021 Jeff Epler for Adafruit Industries +# +# SPDX-License-Identifier: MIT +# pylint: disable=all +import os, sys +import adafruit_bus_device +from adafruit_button import Button +from adafruit_esp32spi import adafruit_esp32spi_socketpool +from adafruit_display_text import wrap_text_to_pixels, wrap_text_to_lines +import adafruit_hid.consumer_control +import import_styles_sub diff --git a/tests/mock_device_2/boot_out.txt b/tests/mock_device_2/boot_out.txt index 55feaff..38172a5 100644 --- a/tests/mock_device_2/boot_out.txt +++ b/tests/mock_device_2/boot_out.txt @@ -1,3 +1,3 @@ -Adafruit CircuitPython 8.1.0 on 2019-08-02; Adafruit CircuitPlayground Express with samd21g18 +Adafruit CircuitPython 9.0.0 on 2019-08-02; Adafruit CircuitPlayground Express with samd21g18 Board ID:this_is_a_board UID:AAAABBBBCCCC diff --git a/tests/mock_device_2/import_styles_sub.py b/tests/mock_device_2/import_styles_sub.py new file mode 100644 index 0000000..99cab83 --- /dev/null +++ b/tests/mock_device_2/import_styles_sub.py @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2025 Neradoc +# +# SPDX-License-Identifier: MIT +# pylint: disable=all +import adafruit_ntp diff --git a/tests/test_circup.py b/tests/test_circup.py index b21061d..95e68c0 100644 --- a/tests/test_circup.py +++ b/tests/test_circup.py @@ -1186,7 +1186,11 @@ def test_get_all_imports(): test_data = fp.read() result = get_all_imports( - backend, test_data, test_file, mod_names, current_module="" + backend, + test_data, + os.path.join(backend.device_location, "import_styles.py"), + mod_names, + current_module="", ) assert result == [ @@ -1215,7 +1219,7 @@ def test_libraries_from_auto_file_local(): "adafruit_ntp", ] - auto_file = "./tests/import_styles.py" + auto_file = "apps/test_app/import_styles.py" with mock.patch("circup.logger.info") as mock_logger, mock.patch( "circup.os.path.isfile", return_value=True @@ -1267,6 +1271,7 @@ def test_libraries_from_auto_file_board(): result = libraries_from_auto_file(backend, auto_file, mod_names) assert result == [ + "adafruit_ntp", "adafruit_spd1608", "adafruit_spd1656", "adafruit_ssd1675",