Skip to content

Remove versioneer / setuptools #57941

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

Closed
wants to merge 18 commits into from
Closed
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir
- run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1
python -m pip install numpy --config-settings=setup-args="-Dallow-noblas=true"
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir cython python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir
export PANDAS_CI=1
Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
/opt/python/cp311-cp311/bin/python -m venv ~/virtualenvs/pandas-dev
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson-python==0.13.1 meson[ninja]==1.2.1
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir cython numpy python-dateutil pytz pytest>=7.3.2 pytest-xdist>=2.2.0 hypothesis>=6.46.1
python -m pip install --no-cache-dir --no-build-isolation -e . --config-settings=setup-args="--werror"
python -m pip list --no-cache-dir

Expand Down Expand Up @@ -339,7 +339,6 @@ jobs:
python --version
python -m pip install --upgrade pip setuptools wheel meson[ninja]==1.2.1 meson-python==0.13.1
python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
python -m pip install versioneer[toml]
python -m pip install python-dateutil pytz tzdata cython hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-cov
python -m pip install -ve . --no-build-isolation --no-index --no-deps --config-settings=setup-args="--werror"
python -m pip list
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-310.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.10

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311-downstream_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- python=3.11

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311-numpydev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.11

# build dependencies
- versioneer[toml]
- meson[ninja]=1.2.1
- meson-python=0.13.1
- cython>=0.29.33
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311-pyarrownightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.11

# build dependencies
- versioneer[toml]
- meson[ninja]=1.2.1
- cython>=0.29.33
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-311.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.11

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-312.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.12

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-39-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- python=3.9

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.9

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/actions-pypy-39.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ dependencies:
- python=3.9[build=*_pypy]

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/deps/circle-310-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
- python=3.10

# build dependencies
- versioneer[toml]
- cython>=0.29.33
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
1 change: 0 additions & 1 deletion ci/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ requirements:
- cython >=0.29.33,<3
- numpy >=1.21.6 # [py<311]
- numpy >=1.23.2 # [py>=311]
- versioneer
- tomli # [py<311]
run:
- python
Expand Down
5 changes: 0 additions & 5 deletions doc/source/development/contributing_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,3 @@ output when importing pandas, you can set the environment variable ``MESONPY_EDT
If you would like to see this verbose output every time, you can set the ``editable-verbose`` config setting to ``true`` like so::

python -m pip install -ve . --config-settings editable-verbose=true

.. tip::
If you ever find yourself wondering whether setuptools or meson was used to build your pandas,
you can check the value of ``pandas._built_with_meson``, which will be true if meson was used
to compile pandas.
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- pip

# build dependencies
- versioneer[toml]
- cython~=3.0.5
- meson[ninja]=1.2.1
- meson-python=0.13.1
Expand Down
69 changes: 0 additions & 69 deletions generate_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion gitpod/gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ARG BASE_CONTAINER="pandas/pandas-dev:latest"
FROM gitpod/workspace-base:latest as clone

# the clone should be deep enough for versioneer to work
# the clone should be deep enough for version detection to work
RUN git clone https://github.com/pandas-dev/pandas --depth 12 /tmp/pandas

# -----------------------------------------------------------------------------
Expand Down
23 changes: 3 additions & 20 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
project(
'pandas',
'c', 'cpp', 'cython',
version: run_command(['generate_version.py', '--print'], check: true).stdout().strip(),
version: run_command(
['python', 'pandas/_build_utils/gitversion.py'],
check: true).stdout().strip(),
license: 'BSD-3',
meson_version: '>=1.2.1',
default_options: [
Expand All @@ -15,8 +17,6 @@ project(
fs = import('fs')
py = import('python').find_installation(pure: false)
tempita = files('generate_pxi.py')
versioneer = files('generate_version.py')


add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'c')
add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'cpp')
Expand All @@ -27,23 +27,6 @@ add_project_arguments('-DNPY_NO_DEPRECATED_API=0', language : 'cpp')
add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'c')
add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'cpp')


if fs.exists('_version_meson.py')
py.install_sources('_version_meson.py', subdir: 'pandas')
else
custom_target('write_version_file',
output: '_version_meson.py',
command: [
py, versioneer, '-o', '@OUTPUT@'
],
build_by_default: true,
build_always_stale: true,
install: true,
install_dir: py.get_install_dir() / 'pandas'
)
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
endif

# Needed by pandas.test() when it looks for the pytest ini options
py.install_sources(
'pyproject.toml',
Expand Down
23 changes: 8 additions & 15 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,15 @@

from pandas.util._tester import test

# use the closest tagged version if possible
_built_with_meson = False
try:
from pandas._version_meson import ( # pyright: ignore [reportMissingImports]
__version__,
__git_version__,
)

_built_with_meson = True
except ImportError:
from pandas._version import get_versions
# If a version with git hash was stored, use that instead
from pandas._version import ( # pyright: ignore [reportMissingImports]
__version__ as generated_ver,
git_revision,
)

v = get_versions()
__version__ = v.get("closest-tag", v["version"])
__git_version__ = v.get("full-revisionid")
del get_versions, v
__version__ = generated_ver
__git_version__ = git_revision
del git_revision, generated_ver


# module level doc-string
Expand Down
92 changes: 92 additions & 0 deletions pandas/_build_utils/gitversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python3

# This file is vendored from NumPy. See NUMPY_LICENSE.txt

import os
import os.path
import subprocess
import textwrap


def init_version() -> str:
init = os.path.join(os.path.dirname(__file__), "../../pyproject.toml")
with open(init, encoding="utf-8") as fid:
data = fid.readlines()

version_line = next(line for line in data if line.startswith("version ="))

result = version_line.strip().split(" = ")[1]
result = result.replace('"', "").replace("'", "")

return result


def git_version(version_str: str) -> tuple[str, str]:
# Append last commit date and hash to dev version information,
# if available

ghash = ""
result = version_str
try:
p = subprocess.Popen(
["git", "log", "-1", '--format="%H %aI"'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=os.path.dirname(__file__),
)
except FileNotFoundError:
pass
else:
out, err = p.communicate()
if p.returncode == 0:
ghash, git_date = (
out.decode("utf-8")
.strip()
.replace('"', "")
.split("T", maxsplit=1)[0]
.replace("-", "")
.split()
)

# Only attach git tag to development versions
if "dev" in version_str:
result = f"{version_str}+git{git_date}.{ghash[:7]}"

return result, ghash


if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--write", help="Save version to this file")
parser.add_argument(
"--meson-dist",
help="Output path is relative to MESON_DIST_ROOT",
action="store_true",
)
args = parser.parse_args()

version, git_hash = git_version(init_version())

template = textwrap.dedent(f"""
version = "{version}"
__version__ = version
git_revision = "{git_hash}"
""")

if args.write:
outfile = args.write
if args.meson_dist:
outfile = os.path.join(os.environ.get("MESON_DIST_ROOT", ""), outfile)

# Print human readable output path
relpath = os.path.relpath(outfile)
if relpath.startswith("."):
relpath = outfile

with open(outfile, "w", encoding="utf-8") as f:
print(f"Saving version to {relpath}")
f.write(template)
else:
print(version)
Loading
Loading