From d3edcdf2dce5917bace7a9b196554d8e8697cefc Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 29 Apr 2023 18:33:08 -0400 Subject: [PATCH 01/46] BLD: Split out tests into pandas_tests package --- MANIFEST.in | 6 ++++- pandas/pyproject.toml | 22 ++++++++++++++++ pandas/{ => tests}/conftest.py | 2 +- pandas/tests/pytest.ini | 44 +++++++++++++++++++++++++++++++ pandas/util/_tester.py | 4 +-- pyproject.toml | 47 ++-------------------------------- 6 files changed, 76 insertions(+), 49 deletions(-) create mode 100644 pandas/pyproject.toml rename pandas/{ => tests}/conftest.py (99%) create mode 100644 pandas/tests/pytest.ini diff --git a/MANIFEST.in b/MANIFEST.in index 361cd8ff9ec22..48271df07be37 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -53,7 +53,11 @@ 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 +#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 diff --git a/pandas/pyproject.toml b/pandas/pyproject.toml new file mode 100644 index 0000000000000..d8d247dda9097 --- /dev/null +++ b/pandas/pyproject.toml @@ -0,0 +1,22 @@ +# Note: This is the pyproject.toml for the pandas-tests package +# The pyproject.toml for the pandas package is in the parent directory +# of this one +[build-system] +requires = [ + "setuptools>=61.0.0", +] +[project] +name="pandas-tests" +# Note: The version is hardcoded since the pandas version has to +# match the tests version. Remember to bump both! +version="2.1" +#dependencies=[ +# "pandas==2.1.0" +#] +requires-python=">=3.9" + +[tool.setuptools] +package-dir={"pandas_tests"= "tests"} + +[tool.setuptools.package-data] +"pandas_tests"=["pytest.ini"] diff --git a/pandas/conftest.py b/pandas/tests/conftest.py similarity index 99% rename from pandas/conftest.py rename to pandas/tests/conftest.py index 86f0121dd00a9..fa6ef62ff2244 100644 --- a/pandas/conftest.py +++ b/pandas/tests/conftest.py @@ -1167,7 +1167,7 @@ def datapath(strict_data_files: str) -> Callable[..., str]: ValueError If the path doesn't exist and the --strict-data-files option is set. """ - BASE_PATH = os.path.join(os.path.dirname(__file__), "tests") + BASE_PATH = os.path.join(os.path.dirname(__file__), "") def deco(*args): path = os.path.join(BASE_PATH, *args) diff --git a/pandas/tests/pytest.ini b/pandas/tests/pytest.ini new file mode 100644 index 0000000000000..09c4cd0406f43 --- /dev/null +++ b/pandas/tests/pytest.ini @@ -0,0 +1,44 @@ +[pytest] +# sync minversion with pyproject.toml & install.rst +minversion = 7.0 +addopts = --strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml +empty_parameter_set_mark = fail_at_collect +xfail_strict = true +testpaths = pandas +doctest_optionflags = + NORMALIZE_WHITESPACE + IGNORE_EXCEPTION_DETAIL + ELLIPSIS + +filterwarnings = + error:::pandas + error::ResourceWarning + error::pytest.PytestUnraisableExceptionWarning + ignore:.*ssl.SSLSocket:pytest.PytestUnraisableExceptionWarning + ignore:.*ssl.SSLSocket:ResourceWarning + ignore::ResourceWarning:asyncio + # From plotting doctests + ignore:More than 20 figures have been opened:RuntimeWarning + # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 + ignore:`np.MachAr` is deprecated:DeprecationWarning:numba + ignore:.*urllib3:DeprecationWarning:botocore + ignore:Setuptools is replacing distutils.:UserWarning:_distutils_hack + # https://github.com/PyTables/PyTables/issues/822 + ignore:a closed node found in the registry:UserWarning:tables + ignore:`np.object` is a deprecated:DeprecationWarning:tables + ignore:tostring:DeprecationWarning:tables + ignore:distutils Version classes are deprecated:DeprecationWarning:numexpr + ignore:distutils Version classes are deprecated:DeprecationWarning:fastparquet + ignore:distutils Version classes are deprecated:DeprecationWarning:fsspec + +junit_family = xunit2 +markers = + single_cpu: tests that should run on a single cpu only + slow: mark a test as slow + network: mark a test as network + db: tests requiring a database (mysql or postgres) + clipboard: mark a pd.read_clipboard test + arm_slow: mark a test as slow for arm64 architecture + arraymanager: mark a test to run with ArrayManager enabled + +asyncio_mode = strict diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 1732b75a2a2b9..6bd74bf89e4e3 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -8,8 +8,6 @@ from pandas.compat._optional import import_optional_dependency -PKG = os.path.dirname(os.path.dirname(__file__)) - def test(extra_args: list[str] | None = None) -> None: """ @@ -23,6 +21,8 @@ def test(extra_args: list[str] | None = None) -> None: Extra marks to run the tests. """ pytest = import_optional_dependency("pytest") + pandas_tests = import_optional_dependency("pandas_tests") + PKG = os.path.dirname(pandas_tests.__file__) import_optional_dependency("hypothesis") cmd = ['-m "not slow and not network and not db"'] if extra_args: diff --git a/pyproject.toml b/pyproject.toml index aacf8649add35..88db05c5d9046 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,8 @@ include-package-data = true [tool.setuptools.packages.find] include = ["pandas", "pandas.*"] +# need to have a * after otherwise won't match anything +exclude = ["pandas.tests*"] namespaces = false [tool.setuptools.exclude-package-data] @@ -415,51 +417,6 @@ disable = [ "using-constant-test" ] -[tool.pytest.ini_options] -# sync minversion with pyproject.toml & install.rst -minversion = "7.0" -addopts = "--strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" -empty_parameter_set_mark = "fail_at_collect" -xfail_strict = true -testpaths = "pandas" -doctest_optionflags = [ - "NORMALIZE_WHITESPACE", - "IGNORE_EXCEPTION_DETAIL", - "ELLIPSIS", -] -filterwarnings = [ - "error:::pandas", - "error::ResourceWarning", - "error::pytest.PytestUnraisableExceptionWarning", - "ignore:.*ssl.SSLSocket:pytest.PytestUnraisableExceptionWarning", - "ignore:.*ssl.SSLSocket:ResourceWarning", - "ignore::ResourceWarning:asyncio", - # From plotting doctests - "ignore:More than 20 figures have been opened:RuntimeWarning", - # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 - "ignore:`np.MachAr` is deprecated:DeprecationWarning:numba", - "ignore:.*urllib3:DeprecationWarning:botocore", - "ignore:Setuptools is replacing distutils.:UserWarning:_distutils_hack", - # https://github.com/PyTables/PyTables/issues/822 - "ignore:a closed node found in the registry:UserWarning:tables", - "ignore:`np.object` is a deprecated:DeprecationWarning:tables", - "ignore:tostring:DeprecationWarning:tables", - "ignore:distutils Version classes are deprecated:DeprecationWarning:numexpr", - "ignore:distutils Version classes are deprecated:DeprecationWarning:fastparquet", - "ignore:distutils Version classes are deprecated:DeprecationWarning:fsspec", -] -junit_family = "xunit2" -markers = [ - "single_cpu: tests that should run on a single cpu only", - "slow: mark a test as slow", - "network: mark a test as network", - "db: tests requiring a database (mysql or postgres)", - "clipboard: mark a pd.read_clipboard test", - "arm_slow: mark a test as slow for arm64 architecture", - "arraymanager: mark a test to run with ArrayManager enabled", -] -asyncio_mode = "strict" - [tool.mypy] # Import discovery mypy_path = "typings" From bd832722b7eee340fd907a00f052eceb70e7306e Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 09:10:21 -0700 Subject: [PATCH 02/46] update for meson --- .gitattributes | 5 ++++- pandas/meson.build | 11 ++++++++-- pandas/tests/pytest.ini | 22 +++++++++++-------- pyproject.toml | 48 ----------------------------------------- 4 files changed, 26 insertions(+), 60 deletions(-) diff --git a/.gitattributes b/.gitattributes index 19c6fd2fd1d47..0ea7db74200ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -81,4 +81,7 @@ 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 +#pandas/tests/io/parser/data export-ignore + +# Strip tests from the distribution +pandas/tests export-ignore diff --git a/pandas/meson.build b/pandas/meson.build index 1dc9955aa4ff6..73cb0449dc1c7 100644 --- a/pandas/meson.build +++ b/pandas/meson.build @@ -35,10 +35,18 @@ subdirs_list = [ 'errors', 'io', 'plotting', - 'tests', 'tseries', 'util' ] + +# Add the tests in if they are present +# (they would be present normally but +# would not be present in an sdist since +# we strip them out for build size reasons) +if fs.is_dir('tests') + subdirs_list += 'tests' +endif + foreach subdir: subdirs_list install_subdir(subdir, install_dir: py.get_install_dir(pure: false) / 'pandas') endforeach @@ -46,7 +54,6 @@ top_level_py_list = [ '__init__.py', '_typing.py', '_version.py', - 'conftest.py', 'testing.py' ] foreach file: top_level_py_list diff --git a/pandas/tests/pytest.ini b/pandas/tests/pytest.ini index 09c4cd0406f43..769db2cdf30e6 100644 --- a/pandas/tests/pytest.ini +++ b/pandas/tests/pytest.ini @@ -1,7 +1,7 @@ [pytest] # sync minversion with pyproject.toml & install.rst -minversion = 7.0 -addopts = --strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml +minversion = 7.3.2 +addopts = --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml empty_parameter_set_mark = fail_at_collect xfail_strict = true testpaths = pandas @@ -16,6 +16,9 @@ filterwarnings = error::pytest.PytestUnraisableExceptionWarning ignore:.*ssl.SSLSocket:pytest.PytestUnraisableExceptionWarning ignore:.*ssl.SSLSocket:ResourceWarning + # GH 44844: Can remove once minimum matplotlib version >= 3.7 + ignore:.*FileIO:pytest.PytestUnraisableExceptionWarning + ignore:.*BufferedRandom:ResourceWarning ignore::ResourceWarning:asyncio # From plotting doctests ignore:More than 20 figures have been opened:RuntimeWarning @@ -27,18 +30,19 @@ filterwarnings = ignore:a closed node found in the registry:UserWarning:tables ignore:`np.object` is a deprecated:DeprecationWarning:tables ignore:tostring:DeprecationWarning:tables + ignore:distutils Version classes are deprecated:DeprecationWarning:pandas_datareader ignore:distutils Version classes are deprecated:DeprecationWarning:numexpr ignore:distutils Version classes are deprecated:DeprecationWarning:fastparquet ignore:distutils Version classes are deprecated:DeprecationWarning:fsspec junit_family = xunit2 markers = - single_cpu: tests that should run on a single cpu only - slow: mark a test as slow - network: mark a test as network - db: tests requiring a database (mysql or postgres) - clipboard: mark a pd.read_clipboard test - arm_slow: mark a test as slow for arm64 architecture - arraymanager: mark a test to run with ArrayManager enabled + single_cpu: tests that should run on a single cpu only, + slow: mark a test as slow, + network: mark a test as network, + db: tests requiring a database (mysql or postgres), + clipboard: mark a pd.read_clipboard test, + arm_slow: mark a test as slow for arm64 architecture, + arraymanager: mark a test to run with ArrayManager enabled, asyncio_mode = strict diff --git a/pyproject.toml b/pyproject.toml index 845c2a63e84f0..cc840135c17a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -467,54 +467,6 @@ disable = [ "using-constant-test" ] -[tool.pytest.ini_options] -# sync minversion with pyproject.toml & install.rst -minversion = "7.3.2" -addopts = "--strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" -empty_parameter_set_mark = "fail_at_collect" -xfail_strict = true -testpaths = "pandas" -doctest_optionflags = [ - "NORMALIZE_WHITESPACE", - "IGNORE_EXCEPTION_DETAIL", - "ELLIPSIS", -] -filterwarnings = [ - "error:::pandas", - "error::ResourceWarning", - "error::pytest.PytestUnraisableExceptionWarning", - "ignore:.*ssl.SSLSocket:pytest.PytestUnraisableExceptionWarning", - "ignore:.*ssl.SSLSocket:ResourceWarning", - # GH 44844: Can remove once minimum matplotlib version >= 3.7 - "ignore:.*FileIO:pytest.PytestUnraisableExceptionWarning", - "ignore:.*BufferedRandom:ResourceWarning", - "ignore::ResourceWarning:asyncio", - # From plotting doctests - "ignore:More than 20 figures have been opened:RuntimeWarning", - # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 - "ignore:`np.MachAr` is deprecated:DeprecationWarning:numba", - "ignore:.*urllib3:DeprecationWarning:botocore", - "ignore:Setuptools is replacing distutils.:UserWarning:_distutils_hack", - # https://github.com/PyTables/PyTables/issues/822 - "ignore:a closed node found in the registry:UserWarning:tables", - "ignore:`np.object` is a deprecated:DeprecationWarning:tables", - "ignore:tostring:DeprecationWarning:tables", - "ignore:distutils Version classes are deprecated:DeprecationWarning:pandas_datareader", - "ignore:distutils Version classes are deprecated:DeprecationWarning:numexpr", - "ignore:distutils Version classes are deprecated:DeprecationWarning:fastparquet", - "ignore:distutils Version classes are deprecated:DeprecationWarning:fsspec", -] -junit_family = "xunit2" -markers = [ - "single_cpu: tests that should run on a single cpu only", - "slow: mark a test as slow", - "network: mark a test as network", - "db: tests requiring a database (mysql or postgres)", - "clipboard: mark a pd.read_clipboard test", - "arm_slow: mark a test as slow for arm64 architecture", - "arraymanager: mark a test to run with ArrayManager enabled", -] -asyncio_mode = "strict" [tool.mypy] # Import discovery From 339dacc3b371349b720abd69f493341508671191 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 09:41:17 -0700 Subject: [PATCH 03/46] adjust cibuildwheel command? --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index cc840135c17a2..e63babc5f4b98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,6 +152,7 @@ build-verbosity = "3" environment = {LDFLAGS="-Wl,--strip-all"} test-requires = "hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17" test-command = """ + pip install {package}/pandas && PANDAS_CI='1' python -c 'import pandas as pd; \ pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); \ pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' \ From a5a89b39c65c17e57bd51e93dd7d40def188e676 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:18:34 -0700 Subject: [PATCH 04/46] update --- .github/workflows/wheels.yml | 34 ++++++++++++++++++++-------------- pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5f541f1bae1fd..a4788bbaf2869 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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@v3 @@ -62,19 +63,29 @@ jobs: python -m pip install build python -m build --sdist + - name: Build pandas_tests + run: | + cd pandas + python -m build --wheel + - uses: actions/upload-artifact@v3 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 @@ -114,26 +125,20 @@ jobs: # 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@v3 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 + # (I think this is a Github Actions bug) - name: Unzip sdist (macOS) if: ${{ matrix.buildplat[1] == 'macosx_*' }} run: | tar -xzf ./dist/${{ env.sdist_name }} -C ./dist - - name: Output sdist name (macOS) + - name: Output new sdist name (macOS) id: save-path2 shell: bash -el {0} run: echo "sdist_name=$(cd ./dist && ls -d */)" >> "$GITHUB_ENV" @@ -145,6 +150,7 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} + PANDAS_TESTS_LOC: ${{ needs.build_sdist.outputs.pandas_tests_loc }} - name: Set up Python uses: mamba-org/setup-micromamba@v1 diff --git a/pyproject.toml b/pyproject.toml index e63babc5f4b98..d802ab8d96cda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,7 +152,7 @@ build-verbosity = "3" environment = {LDFLAGS="-Wl,--strip-all"} test-requires = "hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17" test-command = """ - pip install {package}/pandas && + pip install $PANDAS_TEST_LOC && PANDAS_CI='1' python -c 'import pandas as pd; \ pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); \ pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' \ From 48df26479166bca6588f68ce742f813e5d1c2ec5 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:42:17 -0700 Subject: [PATCH 05/46] try again --- .github/workflows/wheels.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a4788bbaf2869..58368d8c1c1ae 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -66,7 +66,9 @@ jobs: - name: Build pandas_tests run: | cd pandas - python -m build --wheel + # we want to place the pandas_tests wheel in the same + # dist directory as the sdist + python -m build --wheel --outdir ../dist - uses: actions/upload-artifact@v3 with: @@ -140,13 +142,14 @@ jobs: - 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 wheels uses: pypa/cibuildwheel@v2.15.0 with: - package-dir: ./dist/${{ matrix.buildplat[1] == 'macosx_*' && env.sdist_name || needs.build_sdist.outputs.sdist_file }} + package-dir: ${{ 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] }} From d00e471ba7d3d265f8e7fd62a79f7a902cc41cb7 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:53:13 -0700 Subject: [PATCH 06/46] fix more --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 58368d8c1c1ae..5876cb264e5d7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -138,7 +138,7 @@ jobs: - name: Unzip sdist (macOS) if: ${{ 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 new sdist name (macOS) id: save-path2 @@ -153,7 +153,7 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - PANDAS_TESTS_LOC: ${{ needs.build_sdist.outputs.pandas_tests_loc }} + CIBW_ENVIRONMENT: PANDAS_TESTS_LOC=${{ needs.build_sdist.outputs.pandas_tests_loc }} - name: Set up Python uses: mamba-org/setup-micromamba@v1 From a43c9fe375d435761d547a7652b603a467810d14 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 23 Aug 2023 12:08:32 -0700 Subject: [PATCH 07/46] update --- .github/workflows/wheels.yml | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5876cb264e5d7..73e9a99c440fa 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -153,7 +153,7 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - CIBW_ENVIRONMENT: PANDAS_TESTS_LOC=${{ needs.build_sdist.outputs.pandas_tests_loc }} + CIBW_BEFORE_TEST: pip install ${{ needs.build_sdist.outputs.pandas_tests_loc }} - name: Set up Python uses: mamba-org/setup-micromamba@v1 diff --git a/pyproject.toml b/pyproject.toml index d802ab8d96cda..cc840135c17a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,7 +152,6 @@ build-verbosity = "3" environment = {LDFLAGS="-Wl,--strip-all"} test-requires = "hypothesis>=6.46.1 pytest>=7.3.2 pytest-xdist>=2.2.0 pytest-asyncio>=0.17" test-command = """ - pip install $PANDAS_TEST_LOC && PANDAS_CI='1' python -c 'import pandas as pd; \ pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); \ pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' \ From d6ac87c7dad25c8d308c5794cc8dd44609d28b85 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:28:51 -0500 Subject: [PATCH 08/46] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 72b527b31300b..6340d649550bc 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -145,7 +145,7 @@ jobs: if: ${{ (env.IS_SCHEDULE_DISPATCH != 'true' || env.IS_PUSH == 'true') }} uses: pypa/cibuildwheel@v2.16.5 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] }} From 427ea4e5c36051ca7634d67584e75f94b166a2b2 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 12:39:26 -0500 Subject: [PATCH 09/46] try fix paths --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6340d649550bc..9380e29b7bbb6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -149,7 +149,7 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - CIBW_BEFORE_TEST: pip install ${{ needs.build_sdist.outputs.pandas_tests_loc }} + CIBW_BEFORE_TEST: pip install {project}/${{ 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') }} From 7174249f62377fea41299abac354a0d66daaf2ca Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:05:00 -0500 Subject: [PATCH 10/46] try something --- .github/workflows/wheels.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 72b527b31300b..8af071b7782eb 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -149,7 +149,11 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - CIBW_BEFORE_TEST: pip install ${{ needs.build_sdist.outputs.pandas_tests_loc }} + CIBW_TEST_COMMAND: > + pip install ${{ needs.build_sdist.outputs.pandas_tests_loc }} && + PANDAS_CI='1' python -c 'import pandas as pd; + pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); + pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' - name: Build nightly wheels (with NumPy pre-release) if: ${{ (env.IS_SCHEDULE_DISPATCH == 'true' && env.IS_PUSH != 'true') }} From 9cbbb663c1b623c92dd5822bd8f5e9bf4861c51e Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:11:39 -0500 Subject: [PATCH 11/46] typo --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 596d95ae5be89..c32bdf35e95ab 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -150,7 +150,7 @@ jobs: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} CIBW_TEST_COMMAND: > - pip install ${{ needs.build_sdist.outputs.pandas_tests_loc }} && + pip install {project}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && PANDAS_CI='1' python -c 'import pandas as pd; pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' From 053ad48e9a30e74174c0484a69c109cadf5e340c Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:01:48 -0500 Subject: [PATCH 12/46] try again --- .github/workflows/wheels.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c32bdf35e95ab..7cc114971a7b0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -149,8 +149,13 @@ jobs: 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 + # 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_TEST_COMMAND: > - pip install {project}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && + pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ GITHUB_WORKSPACE }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && PANDAS_CI='1' python -c 'import pandas as pd; pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' From f2573eeffe00402816f9d2ce95f66994911097ed Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:03:25 -0500 Subject: [PATCH 13/46] another error --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7cc114971a7b0..10a91dc2b40c4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -155,7 +155,7 @@ jobs: # (On Linux, need to prefix with /host, since we run builds in a container and the root directory is # mounted to host) CIBW_TEST_COMMAND: > - pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ GITHUB_WORKSPACE }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && + pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ env.GITHUB_WORKSPACE }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && PANDAS_CI='1' python -c 'import pandas as pd; pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' From 547dcc10097e8a9dff9ff5aa82d74cab106c6675 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:13:34 -0500 Subject: [PATCH 14/46] try github.workspace --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 10a91dc2b40c4..dac46a597c002 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -155,7 +155,7 @@ jobs: # (On Linux, need to prefix with /host, since we run builds in a container and the root directory is # mounted to host) CIBW_TEST_COMMAND: > - pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ env.GITHUB_WORKSPACE }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && + pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && PANDAS_CI='1' python -c 'import pandas as pd; pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' From 1044441038f3634296441d252f23431c3e6c656e Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 14:23:05 -0500 Subject: [PATCH 15/46] working? --- .github/workflows/wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index dac46a597c002..765038216ad81 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -149,13 +149,14 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} + CIBW_BEFORE_TEST: pip install pyarrow # Note: Since the sdist is the project directory, it does not contain the tests # 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_TEST_COMMAND: > - pip install ${{ startsWith(matrix.buildplat[1], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && + pip install ${{ startsWith(matrix.buildplat[0], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && PANDAS_CI='1' python -c 'import pandas as pd; pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' From f3c182a2074ece4f293e96b9f843ea4fa315a511 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 15:22:11 -0500 Subject: [PATCH 16/46] go for green on GHA --- .github/workflows/wheels.yml | 9 +++------ MANIFEST.in | 5 ----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 765038216ad81..e1379cd9b390a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -149,17 +149,14 @@ jobs: env: CIBW_PRERELEASE_PYTHONS: True CIBW_BUILD: ${{ matrix.python[0] }}-${{ matrix.buildplat[1] }} - CIBW_BEFORE_TEST: pip install pyarrow # Note: Since the sdist is the project directory, it does not contain the tests # 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_TEST_COMMAND: > - pip install ${{ startsWith(matrix.buildplat[0], 'ubuntu') && '/host'|| '' }}${{ github.workspace }}/${{ needs.build_sdist.outputs.pandas_tests_loc }} && - PANDAS_CI='1' python -c 'import pandas as pd; - pd.test(extra_args=["-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", "--no-strict-data-files"]); - pd.test(extra_args=["-m not clipboard and single_cpu and not slow and not network and not db", "--no-strict-data-files"]);' + CIBW_BEFORE_TEST: > + pip install pyarrow + 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') }} diff --git a/MANIFEST.in b/MANIFEST.in index 35e21d22f3192..e3c874d9bb5ea 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -54,11 +54,6 @@ 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 From 06d3697fc22c9e5be7c95704fd077c5d9efb59a1 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 18:38:36 -0500 Subject: [PATCH 17/46] try build from sdist on circleci --- .circleci/config.yml | 24 +++++++++++++++++++++++- .gitattributes | 6 ------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 90afb1ce29684..13f021426abb6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,25 @@ 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 + 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 + python3 -m build --wheel --outdir ../unzipped-sdist + cd .. + echo "sdist_name=./unzipped-sdist" >> "$BASH_ENV" + echo "pandas_tests_loc=$(ls ./unzipped-sdist/*.whl)" >> "$BASH_ENV" + - 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 @@ -76,10 +95,13 @@ 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 + cibuildwheel ${sdist_name} --prerelease-pythons --output-dir wheelhouse environment: CIBW_BUILD: << parameters.cibw-build >> + CIBW_BEFORE_TEST: > + pip install pyarrow + pip install {project}/${pandas_tests_loc} - run: name: Install Anaconda Client & Upload Wheels diff --git a/.gitattributes b/.gitattributes index 0ea7db74200ca..1ce5bd95ba53a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -77,11 +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 From 13063d8d04b95a34cfac9769889429c975010c15 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 19:14:34 -0500 Subject: [PATCH 18/46] debug circleci --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 13f021426abb6..ecaffecc894fc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,6 +85,7 @@ jobs: cd .. echo "sdist_name=./unzipped-sdist" >> "$BASH_ENV" echo "pandas_tests_loc=$(ls ./unzipped-sdist/*.whl)" >> "$BASH_ENV" + ls ./unzipped-sdist/*.whl - run: name: Build aarch64 wheels @@ -95,6 +96,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 + echo ${pandas_tests_loc} + CIBW_BEFORE_TEST="pip install pyarrow && pip install {project}/${pandas_tests_loc}" cibuildwheel ${sdist_name} --prerelease-pythons --output-dir wheelhouse environment: From 825494327e425dddbd22c2c3c4fd2c4d75ef51bd Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 19:14:43 -0500 Subject: [PATCH 19/46] debug circleci --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ecaffecc894fc..1418cf1dc92cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -102,9 +102,6 @@ jobs: environment: CIBW_BUILD: << parameters.cibw-build >> - CIBW_BEFORE_TEST: > - pip install pyarrow - pip install {project}/${pandas_tests_loc} - run: name: Install Anaconda Client & Upload Wheels From 9ed91e00e5f306db4b1308d1ebe96e2b116eea58 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 19:22:25 -0500 Subject: [PATCH 20/46] try exporting? --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1418cf1dc92cd..b0afe9715dc2e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,7 +97,7 @@ jobs: export CIBW_ENVIRONMENT="PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" fi echo ${pandas_tests_loc} - CIBW_BEFORE_TEST="pip install pyarrow && pip install {project}/${pandas_tests_loc}" + export CIBW_BEFORE_TEST="pip install pyarrow && pip install {project}/${pandas_tests_loc}" cibuildwheel ${sdist_name} --prerelease-pythons --output-dir wheelhouse environment: From d4502af7ebcccbfb44153a55a434d2dee168def2 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 22:48:14 -0500 Subject: [PATCH 21/46] green everything except musl? --- .circleci/config.yml | 10 ++++++---- .github/workflows/wheels.yml | 2 +- pandas/pyproject.toml | 5 ++++- pandas/util/_exceptions.py | 12 ++++++++++++ pandas/util/_tester.py | 1 + 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b0afe9715dc2e..42182ecfc0730 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 jobs: test-arm: machine: - image: ubuntu-2004:2022.04.1 + image: default resource_class: arm.large environment: ENV_FILE: ci/deps/circle-310-arm64.yaml @@ -46,7 +46,7 @@ jobs: cibw-build: type: string machine: - image: ubuntu-2004:2022.04.1 + image: default resource_class: arm.large environment: TRIGGER_SOURCE: << pipeline.trigger_source >> @@ -75,13 +75,15 @@ jobs: # (unlike Github Actions there is no host access using cibuildwheel with CircleCI) name: Build the sdist command: | - pip3 install build + pip3 install build setuptools-scm 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 - python3 -m build --wheel --outdir ../unzipped-sdist + # 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" echo "pandas_tests_loc=$(ls ./unzipped-sdist/*.whl)" >> "$BASH_ENV" diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e1379cd9b390a..ab7ee872b398c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -68,7 +68,7 @@ jobs: cd pandas # we want to place the pandas_tests wheel in the same # dist directory as the sdist - python -m build --wheel --outdir ../dist + python -m build --wheel --outdir ../dist --no-isolation - uses: actions/upload-artifact@v4 with: diff --git a/pandas/pyproject.toml b/pandas/pyproject.toml index d8d247dda9097..e5ad41a413d4c 100644 --- a/pandas/pyproject.toml +++ b/pandas/pyproject.toml @@ -9,7 +9,7 @@ requires = [ name="pandas-tests" # Note: The version is hardcoded since the pandas version has to # match the tests version. Remember to bump both! -version="2.1" +dynamic = ["version"] #dependencies=[ # "pandas==2.1.0" #] @@ -18,5 +18,8 @@ requires-python=">=3.9" [tool.setuptools] package-dir={"pandas_tests"= "tests"} +[tool.setuptools_scm] +root = ".." + [tool.setuptools.package-data] "pandas_tests"=["pytest.ini"] diff --git a/pandas/util/_exceptions.py b/pandas/util/_exceptions.py index 5f50838d37315..ef486f96efb1d 100644 --- a/pandas/util/_exceptions.py +++ b/pandas/util/_exceptions.py @@ -42,6 +42,16 @@ def find_stack_level() -> int: pkg_dir = os.path.dirname(pd.__file__) test_dir = os.path.join(pkg_dir, "tests") + # Note: we also want to account for stuff being in the pandas_tests test_dir + try: + # can't use import_optional_dependency cause it uses find_stack_level and we'd + # have ourselves a circular import :( + import pandas_tests + + pd_tests_dir = os.path.dirname(pandas_tests.__file__) + except ImportError: + pd_tests_dir = None + # https://stackoverflow.com/questions/17407119/python-inspect-stack-is-slow frame: FrameType | None = inspect.currentframe() try: @@ -49,6 +59,8 @@ def find_stack_level() -> int: while frame: filename = inspect.getfile(frame) if filename.startswith(pkg_dir) and not filename.startswith(test_dir): + if pd_tests_dir is not None and filename.startswith(pd_tests_dir): + break frame = frame.f_back n += 1 else: diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 9bb4c49445f32..335ea93d3d073 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -46,6 +46,7 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non ] cmd += [PKG] joined = " ".join(cmd) + joined += " -v -k 'test_from_pandas_array[m8[ns]]" print(f"running: pytest {joined}") sys.exit(pytest.main(cmd)) From b61a6a4c2e7e6766bd9ce6fcd07a6a337a6b56f4 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 22:52:26 -0500 Subject: [PATCH 22/46] add missing deps? --- .circleci/config.yml | 2 +- .github/workflows/wheels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 42182ecfc0730..7c9314b39655e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,7 +75,7 @@ jobs: # (unlike Github Actions there is no host access using cibuildwheel with CircleCI) name: Build the sdist command: | - pip3 install build setuptools-scm + pip3 install build setuptools-scm wheel python3 -m build --sdist sdist_name=$(ls ./dist/*.tar.gz) mkdir unzipped-sdist diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ab7ee872b398c..1778d67398e19 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -60,7 +60,7 @@ 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 From 1a6531c5df57abeee53d1152b6f573800e895b3a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:12:56 -0500 Subject: [PATCH 23/46] upload wheels --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1778d67398e19..8d2e9645e73d7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -202,6 +202,7 @@ jobs: 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 From 799687fccc3fdf241257e09ca3b5d56cf6fdd5fe Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:47:27 -0700 Subject: [PATCH 24/46] try something --- pandas/tests/__init__.py | 4 ++++ pandas/util/_tester.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/__init__.py b/pandas/tests/__init__.py index e69de29bb2d1d..705748b0fc723 100644 --- a/pandas/tests/__init__.py +++ b/pandas/tests/__init__.py @@ -0,0 +1,4 @@ +try: + from pandas_tests import * # noqa: F403 +except ImportError: + pass diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 2be0ddacfdf14..c89dda23b7412 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -47,7 +47,6 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non ] cmd += [PKG] joined = " ".join(cmd) - joined += " -v -k 'test_from_pandas_array[m8[ns]]" print(f"running: pytest {joined}") sys.exit(pytest.main(cmd)) From 1d6137b9b4d58e23378d350c176bec9d2a591169 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 16 Mar 2024 20:39:09 -0700 Subject: [PATCH 25/46] change pytest target --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 855973a22886a..0518f82a1b799 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -85,7 +85,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 From 792c01166e2b4e64f79b6944371d0b4e089cc132 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 16 Mar 2024 21:25:07 -0700 Subject: [PATCH 26/46] go for green --- pandas/__init__.py | 11 +++++++++++ pandas/{tests => }/pytest.ini | 0 pandas/tests/__init__.py | 4 ---- 3 files changed, 11 insertions(+), 4 deletions(-) rename pandas/{tests => }/pytest.ini (100%) diff --git a/pandas/__init__.py b/pandas/__init__.py index f7ae91dd847f7..496282c1c20c5 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -189,6 +189,17 @@ del get_versions, v +def __getattr__(name): + import importlib + + if name == "tests": + return importlib.import_module("pandas_tests") + if name.startswith("tests."): + to_import = name.replace("tests", "pandas_tests") + return importlib.import_module(to_import) + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + + # module level doc-string __doc__ = """ pandas - a powerful data analysis and manipulation library for Python diff --git a/pandas/tests/pytest.ini b/pandas/pytest.ini similarity index 100% rename from pandas/tests/pytest.ini rename to pandas/pytest.ini diff --git a/pandas/tests/__init__.py b/pandas/tests/__init__.py index 705748b0fc723..e69de29bb2d1d 100644 --- a/pandas/tests/__init__.py +++ b/pandas/tests/__init__.py @@ -1,4 +0,0 @@ -try: - from pandas_tests import * # noqa: F403 -except ImportError: - pass From 2a783457408ee2a7dc004276e1ad2cd18c64dbdb Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sat, 16 Mar 2024 21:35:22 -0700 Subject: [PATCH 27/46] fix import redirects --- pandas/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index 496282c1c20c5..3a962757214d2 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -195,7 +195,7 @@ def __getattr__(name): if name == "tests": return importlib.import_module("pandas_tests") if name.startswith("tests."): - to_import = name.replace("tests", "pandas_tests") + to_import = name.replace("tests", "pandas_tests.tests") return importlib.import_module(to_import) raise AttributeError(f"module {__name__!r} has no attribute {name!r}") From 16f59645034c6abb5a2d56c06c2850c140fb33c0 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 08:28:31 -0700 Subject: [PATCH 28/46] try something --- pandas/__init__.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index 3a962757214d2..99f28ffcc69db 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -189,15 +189,13 @@ del get_versions, v -def __getattr__(name): - import importlib +try: + import sys + import pandas_tests - if name == "tests": - return importlib.import_module("pandas_tests") - if name.startswith("tests."): - to_import = name.replace("tests", "pandas_tests.tests") - return importlib.import_module(to_import) - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + sys.modules["pandas.tests"] = pandas_tests +except ImportError: + pass # module level doc-string From b9119459700bb98518e9f7ea84e7d873230f731d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:01:02 -0700 Subject: [PATCH 29/46] go for green take 2 --- .github/workflows/unit-tests.yml | 8 ++++---- pandas/__init__.py | 3 +++ pandas/{ => tests}/pytest.ini | 0 3 files changed, 7 insertions(+), 4 deletions(-) rename pandas/{ => tests}/pytest.ini (100%) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 0518f82a1b799..8ea6c40c637c1 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -194,7 +194,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' @@ -246,7 +246,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://github.community/t/concurrecy-not-work-for-push/183068/7 group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-32bit @@ -288,7 +288,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://github.community/t/concurrecy-not-work-for-push/183068/7 group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-musl @@ -336,7 +336,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 diff --git a/pandas/__init__.py b/pandas/__init__.py index 99f28ffcc69db..aa89164b62ef1 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -194,6 +194,9 @@ import pandas_tests sys.modules["pandas.tests"] = pandas_tests + + del sys + del pandas_tests except ImportError: pass diff --git a/pandas/pytest.ini b/pandas/tests/pytest.ini similarity index 100% rename from pandas/pytest.ini rename to pandas/tests/pytest.ini From beb64dc8a7edf348bd141d7856318931d2650494 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:26:43 -0700 Subject: [PATCH 30/46] try fixing windows --- .github/workflows/wheels.yml | 1 + pandas/__init__.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8d2e9645e73d7..bb949d7adf5ea 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -195,6 +195,7 @@ 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 ${{ needs.build_sdist.outputs.pandas_tests_loc }}; 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 diff --git a/pandas/__init__.py b/pandas/__init__.py index aa89164b62ef1..bfa3ae0245c48 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -188,18 +188,19 @@ __git_version__ = v.get("full-revisionid") del get_versions, v +import sys try: - import sys import pandas_tests sys.modules["pandas.tests"] = pandas_tests - del sys del pandas_tests except ImportError: pass +del sys + # module level doc-string __doc__ = """ From 3135e675319d0a6531774812833e8d8d3fc11d24 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 10:58:13 -0700 Subject: [PATCH 31/46] try again to fix windows --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index bb949d7adf5ea..ddd633c411b3f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -195,7 +195,7 @@ 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 ${{ needs.build_sdist.outputs.pandas_tests_loc }}; + 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 From d17ddaf05e7b7428daa0d6c931d7bb3e1af46a15 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:10:44 -0700 Subject: [PATCH 32/46] Update wheels.yml --- .github/workflows/wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ddd633c411b3f..f07b3ed7f4a36 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -155,7 +155,6 @@ jobs: # (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 pyarrow 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) From 50410ad18c6017c0c37c4ff0173d0309fa03fac2 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 17:11:32 -0700 Subject: [PATCH 33/46] Update config.yml --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7c9314b39655e..f57458615e6b0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,8 +98,7 @@ 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 - echo ${pandas_tests_loc} - export CIBW_BEFORE_TEST="pip install pyarrow && pip install {project}/${pandas_tests_loc}" + export CIBW_BEFORE_TEST="pip install {project}/${pandas_tests_loc}" cibuildwheel ${sdist_name} --prerelease-pythons --output-dir wheelhouse environment: From 8d68f7d982a08cbb354bd9d1b8f169b67ea33e4d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:24:29 -0700 Subject: [PATCH 34/46] try for green again --- .circleci/config.yml | 2 +- pandas/util/_tester.py | 9 +++++---- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f57458615e6b0..d580a62d20d0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index c89dda23b7412..72a4c3c687b9e 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -31,21 +31,22 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non running: pytest... """ pytest = import_optional_dependency("pytest") - pandas_tests = import_optional_dependency("pandas_tests") - PKG = os.path.dirname(pandas_tests.__file__) import_optional_dependency("hypothesis") cmd = ["-m not slow and not network and not db"] if extra_args: if not isinstance(extra_args, list): extra_args = [extra_args] cmd = extra_args + # Don't require pandas_tests if only running doctests if run_doctests: cmd = [ "--doctest-modules", "--doctest-cython", - f"--ignore={os.path.join(PKG, 'tests')}", ] - cmd += [PKG] + else: + pandas_tests = import_optional_dependency("pandas_tests") + PKG = os.path.dirname(pandas_tests.__file__) + cmd += [PKG] joined = " ".join(cmd) print(f"running: pytest {joined}") sys.exit(pytest.main(cmd)) diff --git a/pyproject.toml b/pyproject.toml index c824970c6051f..e301ad304065c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -165,7 +165,7 @@ repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}" [[tool.cibuildwheel.overrides]] select = "*-musllinux*" -before-test = "apk update && apk add musl-locales" +before-all = "apk update && apk add musl-locales" [[tool.cibuildwheel.overrides]] select = "*-win*" From 98ec61a05fce87ec5ea6a3dbcba0440566faed36 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:41:31 -0700 Subject: [PATCH 35/46] try to fix doctests? --- pandas/util/_tester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 72a4c3c687b9e..f88c0a80b54b5 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -43,10 +43,11 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non "--doctest-modules", "--doctest-cython", ] + PKG = os.path.dirname(os.path.dirname(__file__)) else: pandas_tests = import_optional_dependency("pandas_tests") PKG = os.path.dirname(pandas_tests.__file__) - cmd += [PKG] + cmd += [PKG] joined = " ".join(cmd) print(f"running: pytest {joined}") sys.exit(pytest.main(cmd)) From b8e3588e0342702f4c259d16fdbe66c6ef133954 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:49:25 -0700 Subject: [PATCH 36/46] try doctests again --- pandas/util/_tester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index f88c0a80b54b5..3de7a9fad4432 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -39,11 +39,12 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non cmd = extra_args # Don't require pandas_tests if only running doctests if run_doctests: + PKG = os.path.dirname(os.path.dirname(__file__)) cmd = [ "--doctest-modules", "--doctest-cython", + f"--ignore={os.path.join(PKG, 'tests')}", ] - PKG = os.path.dirname(os.path.dirname(__file__)) else: pandas_tests = import_optional_dependency("pandas_tests") PKG = os.path.dirname(pandas_tests.__file__) From a19f2e6d1945367be9b6e39ba9dd4199242ed90d Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:14:59 -0700 Subject: [PATCH 37/46] get rid of cython doctests --- .github/workflows/code-checks.yml | 19 +++++++------------ ci/code_checks.sh | 6 +++++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 24b2de251ce8e..33354bce32306 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -43,24 +43,19 @@ jobs: - name: Build Pandas id: build uses: ./.github/actions/build_pandas - with: - editable: false # The following checks are independent of each other and should still be run if one fails - # TODO: The doctests have to be run first right now, since the Cython doctests only work - # with pandas installed in non-editable mode - # This can be removed once pytest-cython doesn't require C extensions to be installed inplace - name: Run doctests - run: cd ci && ./code_checks.sh doctests + run: ci/code_checks.sh doctests if: ${{ steps.build.outcome == 'success' && always() }} - - name: Install pandas in editable mode - id: build-editable - if: ${{ steps.build.outcome == 'success' && always() }} - uses: ./.github/actions/build_pandas - with: - editable: true +# - name: Install pandas in editable mode +# id: build-editable +# if: ${{ steps.build.outcome == 'success' && always() }} +# uses: ./.github/actions/build_pandas +# with: +# editable: true - name: Check for no warnings when building single-page docs run: ci/code_checks.sh single-docs diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 4b8e632f3246c..893c08faec9b8 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -57,7 +57,11 @@ fi if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then MSG='Python and Cython Doctests' ; echo $MSG - python -c 'import pandas as pd; pd.test(run_doctests=True)' + # pytest will get confused by how meson-python does editable installs + # and will try to raise a ImportMismatchError + # we can ignore this + # https://github.com/pytest-dev/pytest/issues/2042 + PY_IGNORE_IMPORTMISMATCH=1 python -c 'import pandas as pd; pd.test(run_doctests=True)' RET=$(($RET + $?)) ; echo $MSG "DONE" fi From b4aa06230bf893227b5606f20f6bef154d9452f1 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:36:40 -0700 Subject: [PATCH 38/46] try again --- .github/workflows/code-checks.yml | 19 ++++++++++++------- ci/code_checks.sh | 4 ---- pandas/conftest.py | 22 ++++++++++++++++++++++ pandas/meson.build | 1 + pandas/tests/conftest.py | 11 ----------- 5 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 pandas/conftest.py diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 33354bce32306..24b2de251ce8e 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -43,19 +43,24 @@ jobs: - name: Build Pandas id: build uses: ./.github/actions/build_pandas + with: + editable: false # The following checks are independent of each other and should still be run if one fails + # TODO: The doctests have to be run first right now, since the Cython doctests only work + # with pandas installed in non-editable mode + # This can be removed once pytest-cython doesn't require C extensions to be installed inplace - name: Run doctests - run: ci/code_checks.sh doctests + run: cd ci && ./code_checks.sh doctests if: ${{ steps.build.outcome == 'success' && always() }} -# - name: Install pandas in editable mode -# id: build-editable -# if: ${{ steps.build.outcome == 'success' && always() }} -# uses: ./.github/actions/build_pandas -# with: -# editable: true + - name: Install pandas in editable mode + id: build-editable + if: ${{ steps.build.outcome == 'success' && always() }} + uses: ./.github/actions/build_pandas + with: + editable: true - name: Check for no warnings when building single-page docs run: ci/code_checks.sh single-docs diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 893c08faec9b8..629282e7ad9ab 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -57,10 +57,6 @@ fi if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then MSG='Python and Cython Doctests' ; echo $MSG - # pytest will get confused by how meson-python does editable installs - # and will try to raise a ImportMismatchError - # we can ignore this - # https://github.com/pytest-dev/pytest/issues/2042 PY_IGNORE_IMPORTMISMATCH=1 python -c 'import pandas as pd; pd.test(run_doctests=True)' RET=$(($RET + $?)) ; echo $MSG "DONE" diff --git a/pandas/conftest.py b/pandas/conftest.py new file mode 100644 index 0000000000000..9d30b086f7b28 --- /dev/null +++ b/pandas/conftest.py @@ -0,0 +1,22 @@ +""" +Just a conftest file for doctest stuff + +The main conftest file is in pandas/tests/conftest.py +""" + +import pytest + + +# https://github.com/pytest-dev/pytest/issues/11873 +# Would like to avoid autouse=True, but cannot as of pytest 8.0.0 +@pytest.fixture(autouse=True) +def add_doctest_imports(doctest_namespace) -> None: + """ + Make `np` and `pd` names available for doctests. + """ + import numpy as np + + import pandas as pd + + doctest_namespace["np"] = np + doctest_namespace["pd"] = pd diff --git a/pandas/meson.build b/pandas/meson.build index 6afb614fd06c4..a6ca8b68e0460 100644 --- a/pandas/meson.build +++ b/pandas/meson.build @@ -54,6 +54,7 @@ top_level_py_list = [ '__init__.py', '_typing.py', '_version.py', + 'conftest.py', 'testing.py' ] py.install_sources(top_level_py_list, subdir: 'pandas') diff --git a/pandas/tests/conftest.py b/pandas/tests/conftest.py index 191b4a908a0df..5ec7c503559f4 100644 --- a/pandas/tests/conftest.py +++ b/pandas/tests/conftest.py @@ -239,17 +239,6 @@ def pytest_collection_modifyitems(items, config) -> None: # ---------------------------------------------------------------- -# https://github.com/pytest-dev/pytest/issues/11873 -# Would like to avoid autouse=True, but cannot as of pytest 8.0.0 -@pytest.fixture(autouse=True) -def add_doctest_imports(doctest_namespace) -> None: - """ - Make `np` and `pd` names available for doctests. - """ - doctest_namespace["np"] = np - doctest_namespace["pd"] = pd - - @pytest.fixture(autouse=True) def configure_tests() -> None: """ From a2ba3bffa1918c02e852a57283de9e1075cc1c27 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:54:00 -0700 Subject: [PATCH 39/46] add back some config options to pyproject.toml --- pandas/conftest.py | 138 +++++++++++++++++++++++++++++++++++++++ pandas/pyproject.toml | 9 +++ pandas/tests/conftest.py | 130 +----------------------------------- 3 files changed, 149 insertions(+), 128 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 9d30b086f7b28..548c1ed52daa4 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -4,7 +4,25 @@ The main conftest file is in pandas/tests/conftest.py """ +from datetime import ( + timedelta, + timezone, +) +import zoneinfo + +from dateutil.tz import ( + tzlocal, + tzutc, +) import pytest +from pytz import FixedOffset + +import pandas.util._test_decorators as td + +try: + zoneinfo.ZoneInfo("UTC") +except zoneinfo.ZoneInfoNotFoundError: + zoneinfo = None # type: ignore[assignment] # https://github.com/pytest-dev/pytest/issues/11873 @@ -20,3 +38,123 @@ def add_doctest_imports(doctest_namespace) -> None: doctest_namespace["np"] = np doctest_namespace["pd"] = pd + + +def ignore_doctest_warning(item: pytest.Item, path: str, message: str) -> None: + """Ignore doctest warning. + + Parameters + ---------- + item : pytest.Item + pytest test item. + path : str + Module path to Python object, e.g. "pandas.core.frame.DataFrame.append". A + warning will be filtered when item.name ends with in given path. So it is + sufficient to specify e.g. "DataFrame.append". + message : str + Message to be filtered. + """ + if item.name.endswith(path): + item.add_marker(pytest.mark.filterwarnings(f"ignore:{message}")) + + +def pytest_collection_modifyitems(items, config) -> None: + is_doctest = config.getoption("--doctest-modules") or config.getoption( + "--doctest-cython", default=False + ) + + # Warnings from doctests that can be ignored; place reason in comment above. + # Each entry specifies (path, message) - see the ignore_doctest_warning function + ignored_doctest_warnings = [ + ("is_int64_dtype", "is_int64_dtype is deprecated"), + ("is_interval_dtype", "is_interval_dtype is deprecated"), + ("is_period_dtype", "is_period_dtype is deprecated"), + ("is_datetime64tz_dtype", "is_datetime64tz_dtype is deprecated"), + ("is_categorical_dtype", "is_categorical_dtype is deprecated"), + ("is_sparse", "is_sparse is deprecated"), + ("DataFrameGroupBy.fillna", "DataFrameGroupBy.fillna is deprecated"), + ("NDFrame.replace", "The 'method' keyword"), + ("NDFrame.replace", "Series.replace without 'value'"), + ("NDFrame.clip", "Downcasting behavior in Series and DataFrame methods"), + ("Series.idxmin", "The behavior of Series.idxmin"), + ("Series.idxmax", "The behavior of Series.idxmax"), + ("SeriesGroupBy.fillna", "SeriesGroupBy.fillna is deprecated"), + ("SeriesGroupBy.idxmin", "The behavior of Series.idxmin"), + ("SeriesGroupBy.idxmax", "The behavior of Series.idxmax"), + # Docstring divides by zero to show behavior difference + ("missing.mask_zero_div_zero", "divide by zero encountered"), + ( + "pandas.core.generic.NDFrame.first", + "first is deprecated and will be removed in a future version. " + "Please create a mask and filter using `.loc` instead", + ), + ( + "Resampler.fillna", + "DatetimeIndexResampler.fillna is deprecated", + ), + ( + "DataFrameGroupBy.fillna", + "DataFrameGroupBy.fillna with 'method' is deprecated", + ), + ("read_parquet", "Passing a BlockManager to DataFrame is deprecated"), + ] + + if is_doctest: + for item in items: + for path, message in ignored_doctest_warnings: + ignore_doctest_warning(item, path, message) + + +# ---------------------------------------------------------------- +# Time zones +# ---------------------------------------------------------------- +TIMEZONES = [ + None, + "UTC", + "US/Eastern", + "Asia/Tokyo", + "dateutil/US/Pacific", + "dateutil/Asia/Singapore", + "+01:15", + "-02:15", + "UTC+01:15", + "UTC-02:15", + tzutc(), + tzlocal(), + FixedOffset(300), + FixedOffset(0), + FixedOffset(-300), + timezone.utc, + timezone(timedelta(hours=1)), + timezone(timedelta(hours=-1), name="foo"), +] +if zoneinfo is not None: + TIMEZONES.extend( + [ + zoneinfo.ZoneInfo("US/Pacific"), # type: ignore[list-item] + zoneinfo.ZoneInfo("UTC"), # type: ignore[list-item] + ] + ) +TIMEZONE_IDS = [repr(i) for i in TIMEZONES] + + +@td.parametrize_fixture_doc(str(TIMEZONE_IDS)) +@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS) +def tz_naive_fixture(request): + """ + Fixture for trying timezones including default (None): {0} + """ + return request.param + + +@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:])) +@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:]) +def tz_aware_fixture(request): + """ + Fixture for trying explicit timezones: {0} + """ + return request.param + + +# Generate cartesian product of tz_aware_fixture: +tz_aware_fixture2 = tz_aware_fixture diff --git a/pandas/pyproject.toml b/pandas/pyproject.toml index e5ad41a413d4c..1eb3794b44105 100644 --- a/pandas/pyproject.toml +++ b/pandas/pyproject.toml @@ -23,3 +23,12 @@ root = ".." [tool.setuptools.package-data] "pandas_tests"=["pytest.ini"] + +# Only present to specify options for the doctests +[tool.pytest.ini_options] +minversion = "7.3.2" +doctest_optionflags = [ + "NORMALIZE_WHITESPACE", + "IGNORE_EXCEPTION_DETAIL", + "ELLIPSIS", +] diff --git a/pandas/tests/conftest.py b/pandas/tests/conftest.py index 5ec7c503559f4..8df943d087a1f 100644 --- a/pandas/tests/conftest.py +++ b/pandas/tests/conftest.py @@ -38,18 +38,12 @@ ) import uuid -from dateutil.tz import ( - tzlocal, - tzutc, -) +from dateutil.tz import tzutc import hypothesis from hypothesis import strategies as st import numpy as np import pytest -from pytz import ( - FixedOffset, - utc, -) +from pytz import utc import pandas.util._test_decorators as td @@ -117,71 +111,6 @@ def pytest_addoption(parser) -> None: ) -def ignore_doctest_warning(item: pytest.Item, path: str, message: str) -> None: - """Ignore doctest warning. - - Parameters - ---------- - item : pytest.Item - pytest test item. - path : str - Module path to Python object, e.g. "pandas.core.frame.DataFrame.append". A - warning will be filtered when item.name ends with in given path. So it is - sufficient to specify e.g. "DataFrame.append". - message : str - Message to be filtered. - """ - if item.name.endswith(path): - item.add_marker(pytest.mark.filterwarnings(f"ignore:{message}")) - - -def pytest_collection_modifyitems(items, config) -> None: - is_doctest = config.getoption("--doctest-modules") or config.getoption( - "--doctest-cython", default=False - ) - - # Warnings from doctests that can be ignored; place reason in comment above. - # Each entry specifies (path, message) - see the ignore_doctest_warning function - ignored_doctest_warnings = [ - ("is_int64_dtype", "is_int64_dtype is deprecated"), - ("is_interval_dtype", "is_interval_dtype is deprecated"), - ("is_period_dtype", "is_period_dtype is deprecated"), - ("is_datetime64tz_dtype", "is_datetime64tz_dtype is deprecated"), - ("is_categorical_dtype", "is_categorical_dtype is deprecated"), - ("is_sparse", "is_sparse is deprecated"), - ("DataFrameGroupBy.fillna", "DataFrameGroupBy.fillna is deprecated"), - ("NDFrame.replace", "The 'method' keyword"), - ("NDFrame.replace", "Series.replace without 'value'"), - ("NDFrame.clip", "Downcasting behavior in Series and DataFrame methods"), - ("Series.idxmin", "The behavior of Series.idxmin"), - ("Series.idxmax", "The behavior of Series.idxmax"), - ("SeriesGroupBy.fillna", "SeriesGroupBy.fillna is deprecated"), - ("SeriesGroupBy.idxmin", "The behavior of Series.idxmin"), - ("SeriesGroupBy.idxmax", "The behavior of Series.idxmax"), - # Docstring divides by zero to show behavior difference - ("missing.mask_zero_div_zero", "divide by zero encountered"), - ( - "pandas.core.generic.NDFrame.first", - "first is deprecated and will be removed in a future version. " - "Please create a mask and filter using `.loc` instead", - ), - ( - "Resampler.fillna", - "DatetimeIndexResampler.fillna is deprecated", - ), - ( - "DataFrameGroupBy.fillna", - "DataFrameGroupBy.fillna with 'method' is deprecated", - ), - ("read_parquet", "Passing a BlockManager to DataFrame is deprecated"), - ] - - if is_doctest: - for item in items: - for path, message in ignored_doctest_warnings: - ignore_doctest_warning(item, path, message) - - hypothesis_health_checks = [hypothesis.HealthCheck.too_slow] if Version(hypothesis.__version__) >= Version("6.83.2"): hypothesis_health_checks.append(hypothesis.HealthCheck.differing_executors) @@ -1169,61 +1098,6 @@ def deco(*args): return deco -# ---------------------------------------------------------------- -# Time zones -# ---------------------------------------------------------------- -TIMEZONES = [ - None, - "UTC", - "US/Eastern", - "Asia/Tokyo", - "dateutil/US/Pacific", - "dateutil/Asia/Singapore", - "+01:15", - "-02:15", - "UTC+01:15", - "UTC-02:15", - tzutc(), - tzlocal(), - FixedOffset(300), - FixedOffset(0), - FixedOffset(-300), - timezone.utc, - timezone(timedelta(hours=1)), - timezone(timedelta(hours=-1), name="foo"), -] -if zoneinfo is not None: - TIMEZONES.extend( - [ - zoneinfo.ZoneInfo("US/Pacific"), # type: ignore[list-item] - zoneinfo.ZoneInfo("UTC"), # type: ignore[list-item] - ] - ) -TIMEZONE_IDS = [repr(i) for i in TIMEZONES] - - -@td.parametrize_fixture_doc(str(TIMEZONE_IDS)) -@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS) -def tz_naive_fixture(request): - """ - Fixture for trying timezones including default (None): {0} - """ - return request.param - - -@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:])) -@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:]) -def tz_aware_fixture(request): - """ - Fixture for trying explicit timezones: {0} - """ - return request.param - - -# Generate cartesian product of tz_aware_fixture: -tz_aware_fixture2 = tz_aware_fixture - - _UTCS = ["utc", "dateutil/UTC", utc, tzutc(), timezone.utc] if zoneinfo is not None: _UTCS.append(zoneinfo.ZoneInfo("UTC")) From 7ee6adc28396e9dc025f6c42cacacf2604948d39 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:13:52 -0700 Subject: [PATCH 40/46] meson changes --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 06623a305ab54..1fbeb688ee676 100644 --- a/meson.build +++ b/meson.build @@ -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' ) From 19fa7f9c255ca3b98a024c2d250f4e228104d05a Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 11:25:07 -0700 Subject: [PATCH 41/46] try moving back stuff to the original conftest --- pandas/conftest.py | 73 ---------------------------------------- pandas/tests/conftest.py | 65 +++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 75 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 548c1ed52daa4..d5e3d6ff72aad 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -4,25 +4,7 @@ The main conftest file is in pandas/tests/conftest.py """ -from datetime import ( - timedelta, - timezone, -) -import zoneinfo - -from dateutil.tz import ( - tzlocal, - tzutc, -) import pytest -from pytz import FixedOffset - -import pandas.util._test_decorators as td - -try: - zoneinfo.ZoneInfo("UTC") -except zoneinfo.ZoneInfoNotFoundError: - zoneinfo = None # type: ignore[assignment] # https://github.com/pytest-dev/pytest/issues/11873 @@ -103,58 +85,3 @@ def pytest_collection_modifyitems(items, config) -> None: for item in items: for path, message in ignored_doctest_warnings: ignore_doctest_warning(item, path, message) - - -# ---------------------------------------------------------------- -# Time zones -# ---------------------------------------------------------------- -TIMEZONES = [ - None, - "UTC", - "US/Eastern", - "Asia/Tokyo", - "dateutil/US/Pacific", - "dateutil/Asia/Singapore", - "+01:15", - "-02:15", - "UTC+01:15", - "UTC-02:15", - tzutc(), - tzlocal(), - FixedOffset(300), - FixedOffset(0), - FixedOffset(-300), - timezone.utc, - timezone(timedelta(hours=1)), - timezone(timedelta(hours=-1), name="foo"), -] -if zoneinfo is not None: - TIMEZONES.extend( - [ - zoneinfo.ZoneInfo("US/Pacific"), # type: ignore[list-item] - zoneinfo.ZoneInfo("UTC"), # type: ignore[list-item] - ] - ) -TIMEZONE_IDS = [repr(i) for i in TIMEZONES] - - -@td.parametrize_fixture_doc(str(TIMEZONE_IDS)) -@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS) -def tz_naive_fixture(request): - """ - Fixture for trying timezones including default (None): {0} - """ - return request.param - - -@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:])) -@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:]) -def tz_aware_fixture(request): - """ - Fixture for trying explicit timezones: {0} - """ - return request.param - - -# Generate cartesian product of tz_aware_fixture: -tz_aware_fixture2 = tz_aware_fixture diff --git a/pandas/tests/conftest.py b/pandas/tests/conftest.py index 8df943d087a1f..3b1656c41e14a 100644 --- a/pandas/tests/conftest.py +++ b/pandas/tests/conftest.py @@ -38,12 +38,18 @@ ) import uuid -from dateutil.tz import tzutc +from dateutil.tz import ( + tzlocal, + tzutc, +) import hypothesis from hypothesis import strategies as st import numpy as np import pytest -from pytz import utc +from pytz import ( + FixedOffset, + utc, +) import pandas.util._test_decorators as td @@ -1098,6 +1104,61 @@ def deco(*args): return deco +# ---------------------------------------------------------------- +# Time zones +# ---------------------------------------------------------------- +TIMEZONES = [ + None, + "UTC", + "US/Eastern", + "Asia/Tokyo", + "dateutil/US/Pacific", + "dateutil/Asia/Singapore", + "+01:15", + "-02:15", + "UTC+01:15", + "UTC-02:15", + tzutc(), + tzlocal(), + FixedOffset(300), + FixedOffset(0), + FixedOffset(-300), + timezone.utc, + timezone(timedelta(hours=1)), + timezone(timedelta(hours=-1), name="foo"), +] +if zoneinfo is not None: + TIMEZONES.extend( + [ + zoneinfo.ZoneInfo("US/Pacific"), # type: ignore[list-item] + zoneinfo.ZoneInfo("UTC"), # type: ignore[list-item] + ] + ) +TIMEZONE_IDS = [repr(i) for i in TIMEZONES] + + +@td.parametrize_fixture_doc(str(TIMEZONE_IDS)) +@pytest.fixture(params=TIMEZONES, ids=TIMEZONE_IDS) +def tz_naive_fixture(request): + """ + Fixture for trying timezones including default (None): {0} + """ + return request.param + + +@td.parametrize_fixture_doc(str(TIMEZONE_IDS[1:])) +@pytest.fixture(params=TIMEZONES[1:], ids=TIMEZONE_IDS[1:]) +def tz_aware_fixture(request): + """ + Fixture for trying explicit timezones: {0} + """ + return request.param + + +# Generate cartesian product of tz_aware_fixture: +tz_aware_fixture2 = tz_aware_fixture + + _UTCS = ["utc", "dateutil/UTC", utc, tzutc(), timezone.utc] if zoneinfo is not None: _UTCS.append(zoneinfo.ZoneInfo("UTC")) From be6469984dac77bbb15329c1893990c1eee998bc Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:28:26 -0700 Subject: [PATCH 42/46] fix typing? --- pandas/util/_tester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 3de7a9fad4432..ade2955a772f5 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -6,6 +6,7 @@ import os import sys +from typing import cast from pandas.compat._optional import import_optional_dependency @@ -47,7 +48,7 @@ def test(extra_args: list[str] | None = None, run_doctests: bool = False) -> Non ] else: pandas_tests = import_optional_dependency("pandas_tests") - PKG = os.path.dirname(pandas_tests.__file__) + PKG = os.path.dirname(cast(str, pandas_tests.__file__)) cmd += [PKG] joined = " ".join(cmd) print(f"running: pytest {joined}") From e835993951ca296492fddc14efb758ef5ec39aef Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:53:09 -0700 Subject: [PATCH 43/46] add pyright ignore --- pandas/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index bfa3ae0245c48..da06222b19924 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -191,7 +191,7 @@ import sys try: - import pandas_tests + import pandas_tests # pyright: ignore [reportMissingImports] sys.modules["pandas.tests"] = pandas_tests From 2cf3911fc75cd279e3053bd896942e9b48626187 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:17:05 -0700 Subject: [PATCH 44/46] last ignore --- pandas/util/_exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/util/_exceptions.py b/pandas/util/_exceptions.py index ef486f96efb1d..056f73c6b4f08 100644 --- a/pandas/util/_exceptions.py +++ b/pandas/util/_exceptions.py @@ -46,7 +46,7 @@ def find_stack_level() -> int: try: # can't use import_optional_dependency cause it uses find_stack_level and we'd # have ourselves a circular import :( - import pandas_tests + import pandas_tests # pyright: ignore [reportMissingImports] pd_tests_dir = os.path.dirname(pandas_tests.__file__) except ImportError: From e9ba935124cba522796130843a628f781f5585cc Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:24:06 -0700 Subject: [PATCH 45/46] fix musl --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d580a62d20d0d..e06c80f88a5f2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: From e53ad084728088fd3054c45ad3c687c1425c9358 Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:03:06 -0700 Subject: [PATCH 46/46] Update code_checks.sh --- ci/code_checks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 629282e7ad9ab..4b8e632f3246c 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -57,7 +57,7 @@ fi if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then MSG='Python and Cython Doctests' ; echo $MSG - PY_IGNORE_IMPORTMISMATCH=1 python -c 'import pandas as pd; pd.test(run_doctests=True)' + python -c 'import pandas as pd; pd.test(run_doctests=True)' RET=$(($RET + $?)) ; echo $MSG "DONE" fi