|
15 | 15 | """This script is used to synthesize generated parts of this library.""" |
16 | 16 |
|
17 | 17 | import pathlib |
| 18 | +import re |
18 | 19 |
|
19 | 20 | import synthtool as s |
20 | 21 | from synthtool import gcp |
|
55 | 56 | # Fixup files |
56 | 57 | # ---------------------------------------------------------------------------- |
57 | 58 |
|
| 59 | +s.replace( |
| 60 | + ["noxfile.py"], |
| 61 | + r"import pathlib\s+import shutil", |
| 62 | + "import pathlib\nimport re\nimport shutil", |
| 63 | +) |
| 64 | + |
58 | 65 | s.replace( |
59 | 66 | ["noxfile.py"], r"[\"']google[\"']", '"pandas_gbq"', |
60 | 67 | ) |
61 | 68 |
|
| 69 | + |
62 | 70 | s.replace( |
63 | 71 | ["noxfile.py"], "--cov=google", "--cov=pandas_gbq", |
64 | 72 | ) |
65 | 73 |
|
| 74 | +s.replace( |
| 75 | + ["noxfile.py"], |
| 76 | + r"@nox.session\(python=DEFAULT_PYTHON_VERSION\)\s+def cover\(session\):", |
| 77 | + r"""@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 78 | +def prerelease(session): |
| 79 | + session.install( |
| 80 | + "--extra-index-url", |
| 81 | + "https://pypi.fury.io/arrow-nightlies/", |
| 82 | + "--prefer-binary", |
| 83 | + "--pre", |
| 84 | + "--upgrade", |
| 85 | + "pyarrow", |
| 86 | + ) |
| 87 | + session.install( |
| 88 | + "--extra-index-url", |
| 89 | + "https://pypi.anaconda.org/scipy-wheels-nightly/simple", |
| 90 | + "--prefer-binary", |
| 91 | + "--pre", |
| 92 | + "--upgrade", |
| 93 | + "pandas", |
| 94 | + ) |
| 95 | + session.install( |
| 96 | + "--prefer-binary", |
| 97 | + "--pre", |
| 98 | + "--upgrade", |
| 99 | + "google-api-core", |
| 100 | + "google-cloud-bigquery", |
| 101 | + "google-cloud-bigquery-storage", |
| 102 | + "google-cloud-core", |
| 103 | + "google-resumable-media", |
| 104 | + "grpcio", |
| 105 | + ) |
| 106 | + session.install( |
| 107 | + "freezegun", |
| 108 | + "google-cloud-datacatalog", |
| 109 | + "google-cloud-storage", |
| 110 | + "google-cloud-testutils", |
| 111 | + "IPython", |
| 112 | + "mock", |
| 113 | + "psutil", |
| 114 | + "pytest", |
| 115 | + "pytest-cov", |
| 116 | + ) |
| 117 | +
|
| 118 | + # Because we test minimum dependency versions on the minimum Python |
| 119 | + # version, the first version we test with in the unit tests sessions has a |
| 120 | + # constraints file containing all dependencies and extras. |
| 121 | + with open( |
| 122 | + CURRENT_DIRECTORY |
| 123 | + / "testing" |
| 124 | + / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", |
| 125 | + encoding="utf-8", |
| 126 | + ) as constraints_file: |
| 127 | + constraints_text = constraints_file.read() |
| 128 | +
|
| 129 | + # Ignore leading whitespace and comment lines. |
| 130 | + deps = [ |
| 131 | + match.group(1) |
| 132 | + for match in re.finditer( |
| 133 | + r"^\\s*(\\S+)(?===\\S+)", constraints_text, flags=re.MULTILINE |
| 134 | + ) |
| 135 | + ] |
| 136 | +
|
| 137 | + # We use --no-deps to ensure that pre-release versions aren't overwritten |
| 138 | + # by the version ranges in setup.py. |
| 139 | + session.install(*deps) |
| 140 | + session.install("--no-deps", "-e", ".[all]") |
| 141 | +
|
| 142 | + # Print out prerelease package versions. |
| 143 | + session.run("python", "-m", "pip", "freeze") |
| 144 | +
|
| 145 | + # Run all tests, except a few samples tests which require extra dependencies. |
| 146 | + session.run( |
| 147 | + "py.test", |
| 148 | + "--quiet", |
| 149 | + f"--junitxml=prerelease_unit_{session.python}_sponge_log.xml", |
| 150 | + os.path.join("tests", "unit"), |
| 151 | + ) |
| 152 | + session.run( |
| 153 | + "py.test", |
| 154 | + "--quiet", |
| 155 | + f"--junitxml=prerelease_system_{session.python}_sponge_log.xml", |
| 156 | + os.path.join("tests", "system"), |
| 157 | + ) |
| 158 | +
|
| 159 | +
|
| 160 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 161 | +def cover(session):""", |
| 162 | + re.MULTILINE, |
| 163 | +) |
| 164 | + |
66 | 165 | s.replace( |
67 | 166 | [".github/header-checker-lint.yml"], '"Google LLC"', '"pandas-gbq Authors"', |
68 | 167 | ) |
|
0 commit comments