Skip to content
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

only ignore build/dist directory if next to a project config file #12625

Open
RonnyPfannschmidt opened this issue Jul 17, 2024 · 4 comments · May be fixed by #12918
Open

only ignore build/dist directory if next to a project config file #12625

RonnyPfannschmidt opened this issue Jul 17, 2024 · 4 comments · May be fixed by #12918
Assignees
Labels
topic: collection related to the collection phase type: enhancement new feature or API change, should be merged into features branch

Comments

@RonnyPfannschmidt
Copy link
Member

the collect ignore on build directories seems to be over-arching due to matching in sub-directories even it should only consider the build/dist folders directly next to the project config files

as per

@RonnyPfannschmidt RonnyPfannschmidt added type: enhancement new feature or API change, should be merged into features branch topic: collection related to the collection phase labels Jul 17, 2024
@webknjaz
Copy link
Member

So this should only be happening when setup.py or setup.cfg exists. In case if there's only pyproject.toml, an additional check should verify that setuptools is listed in [build-system].requires.

sus-pe pushed a commit to sus-pe/pytest that referenced this issue Oct 25, 2024
sus-pe pushed a commit to sus-pe/pytest that referenced this issue Oct 25, 2024
@sus-pe
Copy link
Contributor

sus-pe commented Oct 25, 2024

Hi, I'm giving this a shot, I am wondering how I should go about the pyproject.toml check, any simple method to access the contents of pyproject.toml from _pytest.main?

@webknjaz
Copy link
Member

@sus-pe you should probably follow this pattern:

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
toml_text = filepath.read_text(encoding="utf-8")
try:
config = tomllib.loads(toml_text)
except tomllib.TOMLDecodeError as exc:
raise UsageError(f"{filepath}: {exc}") from exc
result = config.get("tool", {}).get("pytest", {}).get("ini_options", None)
.

@sus-pe
Copy link
Contributor

sus-pe commented Oct 26, 2024

As I'm playing around with tests checking the contents of [build-system].requires I've thought perhaps this is not the way to go about it, say for example a different build system other then setuptools is used (say hatchling) that creates artifacts in dist folder, we probably wouldn't like it to recurse. Can we think of any use case where a pyproject.toml is present and it would make sense to recurse into dist? Why shouldn't we be satisfied with the existence of pyproject.toml as an indication we should not recurse implicitly to common build artifacts dirnames like build and dist?

sus-pe pushed a commit to sus-pe/pytest that referenced this issue Oct 26, 2024
sus-pe pushed a commit to sus-pe/pytest that referenced this issue Oct 26, 2024
sus-pe pushed a commit to sus-pe/pytest that referenced this issue Oct 28, 2024
sus-pe pushed a commit to sus-pe/pytest that referenced this issue Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants