Comments (6)
Quietly ignoring a specific file on MacOS does not seem like the desirable behavior to me. Currently the bahavior of zipapp
is "pack everything", which is easy to understand. Changing it to "pack everything except for files with name .DS_Store
" is kind of weird. There are other commonly generated files, __pycache__
or .coverage
for example. Who should be the person to decide what's on the list and what's not?
To achieve your goal, the Python API zipapp.create_archive
provides a way to do it. You can use the argument filter
to filter the paths. It should be easy to create your own script to generate the zipapp file with customized filtering. I don't believe changing the default behavior is the correct direction.
I can, somehow, imagine a new option to ignore all hidden files, which is probably more generic to users.
And this is definitely not a bug, it's a feature request, so I'll change the lables.
from cpython.
If we plan to add a command line option to filter, I think we should avoid the name filter
, unless we can make it comparable to the filter
argument for create_archive
. The filter
argument is a function that returns a boolean indicating whether the path should be accepted. The only way I can think of to make the option filter
work is for it to pass in a regular expression that provides a pattern for all accepted paths (not declined, or it will have opposite meaning to the argument).
A better way might be --include
and --exclude
which is also commonly used to provide both allow-list and deny-list.
I'm a bit surprised that Finder will generate the file in the background (when it's not opened in the OS) though.
from cpython.
I do not agree. I think by default they should be excluded but there should be an option to include them.
from cpython.
Quietly ignoring a specific file on MacOS does not seem like the desirable behavior to me. Currently the bahavior of
zipapp
is "pack everything", which is easy to understand. Changing it to "pack everything except for files with name.DS_Store
" is kind of weird. There are other commonly generated files,__pycache__
or.coverage
for example. Who should be the person to decide what's on the list and what's not?To achieve your goal, the Python API
zipapp.create_archive
provides a way to do it. You can use the argumentfilter
to filter the paths. It should be easy to create your own script to generate the zipapp file with customized filtering. I don't believe changing the default behavior is the correct direction.I can, somehow, imagine a new option to ignore all hidden files, which is probably more generic to users.
And this is definitely not a bug, it's a feature request, so I'll change the lables.
agree 100%
from cpython.
Quietly ignoring a specific file on MacOS does not seem like the desirable behavior to me. Currently the bahavior of
zipapp
is "pack everything", which is easy to understand. Changing it to "pack everything except for files with name.DS_Store
" is kind of weird. There are other commonly generated files,__pycache__
or.coverage
for example. Who should be the person to decide what's on the list and what's not?
Adding a filter option to the zipapp command line interface could be useful, but as you write the hard bit is which name should be included in the default filter.
Two options (which could both be added)
python -m zipapp --filter GLOB ...
: Multi-use argument for specifying which names should be excluded (user needs to determine useful filters themselves)python -m zipapp --filter-junk ..
: Filter some commonly seen files that should generally not be included, such as.DS_Store
,__pycache__
and backup files (*~
,._*.swp
, ...).
The second option is a nicer user interface for users, but is harder to get right (both naming and which filters to include).
Currently the only API implements something similar to the second option is dircmp
, other APIs try to avoid the temptation to guess ;-).
from cpython.
The problem with the .DS_Store files (unlike other temporary junk mentioned here) is that they can come back randomly and quickly during the time the zippapp is created. E.g. I do run a cleanup before already after I noticed the issue with .DS_Store files ballooning the sizes of the generated archives:
find zipapptempdir -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete -o -type f -name '.DS_Store' -delete && \
python3.12 -m zipapp --output s3cmd.pyz --compress --python /usr/local/bin/python3.12 zipapptempdir
And in one case a .DS_Store file still managed to sneak into the archive. It's very hard to make this work reliable from a single user account. Maybe killing off Finder before, and then relaunching it afterwards or some other awkward kludge?
I'm reporting about the the zipapp app/module itself (as used in python3 -m zipapp
from a user perspective) and I'm perfectly fine with some --filter REGEX
or --reject GLOB
option, if that's more suitable than just default filtering out the .DS_Store
files. 👍
I would consider those files getting added as a privacy/security/ information leak issue (hence a bug report), e.g. when I plan to distribute generated zipapps to other users: they really don't need my .DS_Store files.
from cpython.
Related Issues (20)
- REPL: Ctrl-R and arrow key trips assertion HOT 2
- Sporadic failures in `test_int` `test_denial_of_service_prevented_str_to_int`
- Slight ElementTree serialization performance enhancement for trees with str tags
- urllib.parse.quote docstring has invalid reStructuredText markup HOT 3
- ePub error reported at [email protected]
- Avoid creating a StopIteration instance for monitoring HOT 1
- Inconsistent behaviour between `pathlib.PurePath.match` and `glob.glob` HOT 7
- Implement vectorcall for BaseException to optimize creation of exception instances
- Pathlib.Path.symlink_to() returns None instead of a valid object HOT 4
- Add example of overload with default values HOT 7
- Make `IPv{4,6}Address.version` and `max_prefixlen` available on classes, not just instances HOT 1
- Change in `pdb` behavior at exit from post-mortem debugger HOT 1
- dask pyperformance benchmark hangs on win32 HOT 7
- Support formatting UTF-8 email addresses HOT 4
- Incorrect decoding of preamble in email parser
- Add PyFrame_SetLineNumber() for Cython
- Crash in `PyThreadState_DeleteCurrent`: drop_gil: GIL is not locked (free-threading) HOT 3
- "thread sanitizer" (tsan) CI job is hanging HOT 2
- test_interpreters Failing Intermittently Under Py_DISABLE_GIL HOT 3
- __file__ for Some Dynamic Extension Modules has a Broken Refcount
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.