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

BLD: Split out tests into pandas_tests package #53007

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d3edcdf
BLD: Split out tests into pandas_tests package
lithomas1 Apr 29, 2023
8e0d861
Merge branch 'main' of https://github.com/pandas-dev/pandas into remo…
lithomas1 Aug 23, 2023
bd83272
update for meson
lithomas1 Aug 23, 2023
339dacc
adjust cibuildwheel command?
lithomas1 Aug 23, 2023
eea0220
Merge branch 'main' of https://github.com/pandas-dev/pandas into remo…
lithomas1 Aug 23, 2023
a5a89b3
update
lithomas1 Aug 23, 2023
48df264
try again
lithomas1 Aug 23, 2023
d00e471
fix more
lithomas1 Aug 23, 2023
a43c9fe
update
lithomas1 Aug 23, 2023
b2c2b8c
Merge branch 'main' of github.com:pandas-dev/pandas into remove-tests
lithomas1 Feb 11, 2024
d6ac87c
Update wheels.yml
lithomas1 Feb 11, 2024
427ea4e
try fix paths
lithomas1 Feb 11, 2024
7174249
try something
lithomas1 Feb 11, 2024
f50f110
try something
lithomas1 Feb 11, 2024
9cbbb66
typo
lithomas1 Feb 11, 2024
053ad48
try again
lithomas1 Feb 11, 2024
f2573ee
another error
lithomas1 Feb 11, 2024
547dcc1
try github.workspace
lithomas1 Feb 11, 2024
1044441
working?
lithomas1 Feb 11, 2024
f3c182a
go for green on GHA
lithomas1 Feb 11, 2024
06d3697
try build from sdist on circleci
lithomas1 Feb 11, 2024
13063d8
debug circleci
lithomas1 Feb 12, 2024
8254943
debug circleci
lithomas1 Feb 12, 2024
9ed91e0
try exporting?
lithomas1 Feb 12, 2024
d4502af
green everything except musl?
lithomas1 Feb 12, 2024
b61a6a4
add missing deps?
lithomas1 Feb 12, 2024
1a6531c
upload wheels
lithomas1 Feb 12, 2024
e00ecf5
Merge branch 'main' of github.com:pandas-dev/pandas into remove-tests
lithomas1 Mar 16, 2024
799687f
try something
lithomas1 Mar 16, 2024
1d6137b
change pytest target
lithomas1 Mar 17, 2024
792c011
go for green
lithomas1 Mar 17, 2024
2a78345
fix import redirects
lithomas1 Mar 17, 2024
16f5964
try something
lithomas1 Mar 17, 2024
b911945
go for green take 2
lithomas1 Mar 17, 2024
beb64dc
try fixing windows
lithomas1 Mar 17, 2024
3135e67
try again to fix windows
lithomas1 Mar 17, 2024
d17ddaf
Update wheels.yml
lithomas1 Mar 18, 2024
50410ad
Update config.yml
lithomas1 Mar 18, 2024
554d478
Merge branch 'main' into remove-tests
lithomas1 Mar 18, 2024
8d68f7d
try for green again
lithomas1 Mar 18, 2024
98ec61a
try to fix doctests?
lithomas1 Mar 18, 2024
b8e3588
try doctests again
lithomas1 Mar 18, 2024
a19f2e6
get rid of cython doctests
lithomas1 Mar 18, 2024
b4aa062
try again
lithomas1 Mar 18, 2024
a2ba3bf
add back some config options to pyproject.toml
lithomas1 Mar 18, 2024
7ee6adc
meson changes
lithomas1 Mar 18, 2024
19fa7f9
try moving back stuff to the original conftest
lithomas1 Mar 18, 2024
be64699
fix typing?
lithomas1 Mar 18, 2024
f1c18cc
Merge branch 'main' into remove-tests
lithomas1 Mar 18, 2024
e835993
add pyright ignore
lithomas1 Mar 18, 2024
5bdc0d1
Merge branch 'remove-tests' of github.com:lithomas1/pandas into remov…
lithomas1 Mar 18, 2024
2cf3911
last ignore
lithomas1 Mar 18, 2024
e9ba935
fix musl
lithomas1 Mar 18, 2024
e53ad08
Update code_checks.sh
lithomas1 Mar 20, 2024
23952aa
Merge branch 'main' into remove-tests
lithomas1 Mar 20, 2024
23b9827
Merge branch 'main' into remove-tests
lithomas1 Mar 26, 2024
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
29 changes: 26 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
ENV_FILE: ci/deps/circle-310-arm64.yaml
PYTEST_WORKERS: auto
PATTERN: "not single_cpu and not slow and not network and not clipboard and not arm_slow and not db"
PYTEST_TARGET: "pandas"
PYTEST_TARGET: "pandas/tests"
PANDAS_CI: "1"
steps:
- checkout
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
- run: |
. ~/virtualenvs/pandas-dev/bin/activate
export PANDAS_CI=1
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas/tests --junitxml=test-data.xml
build-aarch64:
parameters:
cibw-build:
Expand All @@ -67,6 +67,28 @@ jobs:
elif ! (curl https://api.github.com/repos/pandas-dev/pandas/issues/$CIRCLE_PR_NUMBER | jq '.labels' | grep -q 'Build'); then
circleci-agent step halt
fi
- run:
# The process here is more complicated than on Github Actions
# since we need to copy the tests wheel into the unzipped sdist
# so that it gets copied (along with the contents of the unzipped sdist)
# into the Linux docker image used for building the wheel
# (unlike Github Actions there is no host access using cibuildwheel with CircleCI)
name: Build the sdist
command: |
pip3 install build setuptools-scm wheel
Copy link
Member

Choose a reason for hiding this comment

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

Is setuptools-scm a misnomer or does it have some kind of dependency with setuptools?

Copy link
Member Author

Choose a reason for hiding this comment

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

We use it to version the pandas-tests package?

Setting up versioneer is probably overkill for pandas-tests.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm not sure I understand. So this does still require setuptools right? I think that is confusing given the work we have put into meson to replace that library

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, pandas-tests is built using setuptools.

I figured it was much easier to use setuptools given this is a pure Python package.

(Note that if you're just doing regular development you'll never need setuptools, unless you want to build pandas_tests by hand for some reason)

python3 -m build --sdist
sdist_name=$(ls ./dist/*.tar.gz)
mkdir unzipped-sdist
tar -xzf $sdist_name -C unzipped-sdist --strip-components=1
cd pandas
# Have to disable isolation otherwise
# we won't be able to pull the version correctly
python3 -m build --wheel --no-isolation --outdir ../unzipped-sdist
cd ..
echo "sdist_name=./unzipped-sdist" >> "$BASH_ENV"
WillAyd marked this conversation as resolved.
Show resolved Hide resolved
echo "pandas_tests_loc=$(ls ./unzipped-sdist/*.whl)" >> "$BASH_ENV"
ls ./unzipped-sdist/*.whl

- run:
name: Build aarch64 wheels
no_output_timeout: 30m # Sometimes the tests won't generate any output, make sure the job doesn't get killed by that
Expand All @@ -76,7 +98,8 @@ jobs:
if [[ "$IS_SCHEDULE_DISPATCH" == "true" || "$IS_PUSH" != 'true' ]]; then
export CIBW_ENVIRONMENT="PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
fi
cibuildwheel --prerelease-pythons --output-dir wheelhouse
export CIBW_BEFORE_TEST="pip install {project}/${pandas_tests_loc}"
cibuildwheel ${sdist_name} --prerelease-pythons --output-dir wheelhouse

environment:
CIBW_BUILD: << parameters.cibw-build >>
Expand Down
7 changes: 2 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,5 @@ Dockerfile export-ignore
environment.yml export-ignore
setup.py export-ignore


# GH 39321
# csv_dir_path fixture checks the existence of the directory
# exclude the whole directory to avoid running related tests in sdist
pandas/tests/io/parser/data export-ignore
# Strip tests from the distribution
pandas/tests export-ignore
10 changes: 5 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
PANDAS_CI: ${{ matrix.pandas_ci || '1' }}
TEST_ARGS: ${{ matrix.test_args || '' }}
PYTEST_WORKERS: ${{ matrix.pytest_workers || 'auto' }}
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas/tests' }}
NPY_PROMOTION_STATE: ${{ matrix.env_file == 'actions-311-numpydev.yaml' && 'weak' || 'legacy' }}
# Clipboard tests
QT_QPA_PLATFORM: offscreen
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
cancel-in-progress: true
env:
PANDAS_CI: 1
PYTEST_TARGET: pandas
PYTEST_TARGET: pandas/tests
PATTERN: "not slow and not db and not network and not single_cpu"
PYTEST_WORKERS: 'auto'

Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
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
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas/tests --junitxml=test-data.xml
concurrency:
# https://git.luolix.topmunity/t/concurrecy-not-work-for-push/183068/7
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-32bit
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
run: |
. ~/virtualenvs/pandas-dev/bin/activate
export PANDAS_CI=1
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas/tests --junitxml=test-data.xml
concurrency:
# https://git.luolix.topmunity/t/concurrecy-not-work-for-push/183068/7
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-musl
Expand Down Expand Up @@ -322,7 +322,7 @@ jobs:
PYTEST_WORKERS: "auto"
PANDAS_CI: 1
PATTERN: "not slow and not network and not clipboard and not single_cpu"
PYTEST_TARGET: pandas
PYTEST_TARGET: pandas/tests

steps:
- uses: actions/checkout@v4
Expand Down
61 changes: 36 additions & 25 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
IS_SCHEDULE_DISPATCH: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
outputs:
sdist_file: ${{ steps.save-path.outputs.sdist_name }}
pandas_tests_loc: ${{ steps.save-tests-path.outputs.pandas_tests_loc }}
steps:
- name: Checkout pandas
uses: actions/checkout@v4
Expand All @@ -59,22 +60,34 @@ jobs:

- name: Build sdist
run: |
python -m pip install build
python -m pip install build wheel setuptools-scm
python -m build --sdist

- name: Build pandas_tests
run: |
cd pandas
# we want to place the pandas_tests wheel in the same
# dist directory as the sdist
python -m build --wheel --outdir ../dist --no-isolation

- uses: actions/upload-artifact@v4
with:
name: sdist
name: sdist-and-tests
path: ./dist/*

- name: Sanity check sdist files
- name: Sanity check built files
run: |
ls ./dist

- name: Output sdist name
id: save-path
shell: bash -el {0}
run: echo "sdist_name=$(ls ./dist)" >> "$GITHUB_OUTPUT"
run: echo "sdist_name=$(ls ./dist/*.tar.gz)" >> "$GITHUB_OUTPUT"

- name: Output pandas_tests location
id: save-tests-path
shell: bash -el {0}
run: echo "pandas_tests_loc=$(ls ./dist/*.whl)" >> "$GITHUB_OUTPUT"

build_wheels:
needs: build_sdist
Expand Down Expand Up @@ -109,52 +122,48 @@ jobs:
with:
fetch-depth: 0

# TODO: Build wheels from sdist again
# There's some sort of weird race condition?
# within Github that makes the sdist be missing files

# We need to build wheels from the sdist since the sdist
# removes unnecessary files from the release
- name: Download sdist (not macOS)
#if: ${{ matrix.buildplat[1] != 'macosx_*' }}
- name: Download sdist and pandas_tests
uses: actions/download-artifact@v4
with:
name: sdist
name: sdist-and-tests
path: ./dist

- name: Output sdist name (macOS)
id: save-path
shell: bash -el {0}
run: echo "sdist_name=$(ls ./dist)" >> "$GITHUB_ENV"

# Python version used to build sdist doesn't matter
# wheel will be built from sdist with the correct version
# The sdist will be corrupted by cibuildwheel/macOS sometimes somehow
WillAyd marked this conversation as resolved.
Show resolved Hide resolved
# (I think this is a Github Actions bug)
- name: Unzip sdist (macOS)
if: ${{ startsWith(matrix.buildplat[1], 'macosx') }}
run: |
tar -xzf ./dist/${{ env.sdist_name }} -C ./dist
tar -xzf ${{ needs.build_sdist.outputs.sdist_file }} -C ./dist

- name: Output sdist name (macOS)
- name: Output new sdist name (macOS)
id: save-path2
if: ${{ matrix.buildplat[1] == 'macosx_*' }}
shell: bash -el {0}
run: echo "sdist_name=$(cd ./dist && ls -d */)" >> "$GITHUB_ENV"
run: echo "sdist_name=./dist/$(cd ./dist && ls -d */)" >> "$GITHUB_ENV"

- name: Build normal wheels
if: ${{ (env.IS_SCHEDULE_DISPATCH != 'true' || env.IS_PUSH == 'true') }}
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
package-dir: ${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
# Note: Since the sdist is the project directory, it does not contain the tests
WillAyd marked this conversation as resolved.
Show resolved Hide resolved
# We need to manually install tests from the host. This isn't ideal since it breaks
# isolation but should be no big deal
# (On Linux, need to prefix with /host, since we run builds in a container and the root directory is
# mounted to host)
CIBW_BEFORE_TEST: >
pip install ${{ startsWith(matrix.buildplat[0], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }}

- name: Build nightly wheels (with NumPy pre-release)
if: ${{ (env.IS_SCHEDULE_DISPATCH == 'true' && env.IS_PUSH != 'true') }}
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: ./dist/${{ startsWith(matrix.buildplat[1], 'macosx') && env.sdist_name || needs.build_sdist.outputs.sdist_file }}
env:
# The nightly wheels should be build witht he NumPy 2.0 pre-releases
# The nightly wheels should be build with the NumPy 2.0 pre-releases
# which requires the additional URL.
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
CIBW_PRERELEASE_PYTHONS: True
Expand Down Expand Up @@ -185,13 +194,15 @@ jobs:
$TST_CMD = @"
python -m pip install hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0;
python -m pip install `$(Get-Item pandas\wheelhouse\*.whl);
python -m pip install `$(Get-Item pandas\dist\pandas_tests*.whl);
python -c `'import pandas as pd; pd.test(extra_args=[`\"--no-strict-data-files`\", `\"-m not clipboard and not single_cpu and not slow and not network and not db`\"])`';
"@
# add rc to the end of the image name if the Python version is unreleased
docker pull python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }}
docker run --env PANDAS_CI='1' -v ${PWD}:C:\pandas python:${{ matrix.python[1] == '3.12' && '3.12-rc' || format('{0}-windowsservercore', matrix.python[1]) }} powershell -Command $TST_CMD

- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }}
path: ./wheelhouse/*.whl
Expand Down
7 changes: 3 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ global-exclude *.h
global-exclude *.py[ocd]
global-exclude *.pxi

# GH 39321
# csv_dir_path fixture checks the existence of the directory
# exclude the whole directory to avoid running related tests in sdist
prune pandas/tests/io/parser/data
# Remove tests
# Those will be distributed in a separate package
prune pandas/tests

# Selectively re-add *.cxx files that were excluded above
graft pandas/_libs/src
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endif

# Needed by pandas.test() when it looks for the pytest ini options
py.install_sources(
'pyproject.toml',
'pandas/pyproject.toml',
subdir: 'pandas'
)

Expand Down
13 changes: 13 additions & 0 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,19 @@
__git_version__ = v.get("full-revisionid")
del get_versions, v

import sys
Copy link
Member

Choose a reason for hiding this comment

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

Does this break an API users potentially use. If so will we need a depr cycle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Kinda.
You can still access pandas.tests as before (if you're using a wheel without the tests submodule) e.g. if you wanted to use the extension dtypes tests, but you'll need to install pandas-tests to do so.

This is technically breaking, but the next release also happens to be 3.0, so I think we'd be able to get away with a breaking change here :)


try:
import pandas_tests # pyright: ignore [reportMissingImports]

sys.modules["pandas.tests"] = pandas_tests

del pandas_tests
except ImportError:
pass

del sys


# module level doc-string
__doc__ = """
Expand Down
Loading
Loading