Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix glob_paths to correctly include .kv files in package #1730

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
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.

1 participant