From fa78cd7e81588a466ccba7cb0edeb84316feb32c Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Mon, 19 Jun 2023 19:31:39 +0100 Subject: [PATCH 01/33] Store deps inside pyproject.toml --- py-polars/Makefile | 3 +- py-polars/polars/utils/show_versions.py | 3 ++ py-polars/pyproject.toml | 26 ++++++++++-- py-polars/requirements-dev.txt | 29 ------------- py-polars/requirements-lint.txt | 5 --- py-polars/scripts/install_dev_dependencies.py | 42 +++++++++++++++++++ 6 files changed, 69 insertions(+), 39 deletions(-) delete mode 100644 py-polars/requirements-dev.txt delete mode 100644 py-polars/requirements-lint.txt create mode 100644 py-polars/scripts/install_dev_dependencies.py diff --git a/py-polars/Makefile b/py-polars/Makefile index ec717c3b0d09..b4ac23bbd4d1 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -17,8 +17,7 @@ endif .PHONY: requirements requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip - $(VENV_BIN)/pip install -r requirements-dev.txt - $(VENV_BIN)/pip install -r requirements-lint.txt + $(VENV_BIN)/python scripts/install_dev_dependencies.py $(VENV_BIN)/pip install -r docs/requirements-docs.txt .PHONY: build diff --git a/py-polars/polars/utils/show_versions.py b/py-polars/polars/utils/show_versions.py index 4d3ca258890c..6bf5bd7c4453 100644 --- a/py-polars/polars/utils/show_versions.py +++ b/py-polars/polars/utils/show_versions.py @@ -67,7 +67,10 @@ def _get_dependency_info() -> dict[str, str]: "matplotlib", "xlsx2csv", "xlsxwriter", + "sqlalchemy", + "pydantic", ] + return {f"{name}:": _get_dependency_version(name) for name in opt_deps} diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 785760024ea8..e2e66822636d 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -45,15 +45,35 @@ pyarrow = ["pyarrow>=7.0.0"] pandas = ["pyarrow>=7.0.0", "pandas"] numpy = ["numpy >= 1.16.0"] fsspec = ["fsspec"] -connectorx = ["connectorx"] +connectorx = ["connectorx < 0.3.1"] # Latest full release is broken - unpin when 0.3.2 released xlsx2csv = ["xlsx2csv >= 0.8.0"] -deltalake = ["deltalake >= 0.8.0"] +deltalake = ["deltalake >= 0.10.0"] timezone = ["backports.zoneinfo; python_version < '3.9'", "tzdata; platform_system == 'Windows'"] matplotlib = ["matplotlib"] sqlalchemy = ["sqlalchemy", "pandas"] xlsxwriter = ["xlsxwriter"] +pydantic = ["pydantic"] all = [ - "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,xlsxwriter]", + "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,xlsxwriter,pydantic]", +] + +dev = [ + # Tooling + "hypothesis==6.75.1", + "maturin==1.0.1", + "pytest==7.3.0", + "pytest-cov==4.1.0", + "pytest-xdist==3.3.1", + + # Stub files + "pandas-stubs==1.2.0.62", + + # Linting + "black==23.3.0", + "blackdoc==0.3.8", + "mypy==1.3.0", + "ruff==0.0.270", + "typos==1.15", ] [tool.mypy] diff --git a/py-polars/requirements-dev.txt b/py-polars/requirements-dev.txt deleted file mode 100644 index 41cd9344418a..000000000000 --- a/py-polars/requirements-dev.txt +++ /dev/null @@ -1,29 +0,0 @@ -# We're pinning our tooling, because it's an environment we can strictly control. -# We're not pinning package dependencies, because our tests need to pass with the -# latest version of the packages. - ---prefer-binary - -# Dependencies -deltalake >= 0.10.0 -numpy -pandas -pyarrow -pydantic -backports.zoneinfo; python_version < '3.9' -tzdata; platform_system == 'Windows' -xlsx2csv -XlsxWriter -adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows' -connectorx==0.3.2a5; python_version >= '3.8' # Latest full release is broken - unpin when 0.3.2 released - -# Tooling -hypothesis==6.79.4; python_version < '3.8' -hypothesis==6.80.0; python_version >= '3.8' -maturin==1.1.0 -pytest==7.4.0 -pytest-cov==4.1.0 -pytest-xdist==3.3.1 - -# Stub files -pandas-stubs==1.2.0.62 diff --git a/py-polars/requirements-lint.txt b/py-polars/requirements-lint.txt deleted file mode 100644 index 3348d30ed8f5..000000000000 --- a/py-polars/requirements-lint.txt +++ /dev/null @@ -1,5 +0,0 @@ -black==23.3.0 -blackdoc==0.3.8 -mypy==1.4.1 -ruff==0.0.275 -typos==1.15.9 diff --git a/py-polars/scripts/install_dev_dependencies.py b/py-polars/scripts/install_dev_dependencies.py new file mode 100644 index 000000000000..201e43ed6c44 --- /dev/null +++ b/py-polars/scripts/install_dev_dependencies.py @@ -0,0 +1,42 @@ + +import subprocess +import sys +from itertools import chain +from typing import Any +import argparse +import tomllib + + +def parse_toml_file(fp) -> dict[str, dict[str, Any]]: + if sys.version_info < (3, 11): + subprocess.run(["pip", "install" ,"tomli"], capture_output=True, text=True) + import tomlli + return tomlli.load(fp) + else: + return tomllib.load(fp) + + +def collect_dependencies_from_pyproject_toml() -> list[str]: + with open("pyproject.toml", mode="rb") as fp: + config = parse_toml_file(fp) + + mandatory_deps = config["project"]["dependencies"] + opt_deps = list(chain(*config["project"]["optional-dependencies"].values())) + deps = mandatory_deps + opt_deps + return deps + + +def pip_install(specifiers: list[str]): + cmd = ["pip", "install"] + specifiers + subprocess.run(cmd, capture_output=True, text=True ) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Install Polars dependencies') + parser.add_argument('pos_arg', type=int, + help='A required integer positional argument') + deps = collect_dependencies_from_pyproject_toml() + + # remove polars[all, pandas], etc + deps_no_meta = list(filter(lambda x: not x.startswith("polars"), deps)) + + pip_install(deps_no_meta) From 5db77c597fdfe21b217e23598c810506923673f0 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 12:41:14 +0200 Subject: [PATCH 02/33] Add option to specify tags + update GH workflows --- .github/workflows/benchmark.yml | 2 +- .github/workflows/lint-python.yml | 6 +- .github/workflows/test-python.yml | 4 +- py-polars/Makefile | 2 +- py-polars/pyproject.toml | 10 +-- py-polars/scripts/install_dependencies.py | 86 +++++++++++++++++++ py-polars/scripts/install_dev_dependencies.py | 42 --------- 7 files changed, 97 insertions(+), 55 deletions(-) create mode 100644 py-polars/scripts/install_dependencies.py delete mode 100644 py-polars/scripts/install_dev_dependencies.py diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0f509f41f99e..d8a4fe9f7a88 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: pip install -r requirements-dev.txt + run: python scripts/install_depencies.py --tag dev - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index be3e2276dc7a..111705758cf4 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.11' - name: Install Python dependencies - run: pip install -r requirements-lint.txt + run: python scripts/install_depencies.py --tag lint - name: Lint Python run: | @@ -54,8 +54,8 @@ jobs: - name: Install dependencies run: | - pip install -r requirements-dev.txt - pip install -r requirements-lint.txt + python scripts/install_depencies.py --tag dev + python scripts/install_depencies.py --tag lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index e71bf38aaf01..c1e37b9cbc32 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -47,7 +47,7 @@ jobs: echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - name: Install dependencies - run: pip install -r requirements-dev.txt + run: python scripts/install_depencies.py --tag dev - name: Set up Rust run: rustup show @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: pip install -r requirements-dev.txt + run: python scripts/install_depencies.py --tag dev - name: Set up Rust run: rustup show diff --git a/py-polars/Makefile b/py-polars/Makefile index b4ac23bbd4d1..8d2ce6770d7f 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -17,7 +17,7 @@ endif .PHONY: requirements requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip - $(VENV_BIN)/python scripts/install_dev_dependencies.py + $(VENV_BIN)/python scripts/install_dependencies.py $(VENV_BIN)/pip install -r docs/requirements-docs.txt .PHONY: build diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index e2e66822636d..4f182f25379e 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -57,23 +57,21 @@ all = [ "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,xlsxwriter,pydantic]", ] +# The tags below are for development of Polars. We pin precise versions here, as we have full control on this dev = [ - # Tooling "hypothesis==6.75.1", "maturin==1.0.1", "pytest==7.3.0", "pytest-cov==4.1.0", "pytest-xdist==3.3.1", - - # Stub files - "pandas-stubs==1.2.0.62", - - # Linting +] +lint = [ "black==23.3.0", "blackdoc==0.3.8", "mypy==1.3.0", "ruff==0.0.270", "typos==1.15", + "pandas-stubs==1.2.0.62", ] [tool.mypy] diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py new file mode 100644 index 000000000000..adcda9eddb31 --- /dev/null +++ b/py-polars/scripts/install_dependencies.py @@ -0,0 +1,86 @@ +""" +Install Polars dependencies as defined in pyproject.toml without building Polars. + +In our dev workflow, we often want to either not build (Rust) Polars at all, or in +develop mode. Unfortunately, `pip install .` or `pip install . -e` will always call +`maturin build` to build Polars. This is very slow compared to `maturin develop`. +We work around this by calling `maturin develop`, and for the Python dependencies, +this script collects the relevant tags from pyproject.toml and pass to `pip install`. +""" + +import argparse +import subprocess +import sys +from itertools import chain +from typing import Any + +import tomllib + + +def parse_toml_file(fp) -> dict[str, dict[str, Any]]: + if sys.version_info < (3, 11): + subprocess.run(["pip", "install", "tomli"], capture_output=True, text=True) + import tomlli + + return tomlli.load(fp) + else: + return tomllib.load(fp) + + +def collect_dependencies_from_pyproject_toml(tag: str | None = None, include_mandatory: bool = True) -> list[str]: + """ + Collects all dependencies, mandatory and optional, from pyproject.toml. + + Parameters + ---------- + tag + Select only dependencies under this tag defined in optional-dependencies + include_mandatory + Whether to return dependencies specified under `dependencies` in pyproject.toml. + + """ + with open("pyproject.toml", mode="rb") as fp: + config = parse_toml_file(fp) + + if tag: + deps = [] + if "," in tag: + for t in tag.split(","): + deps += config["project"]["optional-dependencies"][t] + else: + deps += config["project"]["optional-dependencies"][tag] + if include_mandatory: + deps += config["project"]["dependencies"] + else: + # collect everything + mandatory_deps = config["project"]["dependencies"] + opt_deps = list(chain(*config["project"]["optional-dependencies"].values())) + deps = mandatory_deps + opt_deps + + return deps + + +def pip_install(specifiers: list[str]) -> None: + cmd = ["pip", "install"] + specifiers + subprocess.run(cmd, capture_output=False, text=True) + + +def install_dependencies(tag: str | None = None): + deps = collect_dependencies_from_pyproject_toml(tag) + + # remove polars to avoid building + deps_no_polars = list(filter(lambda x: not x.startswith("polars"), deps)) + + pip_install(deps_no_polars) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Install Polars dependencies from pyproject.toml without building Polars" + ) + parser.add_argument( + "--tag", type=str, help="Optional-dependency tag(s) in pyproject.toml. Provide multiple by separating with commas." + ) + parser.add_argument("--include_mandatory", type=bool, default=True, help="Include mandatory dependencies") + args = parser.parse_args() + install_dependencies(args.tag) diff --git a/py-polars/scripts/install_dev_dependencies.py b/py-polars/scripts/install_dev_dependencies.py deleted file mode 100644 index 201e43ed6c44..000000000000 --- a/py-polars/scripts/install_dev_dependencies.py +++ /dev/null @@ -1,42 +0,0 @@ - -import subprocess -import sys -from itertools import chain -from typing import Any -import argparse -import tomllib - - -def parse_toml_file(fp) -> dict[str, dict[str, Any]]: - if sys.version_info < (3, 11): - subprocess.run(["pip", "install" ,"tomli"], capture_output=True, text=True) - import tomlli - return tomlli.load(fp) - else: - return tomllib.load(fp) - - -def collect_dependencies_from_pyproject_toml() -> list[str]: - with open("pyproject.toml", mode="rb") as fp: - config = parse_toml_file(fp) - - mandatory_deps = config["project"]["dependencies"] - opt_deps = list(chain(*config["project"]["optional-dependencies"].values())) - deps = mandatory_deps + opt_deps - return deps - - -def pip_install(specifiers: list[str]): - cmd = ["pip", "install"] + specifiers - subprocess.run(cmd, capture_output=True, text=True ) - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Install Polars dependencies') - parser.add_argument('pos_arg', type=int, - help='A required integer positional argument') - deps = collect_dependencies_from_pyproject_toml() - - # remove polars[all, pandas], etc - deps_no_meta = list(filter(lambda x: not x.startswith("polars"), deps)) - - pip_install(deps_no_meta) From e9acf102c2a3c17d9e296a5edceb5892be86add1 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 12:50:45 +0200 Subject: [PATCH 03/33] Fix typo in script name --- .github/workflows/benchmark.yml | 2 +- .github/workflows/lint-python.yml | 6 +++--- .github/workflows/test-python.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d8a4fe9f7a88..b68b24fec014 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_depencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 111705758cf4..6987ccf0216b 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.11' - name: Install Python dependencies - run: python scripts/install_depencies.py --tag lint + run: python scripts/install_dependencies.py --tag lint - name: Lint Python run: | @@ -54,8 +54,8 @@ jobs: - name: Install dependencies run: | - python scripts/install_depencies.py --tag dev - python scripts/install_depencies.py --tag lint + python scripts/install_dependencies.py --tag dev + python scripts/install_dependencies.py --tag lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index c1e37b9cbc32..3495d1447aee 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -47,7 +47,7 @@ jobs: echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - name: Install dependencies - run: python scripts/install_depencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev - name: Set up Rust run: rustup show @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python scripts/install_depencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev - name: Set up Rust run: rustup show From 4c299b181cd0c0376cb1af734a86088720269c43 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 12:52:42 +0200 Subject: [PATCH 04/33] Fix formatting --- py-polars/scripts/install_dependencies.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index adcda9eddb31..878cec19ad0c 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -27,7 +27,9 @@ def parse_toml_file(fp) -> dict[str, dict[str, Any]]: return tomllib.load(fp) -def collect_dependencies_from_pyproject_toml(tag: str | None = None, include_mandatory: bool = True) -> list[str]: +def collect_dependencies_from_pyproject_toml( + tag: str | None = None, include_mandatory: bool = True +) -> list[str]: """ Collects all dependencies, mandatory and optional, from pyproject.toml. @@ -79,8 +81,15 @@ def install_dependencies(tag: str | None = None): description="Install Polars dependencies from pyproject.toml without building Polars" ) parser.add_argument( - "--tag", type=str, help="Optional-dependency tag(s) in pyproject.toml. Provide multiple by separating with commas." + "--tag", + type=str, + help="Optional-dependency tag(s) in pyproject.toml. Provide multiple by separating with commas.", + ) + parser.add_argument( + "--include_mandatory", + type=bool, + default=True, + help="Include mandatory dependencies", ) - parser.add_argument("--include_mandatory", type=bool, default=True, help="Include mandatory dependencies") args = parser.parse_args() install_dependencies(args.tag) From 302b71957f729427aa862dd513b2f0d4d4a7eefa Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 12:53:33 +0200 Subject: [PATCH 05/33] Move tomllib import behind Python version clause --- py-polars/scripts/install_dependencies.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 878cec19ad0c..4c8d2a6ba1b0 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -14,8 +14,6 @@ from itertools import chain from typing import Any -import tomllib - def parse_toml_file(fp) -> dict[str, dict[str, Any]]: if sys.version_info < (3, 11): @@ -24,6 +22,7 @@ def parse_toml_file(fp) -> dict[str, dict[str, Any]]: return tomlli.load(fp) else: + import tomllib return tomllib.load(fp) From 9a57b5533270eebc9cb968d24fb6bfc36039b903 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:09:05 +0200 Subject: [PATCH 06/33] Resolve polars tags properly --- py-polars/scripts/install_dependencies.py | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 4c8d2a6ba1b0..12e9c537ee1f 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -17,12 +17,13 @@ def parse_toml_file(fp) -> dict[str, dict[str, Any]]: if sys.version_info < (3, 11): - subprocess.run(["pip", "install", "tomli"], capture_output=True, text=True) + subprocess.run(["pip", "install", "tomli"], capture_output=False, text=True) import tomlli return tomlli.load(fp) else: import tomllib + return tomllib.load(fp) @@ -35,7 +36,9 @@ def collect_dependencies_from_pyproject_toml( Parameters ---------- tag - Select only dependencies under this tag defined in optional-dependencies + Select only dependencies under this tag defined in optional-dependencies. + Multiple tags can be provided by passing in a comma delimited string, for + example "dev,lint" include_mandatory Whether to return dependencies specified under `dependencies` in pyproject.toml. @@ -58,7 +61,17 @@ def collect_dependencies_from_pyproject_toml( opt_deps = list(chain(*config["project"]["optional-dependencies"].values())) deps = mandatory_deps + opt_deps - return deps + # resolve polars[] tags + for d in deps: + if "[" in d: + tags_as_comma_delimited_string = d.split("[")[1].replace("]", "") + for pt in tags_as_comma_delimited_string.split(","): + deps += config["project"]["optional-dependencies"][pt] + + # drop the polars tags from the list + deps2 = [d for d in deps if "[" not in d] + + return deps2 def pip_install(specifiers: list[str]) -> None: @@ -66,13 +79,11 @@ def pip_install(specifiers: list[str]) -> None: subprocess.run(cmd, capture_output=False, text=True) -def install_dependencies(tag: str | None = None): - deps = collect_dependencies_from_pyproject_toml(tag) - - # remove polars to avoid building - deps_no_polars = list(filter(lambda x: not x.startswith("polars"), deps)) - - pip_install(deps_no_polars) +def install_dependencies( + tag: str | None = None, include_mandatory: bool = True +) -> None: + deps = collect_dependencies_from_pyproject_toml(tag, include_mandatory) + pip_install(deps) if __name__ == "__main__": @@ -91,4 +102,4 @@ def install_dependencies(tag: str | None = None): help="Include mandatory dependencies", ) args = parser.parse_args() - install_dependencies(args.tag) + install_dependencies(args.tag, args.include_mandatory) From e4bdbbef87838cc891f11a0970b337ccb13521dc Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:16:38 +0200 Subject: [PATCH 07/33] Fix python 3.7 type annotations --- py-polars/scripts/install_dependencies.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 12e9c537ee1f..ca0298677704 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -12,10 +12,10 @@ import subprocess import sys from itertools import chain -from typing import Any +from typing import Any, Dict -def parse_toml_file(fp) -> dict[str, dict[str, Any]]: +def parse_toml_file(fp) -> Dict[str, Dict[str, Any]]: if sys.version_info < (3, 11): subprocess.run(["pip", "install", "tomli"], capture_output=False, text=True) import tomlli From 6a1a8bb1fee0e9f9c9f1e9224eb2e0b26947b65c Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:24:06 +0200 Subject: [PATCH 08/33] Fix various errors --- .github/workflows/benchmark.yml | 2 +- .github/workflows/lint-python.yml | 3 +-- .github/workflows/test-python.yml | 4 ++-- py-polars/pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b68b24fec014..424aa5192e46 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev,all - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 6987ccf0216b..ab6a6b701ad2 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -54,8 +54,7 @@ jobs: - name: Install dependencies run: | - python scripts/install_dependencies.py --tag dev - python scripts/install_dependencies.py --tag lint + python scripts/install_dependencies.py --tag dev,all,lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 3495d1447aee..e395cc1a77a1 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -47,7 +47,7 @@ jobs: echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - name: Install dependencies - run: python scripts/install_dependencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev,all - name: Set up Rust run: rustup show @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python scripts/install_dependencies.py --tag dev + run: python scripts/install_dependencies.py --tag dev,all - name: Set up Rust run: rustup show diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 4f182f25379e..a80c08ab5e6e 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -45,7 +45,7 @@ pyarrow = ["pyarrow>=7.0.0"] pandas = ["pyarrow>=7.0.0", "pandas"] numpy = ["numpy >= 1.16.0"] fsspec = ["fsspec"] -connectorx = ["connectorx < 0.3.1"] # Latest full release is broken - unpin when 0.3.2 released +connectorx = ["connectorx < 0.3.1"] # Latest full release is broken - unpin when 0.3.2 released xlsx2csv = ["xlsx2csv >= 0.8.0"] deltalake = ["deltalake >= 0.10.0"] timezone = ["backports.zoneinfo; python_version < '3.9'", "tzdata; platform_system == 'Windows'"] From e24c9d5299d87d116d5f71dda0b3faa01e93916b Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:29:45 +0200 Subject: [PATCH 09/33] Fix Python 3.7 type annotations --- py-polars/scripts/install_dependencies.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index ca0298677704..e361330e9df2 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -7,15 +7,16 @@ We work around this by calling `maturin develop`, and for the Python dependencies, this script collects the relevant tags from pyproject.toml and pass to `pip install`. """ +from __future__ import annotations import argparse import subprocess import sys from itertools import chain -from typing import Any, Dict +from typing import Any -def parse_toml_file(fp) -> Dict[str, Dict[str, Any]]: +def parse_toml_file(fp) -> dict[str, dict[str, Any]]: if sys.version_info < (3, 11): subprocess.run(["pip", "install", "tomli"], capture_output=False, text=True) import tomlli From 9f825ce773e656f0c9757deabad633ab0b8b1e9c Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:37:30 +0200 Subject: [PATCH 10/33] Fix tomli package name --- py-polars/scripts/install_dependencies.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index e361330e9df2..8250255837c8 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -19,9 +19,9 @@ def parse_toml_file(fp) -> dict[str, dict[str, Any]]: if sys.version_info < (3, 11): subprocess.run(["pip", "install", "tomli"], capture_output=False, text=True) - import tomlli + import tomli - return tomlli.load(fp) + return tomli.load(fp) else: import tomllib From ab0e6724a269e75bfa259ad9448a4c0dfaf270b6 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 13:50:00 +0200 Subject: [PATCH 11/33] Add adbc dependency --- py-polars/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index a80c08ab5e6e..d60b45984133 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -53,8 +53,9 @@ matplotlib = ["matplotlib"] sqlalchemy = ["sqlalchemy", "pandas"] xlsxwriter = ["xlsxwriter"] pydantic = ["pydantic"] +adbc = ["adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows'"] all = [ - "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,xlsxwriter,pydantic]", + "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,adbc,xlsxwriter,pydantic]", ] # The tags below are for development of Polars. We pin precise versions here, as we have full control on this From 2bd2c7fee802b0b67169cd00f58613efcaebbd8f Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:17:42 +0200 Subject: [PATCH 12/33] Fix connectorx version --- py-polars/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index d60b45984133..72e9d7ff6a15 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -45,7 +45,7 @@ pyarrow = ["pyarrow>=7.0.0"] pandas = ["pyarrow>=7.0.0", "pandas"] numpy = ["numpy >= 1.16.0"] fsspec = ["fsspec"] -connectorx = ["connectorx < 0.3.1"] # Latest full release is broken - unpin when 0.3.2 released +connectorx = ["connectorx >= 0.3.2a5"] # Latest full release is broken - unpin when 0.3.2 released xlsx2csv = ["xlsx2csv >= 0.8.0"] deltalake = ["deltalake >= 0.10.0"] timezone = ["backports.zoneinfo; python_version < '3.9'", "tzdata; platform_system == 'Windows'"] From e9aeacc353f16db0881bd46af63101ce6d383c06 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:21:41 +0200 Subject: [PATCH 13/33] Fix SQLAlchemy typing bug Only occurs if SQLAlchemy is installed. --- py-polars/polars/dataframe/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index e84a8c2549c0..791c96efdc7d 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -3167,12 +3167,12 @@ def write_database( "'sqlalchemy' not found. Install polars with 'pip install polars[sqlalchemy]'." ) from exc - engine = create_engine(connection_uri) + engine_sa = create_engine(connection_uri) # this conversion to pandas as zero-copy # so we can utilize their sql utils for free self.to_pandas(use_pyarrow_extension_array=True).to_sql( - name=table_name, con=engine, if_exists=if_exists, index=False + name=table_name, con=engine_sa, if_exists=if_exists, index=False ) else: From 4724c0aeff8da8ff33a871d8e71d8d5c69ce2f73 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:28:02 +0200 Subject: [PATCH 14/33] Move docs requirements to pyproject.toml --- .github/workflows/docs-python.yml | 6 +++--- .github/workflows/lint-python.yml | 4 ++-- py-polars/Makefile | 1 - py-polars/docs/requirements-docs.txt | 26 ----------------------- py-polars/pyproject.toml | 21 +++++++++++++++++- py-polars/scripts/install_dependencies.py | 2 +- 6 files changed, 26 insertions(+), 34 deletions(-) delete mode 100644 py-polars/docs/requirements-docs.txt diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 4f082a01196d..876186eb2a9e 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -30,11 +30,11 @@ jobs: with: python-version: '3.11' cache: pip - cache-dependency-path: py-polars/docs/requirements-docs.txt + cache-dependency-path: py-polars/pyproject.toml - name: Install Python dependencies - working-directory: py-polars/docs - run: pip install -r requirements-docs.txt + working-directory: py-polars + run: python scripts/install_dependencies.py --tag dev-docs - name: Build Python documentation working-directory: py-polars/docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index ab6a6b701ad2..68d664740a66 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.11' - name: Install Python dependencies - run: python scripts/install_dependencies.py --tag lint + run: python scripts/install_dependencies.py --tag dev-lint - name: Lint Python run: | @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: | - python scripts/install_dependencies.py --tag dev,all,lint + python scripts/install_dependencies.py --tag dev,all,dev-lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/py-polars/Makefile b/py-polars/Makefile index 8d2ce6770d7f..b69a19903ed0 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -18,7 +18,6 @@ endif requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip $(VENV_BIN)/python scripts/install_dependencies.py - $(VENV_BIN)/pip install -r docs/requirements-docs.txt .PHONY: build build: .venv ## Compile and install Polars for development diff --git a/py-polars/docs/requirements-docs.txt b/py-polars/docs/requirements-docs.txt deleted file mode 100644 index 208d366e7fc4..000000000000 --- a/py-polars/docs/requirements-docs.txt +++ /dev/null @@ -1,26 +0,0 @@ ---prefer-binary - -numpy -pandas -pyarrow - -hypothesis==6.79.4; python_version < '3.8' -hypothesis==6.80.0; python_version >= '3.8' - -autodocsumm==0.2.10 -commonmark==0.9.1 -livereload==2.6.3 -numpydoc==1.5.0 -pydata-sphinx-theme==0.13.3 -sphinx==6.2.1 -sphinx-autosummary-accessors==2023.4.0 -sphinx-copybutton==0.5.1 -sphinx-design==0.4.1 -sphinx-favicon==1.0.1 -sphinxcontrib-applehelp==1.0.4 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==2.0.1 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-napoleon==0.7 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.5 diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 72e9d7ff6a15..337b6cfe8c60 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -66,7 +66,7 @@ dev = [ "pytest-cov==4.1.0", "pytest-xdist==3.3.1", ] -lint = [ +dev-lint = [ "black==23.3.0", "blackdoc==0.3.8", "mypy==1.3.0", @@ -74,6 +74,25 @@ lint = [ "typos==1.15", "pandas-stubs==1.2.0.62", ] +dev-docs = [ + "autodocsumm==0.2.10", + "commonmark==0.9.1", + "livereload==2.6.3", + "numpydoc==1.5.0", + "pydata-sphinx-theme==0.13.3", + "sphinx==6.2.1", + "sphinx-autosummary-accessors==2023.4.0", + "sphinx-copybutton==0.5.1", + "sphinx-design==0.4.1", + "sphinx-favicon==1.0.1", + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-jsmath==1.0.1", + "sphinxcontrib-napoleon==0.7", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", +] [tool.mypy] files = ["polars", "tests"] diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 8250255837c8..02e862dae79e 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -39,7 +39,7 @@ def collect_dependencies_from_pyproject_toml( tag Select only dependencies under this tag defined in optional-dependencies. Multiple tags can be provided by passing in a comma delimited string, for - example "dev,lint" + example "dev,dev-lint" include_mandatory Whether to return dependencies specified under `dependencies` in pyproject.toml. From a3287d0d623b4b1b672e4e18d0499e1c3a0df16b Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:30:27 +0200 Subject: [PATCH 15/33] Fix connectorx python version --- py-polars/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 337b6cfe8c60..4444dc71fd24 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -45,7 +45,7 @@ pyarrow = ["pyarrow>=7.0.0"] pandas = ["pyarrow>=7.0.0", "pandas"] numpy = ["numpy >= 1.16.0"] fsspec = ["fsspec"] -connectorx = ["connectorx >= 0.3.2a5"] # Latest full release is broken - unpin when 0.3.2 released +connectorx = ["connectorx >= 0.3.2a5; python_version >= '3.8'"] # Latest full release is broken - unpin when 0.3.2 released xlsx2csv = ["xlsx2csv >= 0.8.0"] deltalake = ["deltalake >= 0.10.0"] timezone = ["backports.zoneinfo; python_version < '3.9'", "tzdata; platform_system == 'Windows'"] From 28755befac759a81c8c6cc5817f68ca4d6b360ef Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:33:49 +0200 Subject: [PATCH 16/33] Fix pyproject.toml formatting --- py-polars/pyproject.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 4444dc71fd24..74088e800205 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -45,7 +45,9 @@ pyarrow = ["pyarrow>=7.0.0"] pandas = ["pyarrow>=7.0.0", "pandas"] numpy = ["numpy >= 1.16.0"] fsspec = ["fsspec"] -connectorx = ["connectorx >= 0.3.2a5; python_version >= '3.8'"] # Latest full release is broken - unpin when 0.3.2 released +connectorx = [ + "connectorx >= 0.3.2a5; python_version >= '3.8'", +] # Latest full release is broken - unpin when 0.3.2 released xlsx2csv = ["xlsx2csv >= 0.8.0"] deltalake = ["deltalake >= 0.10.0"] timezone = ["backports.zoneinfo; python_version < '3.9'", "tzdata; platform_system == 'Windows'"] From b3a047122f607080e82c98061ae72219059f2bfe Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:38:37 +0200 Subject: [PATCH 17/33] Add hypothesis to doc deps --- py-polars/pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 74088e800205..0ac555801426 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -62,7 +62,7 @@ all = [ # The tags below are for development of Polars. We pin precise versions here, as we have full control on this dev = [ - "hypothesis==6.75.1", + "hypothesis==6.75.1", # defined above as well, keep same version! "maturin==1.0.1", "pytest==7.3.0", "pytest-cov==4.1.0", @@ -77,6 +77,7 @@ dev-lint = [ "pandas-stubs==1.2.0.62", ] dev-docs = [ + "hypothesis==6.75.1", # defined above as well, keep same version! "autodocsumm==0.2.10", "commonmark==0.9.1", "livereload==2.6.3", From 5a42edcbd0ac93d17e6cb0af43b080d37d7addd3 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:44:17 +0200 Subject: [PATCH 18/33] Add missing dependencies to doc tag --- py-polars/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 0ac555801426..f9cc449e1ab8 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -77,6 +77,9 @@ dev-lint = [ "pandas-stubs==1.2.0.62", ] dev-docs = [ + "numpy", + "pandas", + "pyarrow", "hypothesis==6.75.1", # defined above as well, keep same version! "autodocsumm==0.2.10", "commonmark==0.9.1", From cb5713e7c7d3d97c6aafe0011bd61e6e41699c66 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:45:09 +0200 Subject: [PATCH 19/33] Improve doc tags --- py-polars/pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index f9cc449e1ab8..0d3d168639c7 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -77,9 +77,7 @@ dev-lint = [ "pandas-stubs==1.2.0.62", ] dev-docs = [ - "numpy", - "pandas", - "pyarrow", + "polars[pyarrow,pandas,numpy]", "hypothesis==6.75.1", # defined above as well, keep same version! "autodocsumm==0.2.10", "commonmark==0.9.1", From b8c41a01dbbe46526f763e3025b8dc55936a313e Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:51:01 +0200 Subject: [PATCH 20/33] DRY hypothesis --- py-polars/pyproject.toml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 0d3d168639c7..1043d1f5068d 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -61,8 +61,11 @@ all = [ ] # The tags below are for development of Polars. We pin precise versions here, as we have full control on this -dev = [ - "hypothesis==6.75.1", # defined above as well, keep same version! +dev-hypothesis = [ + "hypothesis==6.75.1", +] +dev-test = [ + "polars[dev-hypothesis]", "maturin==1.0.1", "pytest==7.3.0", "pytest-cov==4.1.0", @@ -78,7 +81,7 @@ dev-lint = [ ] dev-docs = [ "polars[pyarrow,pandas,numpy]", - "hypothesis==6.75.1", # defined above as well, keep same version! + "polars[dev-hypothesis]", "autodocsumm==0.2.10", "commonmark==0.9.1", "livereload==2.6.3", From c15e9f1894ea243a94134cd433abb625c258825a Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 21:52:03 +0200 Subject: [PATCH 21/33] Rename tag dev to dev-test --- .github/workflows/benchmark.yml | 2 +- .github/workflows/lint-python.yml | 2 +- .github/workflows/test-python.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 424aa5192e46..095d7e7c6274 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py --tag dev,all + run: python scripts/install_dependencies.py --tag dev-test,all - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 68d664740a66..0718e2359072 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: | - python scripts/install_dependencies.py --tag dev,all,dev-lint + python scripts/install_dependencies.py --tag dev-test,all,dev-lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index e395cc1a77a1..6ba560662f9f 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -47,7 +47,7 @@ jobs: echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - name: Install dependencies - run: python scripts/install_dependencies.py --tag dev,all + run: python scripts/install_dependencies.py --tag dev-test,all - name: Set up Rust run: rustup show @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python scripts/install_dependencies.py --tag dev,all + run: python scripts/install_dependencies.py --tag dev-test,all - name: Set up Rust run: rustup show From b6194d1fb71218f089a30f53d2023d99c006a623 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 22:06:25 +0200 Subject: [PATCH 22/33] Clean up parser --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs-python.yml | 2 +- .github/workflows/lint-python.yml | 4 +- .github/workflows/test-python.yml | 4 +- py-polars/Makefile | 2 +- py-polars/scripts/install_dependencies.py | 68 +++++++++-------------- 6 files changed, 32 insertions(+), 50 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 095d7e7c6274..ac87dbe69d5d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py --tag dev-test,all + run: python scripts/install_dependencies.py dev-test,all - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 876186eb2a9e..5db24de53f99 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -34,7 +34,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py --tag dev-docs + run: python scripts/install_dependencies.py dev-docs - name: Build Python documentation working-directory: py-polars/docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 0718e2359072..ea7e9366a51b 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.11' - name: Install Python dependencies - run: python scripts/install_dependencies.py --tag dev-lint + run: python scripts/install_dependencies.py dev-lint - name: Lint Python run: | @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: | - python scripts/install_dependencies.py --tag dev-test,all,dev-lint + python scripts/install_dependencies.py dev-test,all,dev-lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 6ba560662f9f..caf37064f653 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -47,7 +47,7 @@ jobs: echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - name: Install dependencies - run: python scripts/install_dependencies.py --tag dev-test,all + run: python scripts/install_dependencies.py dev-test,all - name: Set up Rust run: rustup show @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python scripts/install_dependencies.py --tag dev-test,all + run: python scripts/install_dependencies.py dev-test,all - name: Set up Rust run: rustup show diff --git a/py-polars/Makefile b/py-polars/Makefile index b69a19903ed0..4f71d6fc89c1 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -17,7 +17,7 @@ endif .PHONY: requirements requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip - $(VENV_BIN)/python scripts/install_dependencies.py + $(VENV_BIN)/python scripts/install_dependencies.py all,dev-test,dev-lint,dev-docs .PHONY: build build: .venv ## Compile and install Polars for development diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 02e862dae79e..90ee324968a6 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -12,7 +12,6 @@ import argparse import subprocess import sys -from itertools import chain from typing import Any @@ -28,79 +27,62 @@ def parse_toml_file(fp) -> dict[str, dict[str, Any]]: return tomllib.load(fp) -def collect_dependencies_from_pyproject_toml( - tag: str | None = None, include_mandatory: bool = True -) -> list[str]: +def collect_dependencies_from_pyproject_toml(tags: str | None = None) -> list[str]: """ Collects all dependencies, mandatory and optional, from pyproject.toml. Parameters ---------- - tag - Select only dependencies under this tag defined in optional-dependencies. + tags + Select dependencies under these tags defined in optional-dependencies. Multiple tags can be provided by passing in a comma delimited string, for - example "dev,dev-lint" - include_mandatory - Whether to return dependencies specified under `dependencies` in pyproject.toml. + example "dev-test,dev-lint". If `None` is passed in, no optional dependencies + are returned. """ with open("pyproject.toml", mode="rb") as fp: config = parse_toml_file(fp) - if tag: - deps = [] - if "," in tag: - for t in tag.split(","): - deps += config["project"]["optional-dependencies"][t] + deps: list[str] = config["project"]["dependencies"] + + if tags: + if "," in tags: + # multiple tags are passed in + for t in tags.split(","): + deps += config["project"]["optional-dependencies"][t.strip()] else: - deps += config["project"]["optional-dependencies"][tag] - if include_mandatory: - deps += config["project"]["dependencies"] - else: - # collect everything - mandatory_deps = config["project"]["dependencies"] - opt_deps = list(chain(*config["project"]["optional-dependencies"].values())) - deps = mandatory_deps + opt_deps + # a single tag is passed in + deps += config["project"]["optional-dependencies"][tags] # resolve polars[] tags for d in deps: - if "[" in d: + if d.startswith("polars["): tags_as_comma_delimited_string = d.split("[")[1].replace("]", "") for pt in tags_as_comma_delimited_string.split(","): deps += config["project"]["optional-dependencies"][pt] - # drop the polars tags from the list - deps2 = [d for d in deps if "[" not in d] + # drop the polars[] tags from the list + deps = [d for d in deps if not d.startswith("polars[")] - return deps2 + return deps -def pip_install(specifiers: list[str]) -> None: - cmd = ["pip", "install"] + specifiers +def install_dependencies(tags: str | None = None) -> None: + deps = collect_dependencies_from_pyproject_toml(tags) + cmd = ["pip", "install"] + deps subprocess.run(cmd, capture_output=False, text=True) -def install_dependencies( - tag: str | None = None, include_mandatory: bool = True -) -> None: - deps = collect_dependencies_from_pyproject_toml(tag, include_mandatory) - pip_install(deps) - - if __name__ == "__main__": parser = argparse.ArgumentParser( description="Install Polars dependencies from pyproject.toml without building Polars" ) parser.add_argument( - "--tag", + "tags", + nargs="?", # allows no arguments to be passed in + default=None, type=str, help="Optional-dependency tag(s) in pyproject.toml. Provide multiple by separating with commas.", ) - parser.add_argument( - "--include_mandatory", - type=bool, - default=True, - help="Include mandatory dependencies", - ) args = parser.parse_args() - install_dependencies(args.tag, args.include_mandatory) + install_dependencies(args.tags) From ac59a260decab340b6f9ce84e4af49cbc3724ef6 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 24 Jun 2023 22:19:15 +0200 Subject: [PATCH 23/33] Simplify code in script --- py-polars/scripts/install_dependencies.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py index 90ee324968a6..231bc47eed5d 100644 --- a/py-polars/scripts/install_dependencies.py +++ b/py-polars/scripts/install_dependencies.py @@ -43,28 +43,24 @@ def collect_dependencies_from_pyproject_toml(tags: str | None = None) -> list[st with open("pyproject.toml", mode="rb") as fp: config = parse_toml_file(fp) + # collect dependencies deps: list[str] = config["project"]["dependencies"] if tags: - if "," in tags: - # multiple tags are passed in - for t in tags.split(","): - deps += config["project"]["optional-dependencies"][t.strip()] - else: - # a single tag is passed in - deps += config["project"]["optional-dependencies"][tags] + for tag in tags.split(","): + deps += config["project"]["optional-dependencies"][tag.strip()] # resolve polars[] tags + deps_resolved: list[str] = [] for d in deps: if d.startswith("polars["): tags_as_comma_delimited_string = d.split("[")[1].replace("]", "") for pt in tags_as_comma_delimited_string.split(","): - deps += config["project"]["optional-dependencies"][pt] - - # drop the polars[] tags from the list - deps = [d for d in deps if not d.startswith("polars[")] + deps_resolved += config["project"]["optional-dependencies"][pt] + else: + deps_resolved.append(d) - return deps + return deps_resolved def install_dependencies(tags: str | None = None) -> None: From ef10a2ae6b5bb0416cbc773d0ed2753fb272ec4f Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sun, 25 Jun 2023 13:32:42 +0200 Subject: [PATCH 24/33] Use maturin develop extras flag --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs-python.yml | 2 +- .github/workflows/lint-python.yml | 4 ++-- .github/workflows/test-python.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index ac87dbe69d5d..e9078aafe375 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -43,7 +43,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py dev-test,all + run: maturin develop --extras dev-test,all - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 5db24de53f99..3dcfe83be67a 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -34,7 +34,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars - run: python scripts/install_dependencies.py dev-docs + run: maturin develop --extras dev-docs - name: Build Python documentation working-directory: py-polars/docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index ea7e9366a51b..c45043929574 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.11' - name: Install Python dependencies - run: python scripts/install_dependencies.py dev-lint + run: maturin develop --extras dev-lint - name: Lint Python run: | @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: | - python scripts/install_dependencies.py dev-test,all,dev-lint + maturin develop --extras dev-test,all,dev-lint # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index caf37064f653..96ff0cc7e7ff 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -106,7 +106,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Python dependencies - run: python scripts/install_dependencies.py dev-test,all + run: maturin develop --extras dev-test,all - name: Set up Rust run: rustup show From 1b1738b0bb1c41147dbbb8ef5c5c13f1e3d32fef Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sun, 25 Jun 2023 13:37:31 +0200 Subject: [PATCH 25/33] Fix --- .github/workflows/test-python.yml | 5 +---- py-polars/Makefile | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 96ff0cc7e7ff..e0332bacc20f 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -46,9 +46,6 @@ jobs: python -m venv .venv echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH - - name: Install dependencies - run: python scripts/install_dependencies.py dev-test,all - - name: Set up Rust run: rustup show @@ -61,7 +58,7 @@ jobs: - name: Install Polars run: | source activate - maturin develop + maturin develop --extras dev-test,all - name: Run tests and report coverage if: github.ref_name != 'main' diff --git a/py-polars/Makefile b/py-polars/Makefile index 4f71d6fc89c1..2c0971e42487 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -17,7 +17,7 @@ endif .PHONY: requirements requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip - $(VENV_BIN)/python scripts/install_dependencies.py all,dev-test,dev-lint,dev-docs + maturin develop --extras all,dev-test,dev-lint,dev-docs .PHONY: build build: .venv ## Compile and install Polars for development From ee2d68e11983b0d96f4d0274b1c64711a2d9ba9b Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sun, 25 Jun 2023 13:38:11 +0200 Subject: [PATCH 26/33] Remove custom script --- py-polars/scripts/install_dependencies.py | 84 ----------------------- 1 file changed, 84 deletions(-) delete mode 100644 py-polars/scripts/install_dependencies.py diff --git a/py-polars/scripts/install_dependencies.py b/py-polars/scripts/install_dependencies.py deleted file mode 100644 index 231bc47eed5d..000000000000 --- a/py-polars/scripts/install_dependencies.py +++ /dev/null @@ -1,84 +0,0 @@ -""" -Install Polars dependencies as defined in pyproject.toml without building Polars. - -In our dev workflow, we often want to either not build (Rust) Polars at all, or in -develop mode. Unfortunately, `pip install .` or `pip install . -e` will always call -`maturin build` to build Polars. This is very slow compared to `maturin develop`. -We work around this by calling `maturin develop`, and for the Python dependencies, -this script collects the relevant tags from pyproject.toml and pass to `pip install`. -""" -from __future__ import annotations - -import argparse -import subprocess -import sys -from typing import Any - - -def parse_toml_file(fp) -> dict[str, dict[str, Any]]: - if sys.version_info < (3, 11): - subprocess.run(["pip", "install", "tomli"], capture_output=False, text=True) - import tomli - - return tomli.load(fp) - else: - import tomllib - - return tomllib.load(fp) - - -def collect_dependencies_from_pyproject_toml(tags: str | None = None) -> list[str]: - """ - Collects all dependencies, mandatory and optional, from pyproject.toml. - - Parameters - ---------- - tags - Select dependencies under these tags defined in optional-dependencies. - Multiple tags can be provided by passing in a comma delimited string, for - example "dev-test,dev-lint". If `None` is passed in, no optional dependencies - are returned. - - """ - with open("pyproject.toml", mode="rb") as fp: - config = parse_toml_file(fp) - - # collect dependencies - deps: list[str] = config["project"]["dependencies"] - - if tags: - for tag in tags.split(","): - deps += config["project"]["optional-dependencies"][tag.strip()] - - # resolve polars[] tags - deps_resolved: list[str] = [] - for d in deps: - if d.startswith("polars["): - tags_as_comma_delimited_string = d.split("[")[1].replace("]", "") - for pt in tags_as_comma_delimited_string.split(","): - deps_resolved += config["project"]["optional-dependencies"][pt] - else: - deps_resolved.append(d) - - return deps_resolved - - -def install_dependencies(tags: str | None = None) -> None: - deps = collect_dependencies_from_pyproject_toml(tags) - cmd = ["pip", "install"] + deps - subprocess.run(cmd, capture_output=False, text=True) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description="Install Polars dependencies from pyproject.toml without building Polars" - ) - parser.add_argument( - "tags", - nargs="?", # allows no arguments to be passed in - default=None, - type=str, - help="Optional-dependency tag(s) in pyproject.toml. Provide multiple by separating with commas.", - ) - args = parser.parse_args() - install_dependencies(args.tags) From 83314bf05fda57bb12ecc2cdab2f56e0ac0144bf Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Mon, 26 Jun 2023 19:09:17 +0100 Subject: [PATCH 27/33] Install maturin with pip --- .github/workflows/benchmark.yml | 13 ++++++++++++- .github/workflows/docs-python.yml | 13 ++++++++++++- .github/workflows/lint-python.yml | 22 +++++++++++++++++++++- .github/workflows/test-python.yml | 8 +++----- py-polars/Makefile | 1 + py-polars/pyproject.toml | 1 - 6 files changed, 49 insertions(+), 9 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e9078aafe375..64ad2894b06d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -41,9 +41,20 @@ jobs: python -m venv .venv echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH + - name: Set up Rust + run: rustup show + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: py-polars + save-if: ${{ github.ref_name == 'main' }} + - name: Install Python dependencies working-directory: py-polars - run: maturin develop --extras dev-test,all + run: | + pip install maturin=1.0.1 + maturin develop --extras dev-test,all - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 3dcfe83be67a..d5853ebc7500 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -32,9 +32,20 @@ jobs: cache: pip cache-dependency-path: py-polars/pyproject.toml + - name: Set up Rust + run: rustup show + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: py-polars + save-if: ${{ github.ref_name == 'main' }} + - name: Install Python dependencies working-directory: py-polars - run: maturin develop --extras dev-docs + run: | + pip install maturin=1.0.1 + maturin develop --extras dev-docs - name: Build Python documentation working-directory: py-polars/docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index c45043929574..53f9de79bfcc 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -24,9 +24,19 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' + - name: Set up Rust + run: rustup show + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: py-polars + save-if: ${{ github.ref_name == 'main' }} - name: Install Python dependencies - run: maturin develop --extras dev-lint + run: | + pip install maturin==1.0.1 + maturin develop --extras dev-lint - name: Lint Python run: | @@ -52,8 +62,18 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Set up Rust + run: rustup show + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: py-polars + save-if: ${{ github.ref_name == 'main' }} + - name: Install dependencies run: | + pip install maturin=1.0.1 maturin develop --extras dev-test,all,dev-lint # Allow untyped calls for older Python versions diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index e0332bacc20f..45764cb535d2 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -58,6 +58,7 @@ jobs: - name: Install Polars run: | source activate + pip install maturin==1.0.1 maturin develop --extras dev-test,all - name: Run tests and report coverage @@ -102,9 +103,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install Python dependencies - run: maturin develop --extras dev-test,all - - name: Set up Rust run: rustup show @@ -117,8 +115,8 @@ jobs: - name: Install Polars shell: bash run: | - maturin build - pip install target/wheels/polars-*.whl + pip install maturin==1.0.1 + maturin develop --extras dev-test,all - name: Run tests if: github.ref_name != 'main' diff --git a/py-polars/Makefile b/py-polars/Makefile index 2c0971e42487..916d973af0a5 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -17,6 +17,7 @@ endif .PHONY: requirements requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip + $(VENV_BIN)/python -m pip install maturin==1.0.1 maturin develop --extras all,dev-test,dev-lint,dev-docs .PHONY: build diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 1043d1f5068d..7d3b6677995a 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -66,7 +66,6 @@ dev-hypothesis = [ ] dev-test = [ "polars[dev-hypothesis]", - "maturin==1.0.1", "pytest==7.3.0", "pytest-cov==4.1.0", "pytest-xdist==3.3.1", From f6167364bbe2e2e473782198be79d61744461b3e Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Mon, 26 Jun 2023 19:13:41 +0100 Subject: [PATCH 28/33] Fix pip install command --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs-python.yml | 2 +- .github/workflows/lint-python.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 64ad2894b06d..d913607e9348 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -53,7 +53,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars run: | - pip install maturin=1.0.1 + pip install maturin==1.0.1 maturin develop --extras dev-test,all - name: Load benchmark data from cache diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index d5853ebc7500..ce6d02f10d82 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -44,7 +44,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars run: | - pip install maturin=1.0.1 + pip install maturin==1.0.1 maturin develop --extras dev-docs - name: Build Python documentation diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 53f9de79bfcc..89170db6e1cd 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -73,7 +73,7 @@ jobs: - name: Install dependencies run: | - pip install maturin=1.0.1 + pip install maturin==1.0.1 maturin develop --extras dev-test,all,dev-lint # Allow untyped calls for older Python versions From c738a6138299311123a23c92e2081a7c85479736 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Mon, 26 Jun 2023 19:14:22 +0100 Subject: [PATCH 29/33] Fix yaml --- .github/workflows/lint-python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 89170db6e1cd..5d1f2228fe10 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -24,7 +24,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - - name: Set up Rust + + - name: Set up Rust run: rustup show - name: Cache Rust From 1f10618d1ea0d73c382658227097c8b5e2868adf Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 1 Jul 2023 14:37:43 +0100 Subject: [PATCH 30/33] Avoid polars all tag. Pip incorrectly uses the released Polars version, leading to outdated definitions. --- .github/workflows/benchmark.yml | 2 +- .github/workflows/lint-python.yml | 2 +- .github/workflows/test-python.yml | 5 +++-- py-polars/Makefile | 10 +++++++--- py-polars/pyproject.toml | 7 +------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d913607e9348..8e4619df603c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -54,7 +54,7 @@ jobs: working-directory: py-polars run: | pip install maturin==1.0.1 - maturin develop --extras dev-test,all + maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 5d1f2228fe10..1e03a68558d0 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -75,7 +75,7 @@ jobs: - name: Install dependencies run: | pip install maturin==1.0.1 - maturin develop --extras dev-test,all,dev-lint + maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 45764cb535d2..dba4c5ddbc8e 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -59,7 +59,8 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,all + # the list of tags should be in sync with the Makefile + maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests and report coverage if: github.ref_name != 'main' @@ -116,7 +117,7 @@ jobs: shell: bash run: | pip install maturin==1.0.1 - maturin develop --extras dev-test,all + maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests if: github.ref_name != 'main' diff --git a/py-polars/Makefile b/py-polars/Makefile index 916d973af0a5..868d87a9f9e2 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -18,18 +18,22 @@ endif requirements: .venv ## Install/refresh all project requirements $(VENV_BIN)/python -m pip install --upgrade pip $(VENV_BIN)/python -m pip install maturin==1.0.1 - maturin develop --extras all,dev-test,dev-lint,dev-docs .PHONY: build build: .venv ## Compile and install Polars for development - @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop + # NOTE: ideally, we can use the all tag available in pyproject.toml, but that has + # the form of "polars[pandas,...]". Pip incorrectly parses that as using the released + # polars version, rather than self referencing. So we avoid the all tag here. + # @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras all,dev-test,dev-lint,dev-docs + @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic,dev-test,dev-lint,dev-docs + .PHONY: build-release build-release: .venv ## Compile and install a faster Polars binary @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --release .PHONY: fmt -fmt: .venv ## Run autoformatting and linting +fmt: .venv build ## Run autoformatting and linting $(VENV_BIN)/ruff . $(VENV_BIN)/black . $(VENV_BIN)/blackdoc . diff --git a/py-polars/pyproject.toml b/py-polars/pyproject.toml index 7d3b6677995a..6996774a3a6a 100644 --- a/py-polars/pyproject.toml +++ b/py-polars/pyproject.toml @@ -55,17 +55,14 @@ matplotlib = ["matplotlib"] sqlalchemy = ["sqlalchemy", "pandas"] xlsxwriter = ["xlsxwriter"] pydantic = ["pydantic"] +hypothesis = ["hypothesis==6.75.1"] adbc = ["adbc_driver_sqlite; python_version >= '3.9' and platform_system != 'Windows'"] all = [ "polars[pyarrow,pandas,numpy,fsspec,connectorx,xlsx2csv,deltalake,timezone,matplotlib,sqlalchemy,adbc,xlsxwriter,pydantic]", ] # The tags below are for development of Polars. We pin precise versions here, as we have full control on this -dev-hypothesis = [ - "hypothesis==6.75.1", -] dev-test = [ - "polars[dev-hypothesis]", "pytest==7.3.0", "pytest-cov==4.1.0", "pytest-xdist==3.3.1", @@ -79,8 +76,6 @@ dev-lint = [ "pandas-stubs==1.2.0.62", ] dev-docs = [ - "polars[pyarrow,pandas,numpy]", - "polars[dev-hypothesis]", "autodocsumm==0.2.10", "commonmark==0.9.1", "livereload==2.6.3", From f053d1cc0f080910a0decb5af74c50273e77df22 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 1 Jul 2023 14:43:28 +0100 Subject: [PATCH 31/33] Activate .venv, otherwise maturin fails --- .github/workflows/benchmark.yml | 1 + .github/workflows/docs-python.yml | 1 + .github/workflows/lint-python.yml | 2 ++ .github/workflows/test-python.yml | 1 + 4 files changed, 5 insertions(+) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8e4619df603c..731cc6fe4969 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -53,6 +53,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars run: | + source activate pip install maturin==1.0.1 maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index ce6d02f10d82..1c9e103669bb 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -44,6 +44,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars run: | + source activate pip install maturin==1.0.1 maturin develop --extras dev-docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 1e03a68558d0..13e33f2eb60c 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -36,6 +36,7 @@ jobs: - name: Install Python dependencies run: | + source activate pip install maturin==1.0.1 maturin develop --extras dev-lint @@ -74,6 +75,7 @@ jobs: - name: Install dependencies run: | + source activate pip install maturin==1.0.1 maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index dba4c5ddbc8e..994e115f980f 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -116,6 +116,7 @@ jobs: - name: Install Polars shell: bash run: | + source activate pip install maturin==1.0.1 maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic From 3934dfea2b14feee3a5b3362bb95f0964cbcae50 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 1 Jul 2023 14:56:36 +0100 Subject: [PATCH 32/33] Update --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs-python.yml | 5 +++++ .github/workflows/lint-python.yml | 12 +++++++++++- .github/workflows/test-python.yml | 4 ++-- py-polars/Makefile | 2 +- py-polars/bla.txt | 1 + 6 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 py-polars/bla.txt diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 731cc6fe4969..8cd528ef022a 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -55,7 +55,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index 1c9e103669bb..de8d5d253b89 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -32,6 +32,11 @@ jobs: cache: pip cache-dependency-path: py-polars/pyproject.toml + - name: Create virtual environment + run: | + python -m venv .venv + echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH + - name: Set up Rust run: rustup show diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 13e33f2eb60c..9844909309ae 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -25,6 +25,11 @@ jobs: with: python-version: '3.11' + - name: Create virtual environment + run: | + python -m venv .venv + echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH + - name: Set up Rust run: rustup show @@ -64,6 +69,11 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Create virtual environment + run: | + python -m venv .venv + echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH + - name: Set up Rust run: rustup show @@ -77,7 +87,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 994e115f980f..122ccd1dc126 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -60,7 +60,7 @@ jobs: source activate pip install maturin==1.0.1 # the list of tags should be in sync with the Makefile - maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests and report coverage if: github.ref_name != 'main' @@ -118,7 +118,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests if: github.ref_name != 'main' diff --git a/py-polars/Makefile b/py-polars/Makefile index 868d87a9f9e2..ee5d289ad185 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -25,7 +25,7 @@ build: .venv ## Compile and install Polars for development # the form of "polars[pandas,...]". Pip incorrectly parses that as using the released # polars version, rather than self referencing. So we avoid the all tag here. # @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras all,dev-test,dev-lint,dev-docs - @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras pyarrow,pandas,fsspec,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic,dev-test,dev-lint,dev-docs + @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic,dev-test,dev-lint,dev-docs .PHONY: build-release diff --git a/py-polars/bla.txt b/py-polars/bla.txt new file mode 100644 index 000000000000..b2a894dc8cf4 --- /dev/null +++ b/py-polars/bla.txt @@ -0,0 +1 @@ +hello world, oh no, polars \ No newline at end of file From 171554970fad17f2e265a378ef834f6083bb3102 Mon Sep 17 00:00:00 2001 From: Jeroen van Zundert Date: Sat, 1 Jul 2023 15:06:02 +0100 Subject: [PATCH 33/33] Update --- .github/workflows/benchmark.yml | 2 +- .github/workflows/docs-python.yml | 2 +- .github/workflows/lint-python.yml | 2 +- .github/workflows/test-python.yml | 4 ++-- py-polars/Makefile | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8cd528ef022a..5552766e1bfd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -55,7 +55,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,timezone,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Load benchmark data from cache id: cache-data diff --git a/.github/workflows/docs-python.yml b/.github/workflows/docs-python.yml index de8d5d253b89..321554ccdb3b 100644 --- a/.github/workflows/docs-python.yml +++ b/.github/workflows/docs-python.yml @@ -49,7 +49,7 @@ jobs: - name: Install Python dependencies working-directory: py-polars run: | - source activate + source $GITHUB_WORKSPACE/py-polars/.venv/Scripts/activate pip install maturin==1.0.1 maturin develop --extras dev-docs diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 9844909309ae..b4dabdb5ceab 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -87,7 +87,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,dev-lint,pyarrow,pandas,fsspec,timezone,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic # Allow untyped calls for older Python versions - name: Run mypy diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 122ccd1dc126..d36f8379278a 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -60,7 +60,7 @@ jobs: source activate pip install maturin==1.0.1 # the list of tags should be in sync with the Makefile - maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,timezone,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests and report coverage if: github.ref_name != 'main' @@ -118,7 +118,7 @@ jobs: run: | source activate pip install maturin==1.0.1 - maturin develop --extras dev-test,pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic + maturin develop --extras dev-test,pyarrow,pandas,fsspec,timezone,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic - name: Run tests if: github.ref_name != 'main' diff --git a/py-polars/Makefile b/py-polars/Makefile index ee5d289ad185..c6ecba804058 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -25,7 +25,7 @@ build: .venv ## Compile and install Polars for development # the form of "polars[pandas,...]". Pip incorrectly parses that as using the released # polars version, rather than self referencing. So we avoid the all tag here. # @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras all,dev-test,dev-lint,dev-docs - @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras pyarrow,pandas,fsspec,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic,dev-test,dev-lint,dev-docs + @unset CONDA_PREFIX && source $(VENV_BIN)/activate && maturin develop --extras pyarrow,pandas,fsspec,timezone,connectorx,adbc,numpy,hypothesis,xlsxwriter,xlsx2csv,deltalake,pydantic,dev-test,dev-lint,dev-docs .PHONY: build-release