[BUG] glob-style pattern with range ([0-9]) not working

Open
#4,018 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
build-system

Research direction

Start with the supplied setuptools-globstyle-bug.zip and the MANIFEST.in rules, then run the documented build and inspect the wheel with unzip -l. Compare global-exclude 202[0-9] with the working 202 and 202[23] patterns. Done means the range pattern excludes file3_20230814T111336.py as expected.

Written by the indexing model from the issue text.

Description

help wanted Needs Investigation Waiting User Feedback
setuptools version

68.0.0

Python version

Python 3.10.12

OS

Ubuntu 22.04 under WSL2

Additional environment information

Environment

$ python --version
Python 3.10.12

$ pip freeze
build==0.10.0
packaging==23.1
pyproject_hooks==1.0.0
# Editable install with no version control (setuptools-tests==1.0)
-e <somedir>/setuptools-test
tomli==2.0.1

Setup to reproduce the problem

setuptools-globstyle-bug.zip

Description

When MANIFEST.in contains global-exclude *202*, any file with this string is being excluded such as file3_20230814T111336.py (WORKS AS INTENDED).

However, when MANIFEST.in contains global-exclude *202[0-9]*, any file with a string that follows that glob-style pattern gets included, such as one named file3_20230814T111336.py. That is the BUG.

Note that I tested the glob-style pattern an it is valid:

$ find . -name '*202[0-9]*'
./src/file3_20230814T111336.py

Last note, when MANIFEST.in contains global-exclude *202[23]*, that does work and file3_20230814T111336.py gets excluded. The [] syntax seams to work partially, but its "range" functionality does not.

Setuptools is not following what its documentation is referring to at Controlling files in the distribution which points to PyPA’s Packaging User Guide. In this last page, we do find:

matches any one of the characters between the square brackets (which may contain character ranges, e.g., [a-z] or [a-fA-F0-9]).

Expected behavior

global-exclude *202[0-9]*, any file with a string that follows that glob-style pattern should get excluded.

How to Reproduce

setuptools-globstyle-bug.zip provides an environment where one can test this. Simply edit MANIFEST.in to test the glob-style pattern you plan to test and call build to see what gets included in the wheel.

Output

When MANIFEST.in contains global-exclude *202[0-9]*, we notice below that the file file3_20230814T111336.py gets included.

unzip -l dist/*.whl

  Length      Date    Time    Name
---------  ---------- -----   ----
       45  2023-08-14 13:09   file1.py
       45  2023-08-14 13:09   file2.py
       45  2023-08-14 13:09   file3_20230814T111336.py
       45  2023-08-14 13:09   file3_print.py
      265  2023-08-14 16:58   setuptools_tests-1.0.dist-info/METADATA
       92  2023-08-14 16:58   setuptools_tests-1.0.dist-info/WHEEL
       46  2023-08-14 16:58   setuptools_tests-1.0.dist-info/top_level.txt
      599  2023-08-14 16:58   setuptools_tests-1.0.dist-info/RECORD
---------                     -------
     1182                     8 files
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pypa/setuptools

All issues in pypa/setuptools

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.