Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/conda_env_python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ numpy>=1.16.6
pytest
pytest-faulthandler
s3fs>=2023.10.0
setuptools>=64
setuptools>=77
setuptools_scm>=8
5 changes: 5 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ pyarrow/_table_api.h
manylinux1/arrow
nm_arrow.log
visible_symbols.log

# the purpose of the custom SDist class in setup.py is to include these files
# in the sdist tarball, but we don't want to track duplicates
LICENSE.txt
NOTICE.txt
9 changes: 6 additions & 3 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requires = [
# configuring setuptools_scm in pyproject.toml requires
# versions released after 2022
"setuptools_scm[toml]>=8",
"setuptools>=64",
"setuptools>=77",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required due to setuptools<77 not recognizing the new license strings proposed in this PR (see pypa/setuptools#4903 for explanation). I'm not sure if this is controversial so bringing it up here. @raulcd

]
build-backend = "setuptools.build_meta"

Expand All @@ -32,9 +32,12 @@ dynamic = ["version"]
requires-python = ">=3.10"
description = "Python library for Apache Arrow"
readme = {file = "README.md", content-type = "text/markdown"}
license = {text = "Apache Software License"}
license = "Apache-2.0"
license-files = [
"LICENSE.txt",
"NOTICE.txt",
]
classifiers = [
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
Expand Down
2 changes: 1 addition & 1 deletion python/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cython>=3.1
numpy>=1.25
setuptools_scm>=8
setuptools>=64
setuptools>=77
5 changes: 0 additions & 5 deletions python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
# specific language governing permissions and limitations
# under the License.

[metadata]
license_files =
../LICENSE.txt
../NOTICE.txt

[build_sphinx]
source-dir = doc/
build-dir = doc/_build
Expand Down
34 changes: 33 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from os.path import join as pjoin
import re
import shlex
import shutil
import sys
import warnings

Expand All @@ -33,6 +34,7 @@
from distutils import sysconfig

from setuptools import setup, Extension, Distribution
from setuptools.command.sdist import sdist

from Cython.Distutils import build_ext as _build_ext
import Cython
Expand Down Expand Up @@ -395,11 +397,41 @@ def has_ext_modules(foo):
return True


class CopyLicenseSdist(sdist):
"""Custom sdist command that copies license files from parent directory."""

def make_release_tree(self, base_dir, files):
# Call parent to do the normal work
super().make_release_tree(base_dir, files)

# Define source (parent dir) and destination (sdist root) for license files
license_files = [
("LICENSE.txt", "../LICENSE.txt"),
("NOTICE.txt", "../NOTICE.txt"),
]

for dest_name, src_path in license_files:
src_full = os.path.join(os.path.dirname(__file__), src_path)
dest_full = os.path.join(base_dir, dest_name)

# Remove any existing file/symlink at destination
if os.path.exists(dest_full) or os.path.islink(dest_full):
os.unlink(dest_full)

if not os.path.exists(src_full):
msg = f"Required license file not found: {src_full}"
raise FileNotFoundError(msg)

shutil.copy2(src_full, dest_full)
print(f"Copied {src_path} to {dest_name} in sdist")


setup(
distclass=BinaryDistribution,
# Dummy extension to trigger build_ext
ext_modules=[Extension('__dummy__', sources=[])],
cmdclass={
'build_ext': build_ext
'build_ext': build_ext,
'sdist': CopyLicenseSdist,
},
)
Loading