Skip to content

Conversation

@koala-sloth
Copy link

@koala-sloth koala-sloth commented Aug 30, 2024

  • Modified glob_paths function to properly identify files with given extensions
  • Now correctly traverses subdirectories and returns relative file paths
  • Fixes issue where .kv files were missing from pip installations
  • Also affects .pot and .po files, ensuring all necessary files are included

Description of the problem:
The glob_paths function in setup.py was not correctly identifying .kv files (and potentially .pot and .po files) in the KivyMD project structure. This led to these files being excluded from the built package, causing issues for users who installed KivyMD via pip.

Algorithm of actions that leads to the problem:

Run python3 setup.py
The glob_paths function is called to find .kv files
The function returns a list of directory names instead of file paths
The setup process doesn't include the .kv files in the package

Reproducing the problem:

# In setup.py, add this line before the setup() call:
print(f"kv files: {glob_paths('.kv')}")

# Then run:
python3 setup.py

# This outputs:
# kv files: ['KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/', 'KivyMD/']

Screenshots of the problem:
This is text-only, part of building python package, screenshots not needed.

Description of Changes:
We modified the glob_paths function in setup.py to correctly identify files with the given extension in all subdirectories of the 'kivymd' folder. The key changes were:

Changed the condition to check for files (not directories) that end with the given pattern.
Used os.path.relpath() to get the path relative to the 'kivymd' directory.
Simplified error handling to catch any ValueError that might occur.

Code for testing new changes:

# In setup.py, add this line before the setup() call:
print(f"kv files: {glob_paths('.kv')}")

# Then run:
python3 setup.py

# This should now output a list of actual .kv file paths, like:
# kv files: ['uix/imagelist/imagelist.kv', 'uix/appbar/appbar.kv', ...]

- Modified glob_paths function to properly identify files with given extensions
- Now correctly traverses subdirectories and returns relative file paths
- Fixes issue where .kv files were missing from pip installations
- Also affects .pot and .po files, ensuring all necessary files are included
@Novfensec
Copy link
Contributor

I also found kv files missing after doing an iOS build with kivy_ios.

To counter that a friend of mine made a recipe for KivyMD in kivy_ios;

# pure-python package, this can be removed when we'll support any python package
from kivy_ios.toolchain import PythonRecipe, shprint
from os.path import join
import sh
import os


class KivyMDRecipe(PythonRecipe):
    version = "2.0.1"
    url = "https://github.com/kivymd/KivyMD/archive/master.zip"
    depends = ["python"]

    def install(self):
        plat = list(self.platforms_to_build)[0]
        build_dir = self.get_build_dir(plat)
        os.chdir(build_dir)
        hostpython = sh.Command(self.ctx.hostpython)
        build_env = plat.get_env()
        dest_dir = join(self.ctx.dist_dir, "root", "python3")
        build_env['PYTHONPATH'] = self.ctx.site_packages_dir
        shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)



recipe = KivyMDRecipe()

For now we are forcing it to master version by default as its not yet released.
But this builds KivyMD with all kv files on iOS.

There is no pull made for this as it's expected to be resolved in the library itself.

@HeaTTheatR
Copy link
Member

I also found kv files missing after doing an iOS build with kivy_ios.

To counter that a friend of mine made a recipe for KivyMD in kivy_ios;

I've built several iOS apps and never seen the bug you're talking about.

@Novfensec
Copy link
Contributor

Novfensec commented May 24, 2025

He told me this (macOS 15). We used a custom fork of kivy_ios to be compatible with buildozer. The error was same as above described. If that's not an issue it's awesome. 👍

@Novfensec
Copy link
Contributor

I also found kv files missing after doing an iOS build with kivy_ios.

To counter that a friend of mine made a recipe for KivyMD in kivy_ios;

I've built several iOS apps and never seen the bug you're talking about.

I figured it out. He bundled it explicitly inside the app directory. It only happens in this case. Thanks for clarification.

#1722

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants