Skip to content

Commit 866502e

Browse files
authored
GH-45867: [Python] Fix SetuptoolsDeprecationWarning (#47141)
### Rationale for this change When building locally, I get many errors along the lines of ``` Please ensure the files specified are contained by the root of the Python package (normally marked by `pyproject.toml`). By 2026-Mar-20, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://packaging.python.org/en/latest/specifications/glob-patterns/ for details. ``` <img width="958" height="755" alt="terminal demo" src="https://github.com/user-attachments/assets/67f0e261-c4d2-403c-b004-688dfaaccda6" /> ### What changes are included in this PR? - Make the licence [SPDX compliant](https://spdx.org/licenses) - Remove the licence classifier - Move the licence files from `setup.cfg` to `pyproject.toml` - Fix the [disallowed glob patterns](https://packaging.python.org/en/latest/specifications/glob-patterns) via symlinks - Bumped the minimum version of `setuptools` due to macOS CI failures (don't know why this happened, caching maybe?) I appreciate the symlink change might prove controversial. See discussions in #45867, fixes #45867. ### Are these changes tested? When I rebuild locally, I get no errors any more. ### Are there any user-facing changes? Yes. The minimum required version of `setuptools` is now `77`. However, this is available on `>=3.9` so won't affect anyone really. * GitHub Issue: #45867 Authored-by: Patrick J. Roddy <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent aeb6486 commit 866502e

File tree

6 files changed

+46
-11
lines changed

6 files changed

+46
-11
lines changed

ci/conda_env_python.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ numpy>=1.16.6
2828
pytest
2929
pytest-faulthandler
3030
s3fs>=2023.10.0
31-
setuptools>=64
31+
setuptools>=77
3232
setuptools_scm>=8

python/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ pyarrow/_table_api.h
4545
manylinux1/arrow
4646
nm_arrow.log
4747
visible_symbols.log
48+
49+
# the purpose of the custom SDist class in setup.py is to include these files
50+
# in the sdist tarball, but we don't want to track duplicates
51+
LICENSE.txt
52+
NOTICE.txt

python/pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ requires = [
2222
# configuring setuptools_scm in pyproject.toml requires
2323
# versions released after 2022
2424
"setuptools_scm[toml]>=8",
25-
"setuptools>=64",
25+
"setuptools>=77",
2626
]
2727
build-backend = "setuptools.build_meta"
2828

@@ -32,9 +32,12 @@ dynamic = ["version"]
3232
requires-python = ">=3.10"
3333
description = "Python library for Apache Arrow"
3434
readme = {file = "README.md", content-type = "text/markdown"}
35-
license = {text = "Apache Software License"}
35+
license = "Apache-2.0"
36+
license-files = [
37+
"LICENSE.txt",
38+
"NOTICE.txt",
39+
]
3640
classifiers = [
37-
'License :: OSI Approved :: Apache Software License',
3841
'Programming Language :: Python :: 3.10',
3942
'Programming Language :: Python :: 3.11',
4043
'Programming Language :: Python :: 3.12',

python/requirements-build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cython>=3.1
22
numpy>=1.25
33
setuptools_scm>=8
4-
setuptools>=64
4+
setuptools>=77

python/setup.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
[metadata]
19-
license_files =
20-
../LICENSE.txt
21-
../NOTICE.txt
22-
2318
[build_sphinx]
2419
source-dir = doc/
2520
build-dir = doc/_build

python/setup.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from os.path import join as pjoin
2424
import re
2525
import shlex
26+
import shutil
2627
import sys
2728
import warnings
2829

@@ -33,6 +34,7 @@
3334
from distutils import sysconfig
3435

3536
from setuptools import setup, Extension, Distribution
37+
from setuptools.command.sdist import sdist
3638

3739
from Cython.Distutils import build_ext as _build_ext
3840
import Cython
@@ -395,11 +397,41 @@ def has_ext_modules(foo):
395397
return True
396398

397399

400+
class CopyLicenseSdist(sdist):
401+
"""Custom sdist command that copies license files from parent directory."""
402+
403+
def make_release_tree(self, base_dir, files):
404+
# Call parent to do the normal work
405+
super().make_release_tree(base_dir, files)
406+
407+
# Define source (parent dir) and destination (sdist root) for license files
408+
license_files = [
409+
("LICENSE.txt", "../LICENSE.txt"),
410+
("NOTICE.txt", "../NOTICE.txt"),
411+
]
412+
413+
for dest_name, src_path in license_files:
414+
src_full = os.path.join(os.path.dirname(__file__), src_path)
415+
dest_full = os.path.join(base_dir, dest_name)
416+
417+
# Remove any existing file/symlink at destination
418+
if os.path.exists(dest_full) or os.path.islink(dest_full):
419+
os.unlink(dest_full)
420+
421+
if not os.path.exists(src_full):
422+
msg = f"Required license file not found: {src_full}"
423+
raise FileNotFoundError(msg)
424+
425+
shutil.copy2(src_full, dest_full)
426+
print(f"Copied {src_path} to {dest_name} in sdist")
427+
428+
398429
setup(
399430
distclass=BinaryDistribution,
400431
# Dummy extension to trigger build_ext
401432
ext_modules=[Extension('__dummy__', sources=[])],
402433
cmdclass={
403-
'build_ext': build_ext
434+
'build_ext': build_ext,
435+
'sdist': CopyLicenseSdist,
404436
},
405437
)

0 commit comments

Comments
 (0)