Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Use a recursive iglob for filesets #765
Conversation
sergiusens
referenced this pull request
Aug 29, 2016
Closed
Use in plugin code to remove unwanted files. #754
sergiusens
added some commits
Aug 29, 2016
|
retest this please |
elopio
reviewed
Aug 30, 2016
| - os.unlink(os.path.join(root, file_name)) | ||
| + def snap_fileset(self): | ||
| + fileset = super().snap_fileset() | ||
| + fileset.append('-**/*.la') |
elopio
Aug 30, 2016
Member
Please copy the comment:
Remove .la files which don't work when they are moved around
elopio
reviewed
Aug 30, 2016
| - fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*.pyc') | ||
| - fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*/*.pyc') | ||
| + fileset.append('-**/*.pth') | ||
| + fileset.append('-**/*.pyc') |
elopio
reviewed
Aug 30, 2016
| - fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
| - fileset.append('-usr/lib/python*/*/*/*/*/*/*/*/*/*/__pycache__/*.pyc') | ||
| + fileset.append('-**/*.pth') | ||
| + fileset.append('-**/__pycache__') |
|
|
|
El 30/08/16 a las 00:49, Leo Arias escribió:
He said he was going to be happy with this one as well ;-) |
sergiusens
added some commits
Aug 30, 2016
kyrofa
reviewed
Aug 30, 2016
| + pth_files.extend([f for f in files if f.endswith('pth')]) | ||
| + | ||
| + self.assertEqual([], pyc_files) | ||
| + self.assertEqual([], pth_files) |
kyrofa
Aug 30, 2016
•
Member
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.
kyrofa
reviewed
Aug 30, 2016
| @@ -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) |
kyrofa
Aug 30, 2016
Member
glob.glob also accepts the recursive param. Is the switch to iglob performance-related?
sergiusens
Aug 30, 2016
Collaborator
@kyrofa it should be. We go over the list only when making it a set on the line below
kyrofa
Aug 30, 2016
Member
Which means you evaluate them all immediately anyway, right? I don't see the difference between this and glob for our usage anyway. That said, I don't have a problem with iglob, I was just curious for the reasoning behind the switch.
kyrofa
reviewed
Aug 30, 2016
| + # We use PYTHONPATH for everything so not needed. | ||
| + fileset.append('-**/*.pth') | ||
| + # This is a major cause of inter part conflict. | ||
| + fileset.append('-**/*.pyc') |
kyrofa
Aug 30, 2016
Member
This actually pleases me more than the previous PR, as I don't feel like we're fighting snapcraft here.
kyrofa
reviewed
Aug 30, 2016
| + fileset.append('-**/*.pth') | ||
| + # Holds all the .pyc files. It is a major cause of inter part | ||
| + # conflict. | ||
| + fileset.append('-**/__pycache__') |
|
Very nice! I made one ignorable suggestion, |
sergiusens
merged commit 2d7fc11
into
snapcore:master
Aug 30, 2016
sergiusens
deleted the
sergiusens:bugfix/1616464/better-fileset-globbing
branch
Aug 30, 2016
|
So this is actually a problem. Specifically with the .pth removal. There are several projects that I know of that have the .pth to (ab)use python importing. Here is a line from the dogpile.cache pth file that allows it to import from site-packages/dogpile/cache without having site-packages/dogpile/init.py
there are many such projects that do things like this unfortunately. |
|
El 22/09/16 a las 13:44, Sam Yaple escribió:
In your snapcraft.yaml, can you try to explicitly add it? |
|
Thats a silly thing to suggest. This was rather complicated to even figure out why it was broken. Even though I can add this file specifically in, this will lead many people to believe that python does not work well with snapcraft. Indeed, looking through the IRC logs show several cases where people are complaining about it not being able to import a package after this patch merged, I would bet at least some of those are this exact issue. Why is removing the pth file something that is even needed? |
|
El 22/09/16 a las 14:25, Sam Yaple escribió:
I am not saying we should keep it this way! :-)
I think this was just oversight |
|
Submitting a patch :) Not a big deal in the grand scheme of things. Shame i just missed 2.18 window though |
|
El 22/09/16 a las 14:29, Sam Yaple escribió:
don't worry, I am preparing 2.18.1 right now. |
sergiusens commentedAug 29, 2016
This adds support for
**in filesets for parts.LP: #1616464
Signed-off-by: Sergio Schvezov sergio.schvezov@ubuntu.com