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
Use a recursive iglob for filesets #765
Changes from 4 commits
cb2265a
6148f6c
6417d04
4d00a59
7ad6a05
2494aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,13 @@ | |
|
||
import contextlib | ||
import filecmp | ||
import glob | ||
import importlib | ||
import itertools | ||
import logging | ||
import os | ||
import shutil | ||
import sys | ||
from glob import iglob | ||
|
||
import jsonschema | ||
import magic | ||
|
@@ -756,7 +756,8 @@ def _generate_include_set(directory, includes): | |
include_files = set() | ||
for include in includes: | ||
if '*' in include: | ||
matches = glob.glob(os.path.join(directory, include)) | ||
pattern = os.path.join(directory, include) | ||
matches = iglob(pattern, recursive=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kyrofa it should be. We go over the list only when making it a set on the line below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which means you evaluate them all immediately anyway, right? I don't see the difference between this and |
||
include_files |= set(matches) | ||
else: | ||
include_files |= set([os.path.join(directory, include), ]) | ||
|
@@ -782,7 +783,8 @@ def _generate_exclude_set(directory, excludes): | |
exclude_files = set() | ||
|
||
for exclude in excludes: | ||
matches = glob.glob(os.path.join(directory, exclude)) | ||
pattern = os.path.join(directory, exclude) | ||
matches = iglob(pattern, recursive=True) | ||
exclude_files |= set(matches) | ||
|
||
exclude_dirs = [os.path.relpath(x, directory) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,11 +124,7 @@ def build(self): | |
self.run(['make', '-j{}'.format(self.parallel_build_count)]) | ||
self.run(make_install_command) | ||
|
||
# Remove .la files which don't work when they are moved around | ||
self._remove_la_files() | ||
|
||
def _remove_la_files(self): | ||
for root, _, files in os.walk(self.installdir): | ||
for file_name in files: | ||
if file_name.endswith('.la'): | ||
os.unlink(os.path.join(root, file_name)) | ||
def snap_fileset(self): | ||
fileset = super().snap_fileset() | ||
fileset.append('-**/*.la') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please copy the comment: Remove .la files which don't work when they are moved around |
||
return fileset |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,18 +206,8 @@ def build(self): | |
def snap_fileset(self): | ||
fileset = super().snap_fileset() | ||
fileset.append('-usr/bin/pip*') | ||
fileset.append('-usr/lib/python*/dist-packages/easy-install.pth') | ||
fileset.append('-usr/lib/python*/dist-packages/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*/*.pyc') | ||
fileset.append('-**/*.pth') | ||
fileset.append('-**/*.pyc') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A coment on why are you removing them would be nice here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually pleases me more than the previous PR, as I don't feel like we're fighting snapcraft here. |
||
return fileset | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,14 +184,6 @@ def python_version(self): | |
def snap_fileset(self): | ||
fileset = super().snap_fileset() | ||
fileset.append('-usr/bin/pip*') | ||
fileset.append('-usr/lib/python*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
fileset.append('-**/*.pth') | ||
fileset.append('-**/__pycache__') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, lovely indeed. Thank you for the comments as well. |
||
return fileset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails, it might be much easier to digest an error based on the length of the lists rather than directly comparing their contents (it'll print the lists, right?). You could still print the list in the failure message if you wanted.