Reputation: 114795
We're getting deprecation warnings when building with python3 setup.py sdist
and after reading Why you shouldn't invoke setup.py directly? I see that the recomended alternative is to use build
.
setup.py command | New command |
---|---|
setup.py sdist | python -m build (with build) |
setup.py bdist_wheel |
When comparing the outputs I see that the deprecated setup.py
excludes the tests directory (as specified with packages=find_packages(exclude=['tests']),
while python3 -m build
does not exclude this directory.
My understanding was that build
still uses setup.py
, albeit not directly, am I missing something? What is the correct way to avoid packaging the tests directory?
Environment information
python
: 3.10.10pip
: 23.0.1setuptools
: 65.5.0build
: 0.10.0pyproject.toml
file in projectA minimal project behaves the same:
In my test sample project there is a lib
directory with an empty __init__.py
and hello.py
with print("hello")
, a tests
directory with an empty test_hello.py
file and the following setup.py
:
from setuptools import find_packages, setup
setup(
name="hello",
version="0.1",
author="myself",
description="test package",
packages=find_packages(exclude=["tests"]),
)
Edit: Opened issue on github https://github.com/pypa/setuptools/issues/3870
Upvotes: 0
Views: 586
Reputation: 114795
After opening a defect on github the problem was resolved by adding the following pyproject.toml
:
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools==65.5"]
Upvotes: 0