-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
glob patterns for data_files #1681
Comments
I have no great objections to this, though do we need some indication that it's to be interpreted as a glob pattern and not a literal string? Even if we limit it just to supporting |
|
@agateau I'm not really willing to break backwards compatibility by changing the way these strings are interpreted from being paths to being glob patterns. An asterisk is a valid character for a file name, it's definitely something we want to support, regardless of whether it will break in other places as well. We just need a way to differentiate between "interpret this as a path" and "interpret this as a glob", hopefully it's not terribly difficult. |
@pganssle |
@hydrargyrum Like I said above, I'm in favor of adding a way to do this, but it would be a backwards-incompatible change and would be removing the ability to literally specify files with asterisks in their names if we just start interpreting all file paths as glob literals. As much as I am in favor of making common patterns easier in If we want to make actual progress on this issue, I think we need to come up with possible backwards-compatible interfaces that would allow this to move forward. I think they will broadly fall into four categories:
Number 1 is probably the best option, but it's not terribly discoverable, and right now at least only Numbers 3 and 4 are ugly mainly because you now have two different options to specify the same thing, and it may not be obvious to people what they do. If anyone has better options or wants to argue for one of these, please do let me know, because none of the options seem terribly appealing to me. |
Number 1 looks like the best option to me as well, because it would work for setup.py and setup.cfg, but this syntax should be usable for all keys were a glob pattern can be used. While I respect your desire to not break compatibility, I have yet to find a package shipping files with asterisks in their names. I may be wrong on this, but I would be surprised if simply changing the code to accept asterisks would wreak so much havoc. Quoting the Zen of Python:
|
The only invalid path on Unix is a null byte (and "/" cannot exist in filenames but validly denotes a directory separator). It's theoretically possible but highly unlikely people wanted a literal asterisk in their file names, but by the same token that ":" is illegal on Windows, and in fact also illegal even on Unix if you happen to be using fat32 or NTFS without the POSIX namespace (the restriction is part of the filesystem spec)... ... the asterisk is also illegal in filenames on Windows (and at the filesystem layer on fat32 and NTFS). So, such code depending on literal asterisks would unexpectedly fail on Windows, and also on that one person's USB drive used for copying around a personal python environment from Unix system to Unix system. One could argue backwards compatibility with something inherently broken is not such an important priority, and even if someone did need that behavior, the asterisk would simply expand to multiple files including the one with the literal asterisk. So the package would collect too many files, but at least the desired file would in fact be there. If we want to make it super unlikely for anyone to ever stumble across this by using some prefix marker like option 1, I don't think |
I discovered this issue while trying to migrate some other project off of pbr and onto the builtin setup.cfg support (and wondering why the obvious thing did not work). Unfortunately, the project uses pbr's support for
so it cannot be mapped to |
Recently discovered the same thing and found this thread. I have begrudgingly reinstituted a setup.py just to do some glob() calls, but I feel a new directive like |
So, I've taken a whack at adding a I feel it's a relatively safe change as the present behaviour has not changed if the new directive is not used. Open for any constructive feedback from anybody in any case. |
Well, @pganssle's concern was, I think, that people might be using the new directive and actually mean it to be a literal filename instead of a directive... the question is whether that's a practical concern. So yeah, relatively safe. Thanks for doing the legwork of actually implementing this! |
Implement #1681 (globbing support for `[options.data_files]`)
Would be great to be able to use glob patterns for
data_files
, so that one can write something like this:This would be consistent with the way
package_data
works.The text was updated successfully, but these errors were encountered: