Skip to content

Commit 8023225

Browse files
lithomas1mroeschke
andauthored
BLD: Add pyproject.toml to wheels (#50330)
* BLD: Add pyproject.toml to wheels * Make strict-data-files opt out * Fixed backwards condition * Actually fix * Maybe fix all * Adjust options for other wheel builds * Error on unknown mark warning * Update pyproject.toml * Apply suggestions from code review Co-authored-by: Matthew Roeschke <[email protected]> * revert #48924 * update * fix syntax * fix warnings * Update test_nlargest.py * Update pyproject.toml --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 0950b1c commit 8023225

File tree

8 files changed

+33
-14
lines changed

8 files changed

+33
-14
lines changed

.github/workflows/wheels.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ jobs:
173173
pip install hypothesis>=6.34.2 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17
174174
cd .. # Not a good idea to test within the src tree
175175
python -c "import pandas; print(pandas.__version__);
176-
pandas.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']);
177-
pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db'])"
176+
pandas.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']);
177+
pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files'])"
178178
- uses: actions/upload-artifact@v3
179179
with:
180180
name: sdist

ci/test_wheels.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@
4141
multi_args = [
4242
"-m not clipboard and not single_cpu and not slow and not network and not db",
4343
"-n 2",
44+
"--no-strict-data-files",
4445
]
4546
pd.test(extra_args=multi_args)
4647
pd.test(
4748
extra_args=[
4849
"-m not clipboard and single_cpu and not slow and not network and not db",
50+
"--no-strict-data-files",
4951
]
5052
)

ci/test_wheels_windows.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set test_command=import pandas as pd; print(pd.__version__); ^
2-
pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']); ^
3-
pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db'])
2+
pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '--no-strict-data-files', '-n=2']); ^
3+
pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files'])
44

55
python --version
66
pip install pytz six numpy python-dateutil tzdata>=2022.1

pandas/conftest.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103

104104
def pytest_addoption(parser) -> None:
105105
parser.addoption(
106-
"--strict-data-files",
107-
action="store_true",
108-
help="Fail if a test is skipped for missing data file.",
106+
"--no-strict-data-files",
107+
action="store_false",
108+
help="Don't fail if a test is skipped for missing data file.",
109109
)
110110

111111

@@ -1112,9 +1112,9 @@ def all_numeric_accumulations(request):
11121112
@pytest.fixture
11131113
def strict_data_files(pytestconfig):
11141114
"""
1115-
Returns the configuration for the test setting `--strict-data-files`.
1115+
Returns the configuration for the test setting `--no-strict-data-files`.
11161116
"""
1117-
return pytestconfig.getoption("--strict-data-files")
1117+
return pytestconfig.getoption("--no-strict-data-files")
11181118

11191119

11201120
@pytest.fixture
@@ -1134,7 +1134,7 @@ def datapath(strict_data_files: str) -> Callable[..., str]:
11341134
Raises
11351135
------
11361136
ValueError
1137-
If the path doesn't exist and the --strict-data-files option is set.
1137+
If the path doesn't exist and the --no-strict-data-files option is not set.
11381138
"""
11391139
BASE_PATH = os.path.join(os.path.dirname(__file__), "tests")
11401140

@@ -1143,7 +1143,7 @@ def deco(*args):
11431143
if not os.path.exists(path):
11441144
if strict_data_files:
11451145
raise ValueError(
1146-
f"Could not find file {path} and --strict-data-files is set."
1146+
f"Could not find file {path} and --no-strict-data-files is not set."
11471147
)
11481148
pytest.skip(f"Could not find {path}.")
11491149
return path

pandas/tests/frame/indexing/test_setitem.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class mystring(str):
6161
"dtype", ["int32", "int64", "uint32", "uint64", "float32", "float64"]
6262
)
6363
def test_setitem_dtype(self, dtype, float_frame):
64-
arr = np.random.randn(len(float_frame))
64+
# Use randint since casting negative floats to uints is undefined
65+
arr = np.random.randint(1, 10, len(float_frame))
6566

6667
float_frame[dtype] = np.array(arr, dtype=dtype)
6768
assert float_frame[dtype].dtype.name == dtype

pandas/tests/series/methods/test_nlargest.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ def test_nlargest_boolean(self, data, expected):
217217
def test_nlargest_nullable(self, any_numeric_ea_dtype):
218218
# GH#42816
219219
dtype = any_numeric_ea_dtype
220-
arr = np.random.randn(10).astype(dtype.lower(), copy=False)
220+
if dtype.startswith("UInt"):
221+
# Can't cast from negative float to uint on some platforms
222+
arr = np.random.randint(1, 10, 10)
223+
else:
224+
arr = np.random.randn(10)
225+
arr = arr.astype(dtype.lower(), copy=False)
221226

222227
ser = Series(arr.copy(), dtype=dtype)
223228
ser[1] = pd.NA

pandas/tests/test_common.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections
22
from functools import partial
3+
import os
34
import string
45

56
import numpy as np
@@ -174,6 +175,12 @@ def test_version_tag():
174175
)
175176

176177

178+
def test_pyproject_present():
179+
# Check pyproject.toml is present(relevant for wheels)
180+
pyproject_loc = os.path.join(os.path.dirname(__file__), "../../pyproject.toml")
181+
assert os.path.exists(pyproject_loc)
182+
183+
177184
@pytest.mark.parametrize(
178185
"obj", [(obj,) for obj in pd.__dict__.values() if callable(obj)]
179186
)

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ include-package-data = true
125125
include = ["pandas", "pandas.*"]
126126
namespaces = false
127127

128+
[tool.setuptools.package-data]
129+
pandas = ["../pyproject.toml"]
130+
128131
[tool.setuptools.exclude-package-data]
129132
"*" = ["*.c", "*.h"]
130133

@@ -406,7 +409,7 @@ disable = [
406409
[tool.pytest.ini_options]
407410
# sync minversion with pyproject.toml & install.rst
408411
minversion = "7.0"
409-
addopts = "--strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml"
412+
addopts = "--strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml"
410413
empty_parameter_set_mark = "fail_at_collect"
411414
xfail_strict = true
412415
testpaths = "pandas"
@@ -416,6 +419,7 @@ doctest_optionflags = [
416419
"ELLIPSIS",
417420
]
418421
filterwarnings = [
422+
"error::_pytest.warning_types.PytestUnknownMarkWarning",
419423
"error:::pandas",
420424
"error::ResourceWarning",
421425
"error::pytest.PytestUnraisableExceptionWarning",

0 commit comments

Comments
 (0)