[issue31072] add filter to zipapp

2017-08-26 Thread Paul Moore

Paul Moore added the comment:


New changeset 0780bf7578dc4c9c3852dc5e869aba515a2c65b1 by Paul Moore in branch 
'master':
bpo-31072: Rename the new filter argument for zipapp.create_archive. (#3049)
https://github.com/python/cpython/commit/0780bf7578dc4c9c3852dc5e869aba515a2c65b1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-26 Thread Paul Moore

Paul Moore added the comment:

OK. There's been no further comments, and I think the differences with 
PyZipFile's filterfunc are sufficient to warrant using a different name. I'm 
going to go with "filter". It's short, and says what it means.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-11 Thread Paul Moore

Paul Moore added the comment:

Sounds reasonable :-) I'm not going to be checking mails for a week or so, so 
I'll revisit this once I get back.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-11 Thread Brett Cannon

Brett Cannon added the comment:

What about simply 'filter' as a name? or 'path_filter'?

--
nosy: +brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-11 Thread Paul Moore

Paul Moore added the comment:

Zipapp uses path objects throughout, so making the filter function take a path 
object is consistent with that. I guess modifying PyZipFile to take either a 
string or a path object would be possible.

As for the relative path, that's deliberate as I expect that a common use case 
will be to exclude a directory, and doing that via

lambda pth: pth.parts[0] != 'dir_to_exclude'

is a simple possibility. Having to do this with an absolute path would just 
require the user to make the path relative, and we've already done that in 
zipapp so why duplicate the work?

So I guess I'm saying I want to keep both those choices. Do you think this is a 
sufficient problem that we should *not* use the same name? Any suggestions on a 
better name (or should we stick with the original ``include_file``)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There are two differences between filterfunc arguments in zipapp and PyZipFile:

1. An argument of filterfunc is a string in PyZipFile and a Path object in 
zipapp.

2. The patch in zipapp is relative to the root of the archive. The patch in 
PyZipFile is a path on FS (absolute or relative to the current working 
directory).

I afraid that these differences can cause confusions.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Paul Moore

Paul Moore added the comment:

I've created a new PR 3049 adding the fixes you suggested (and tightening up 
the tests, as I noticed an untested aspect of the change while editing).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Paul Moore

Changes by Paul Moore :


--
pull_requests: +3084

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Paul Moore

Paul Moore added the comment:

Good point - I wasn't even aware of the filterfunc argument in PyZipFile. I'll 
rename the argument.

I wasn't initially sure about a what's new entry. I'll add one - and thanks for 
the reminder about versionadded.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Wouldn't be better to name the parameter filterfunc for conformity with 
PyZipFile?

I think the new feature needs at least the versionadded directive in the module 
documentation. And may be an entry in the What's New document.

--
nosy: +serhiy.storchaka
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Paul Moore

Paul Moore added the comment:

Thanks to Jeffrey Rackauckas for the implementation of this feature.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-09 Thread Paul Moore

Paul Moore added the comment:


New changeset b811d664defed085d16951088afb579fb649c58d by Paul Moore (Jeffrey 
Rackauckas) in branch 'master':
bpo-31072: Add filter to zipapp (#3021)
https://github.com/python/cpython/commit/b811d664defed085d16951088afb579fb649c58d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-08-07 Thread Jeffrey Rackauckas

Changes by Jeffrey Rackauckas :


--
pull_requests: +3054

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-07-28 Thread Paul Moore

Paul Moore added the comment:

Yes, they can be.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-07-28 Thread Irmen de Jong

Irmen de Jong added the comment:

That sounds fine to me. I guess the paths passed to the function should be 
relative to the root folder being zipped?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-07-28 Thread Paul Moore

Paul Moore added the comment:

I'd propose an extra argument to zipapp.create_archive, include_file=None (feel 
free to bikeshed on the name). If the argument is not None, then it should be a 
callable which will be called with a pathlib.Path object for each file that's 
selected for inclusion in the archive. The function should return a boolean - 
False means don't include this file.

Because the create_archive function only gets a list of files internally (it 
uses Path.rglob()), the callable won't get passed directories, only the actual 
files (but it can of course check the full path to see what directory the file 
is in).

The include_file argument is ignored when copying anything other than a 
filesystem directory (i.e., when the source argument is a filename or an open 
file object).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31072] add filter to zipapp

2017-07-28 Thread Irmen de Jong

New submission from Irmen de Jong:

As briefly discussed on comp.lang.python, I propose to add an optional filter 
callback function to zipapp.create_archive.


The function could perhaps work like the os.walk generator or maybe just lets 
you to return a simple boolean for every folder/file that it wants to include 
in the zip.

My use case is that I sometimes don't want to include every file in the root 
folder into the zip file (I want to be able to skip temporary or irrelevant 
folders such as .git/.svn, .tox, .tmp and sometimes want to avoid including 
*.pyc/*.pyo files).  Right now, I first have to manually clean up the folder 
before I can use zipapp.create_archive.


(Instead of providing a filter callback fuction, another approach may be to 
provide your own dir/file generator instead, that fully replaces the internal 
file listing logic of zipapp.create_archive?)

--
assignee: paul.moore
components: Library (Lib)
keywords: easy
messages: 299409
nosy: irmen, paul.moore
priority: normal
severity: normal
status: open
title: add filter to zipapp
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com