diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b467a0ef05a9..de2bfc326ae1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -36,10 +36,9 @@ jobs: python-version: '3.11' - name: Create virtual environment - working-directory: py-polars run: | python -m venv .venv - echo "$GITHUB_WORKSPACE/py-polars/.venv/bin" >> $GITHUB_PATH + echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH - name: Install Python dependencies working-directory: py-polars diff --git a/.github/workflows/test-bytecode-parser.yml b/.github/workflows/test-bytecode-parser.yml index dacbc209b62a..dc8e6c09ce9e 100644 --- a/.github/workflows/test-bytecode-parser.yml +++ b/.github/workflows/test-bytecode-parser.yml @@ -5,21 +5,11 @@ on: paths: - py-polars/** - .github/workflows/test-bytecode-parser.yml - push: - branches: - - main - paths: - - py-polars/** - - .github/workflows/test-bytecode-parser.yml concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -defaults: - run: - working-directory: py-polars - jobs: ubuntu: runs-on: ubuntu-latest @@ -36,14 +26,9 @@ 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: Install dependencies run: pip install ipython numpy pytest - name: Run tests - if: github.ref_name != 'main' + working-directory: py-polars run: PYTHONPATH=polars/utils pytest tests/test_udfs.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a94b18b89c1..315ac4c8acd8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,7 +87,7 @@ make test This will do a number of things: -- Use Python to create a virtual environment in the `py-polars/.venv` folder. +- Use Python to create a virtual environment in the `.venv` folder. - Use [pip](https://pip.pypa.io/) to install all Python dependencies for development, linting, and building documentation. - Use Rust to compile and install Polars in your virtual environment. - Use [pytest](https://docs.pytest.org/) to run the Python unittests in your virtual environment diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..532342913f97 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +.DEFAULT_GOAL := help + +PYTHONPATH= +SHELL=/bin/bash +VENV=.venv + +ifeq ($(OS),Windows_NT) + VENV_BIN=$(VENV)/Scripts +else + VENV_BIN=$(VENV)/bin +endif + +.venv: ## Set up Python virtual environment and install requirements + python3 -m venv $(VENV) + $(MAKE) requirements + +.PHONY: requirements +requirements: .venv ## Install/refresh Python project requirements + $(VENV_BIN)/python -m pip install --upgrade pip + $(VENV_BIN)/pip install --upgrade -r py-polars/requirements-dev.txt + $(VENV_BIN)/pip install --upgrade -r py-polars/requirements-lint.txt + $(VENV_BIN)/pip install --upgrade -r py-polars/docs/requirements-docs.txt + +.PHONY: clean +clean: ## Clean up caches and build artifacts + @rm -rf .venv/ + @rm -rf target/ + @rm -f Cargo.lock + @cargo clean + @$(MAKE) -s -C py-polars/ $@ + +.PHONY: help +help: ## Display this help screen + @echo -e "\033[1mAvailable commands:\033[0m" + @grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort diff --git a/dprint.json b/dprint.json index 60290669328c..8e9d0d92e909 100644 --- a/dprint.json +++ b/dprint.json @@ -1,14 +1,17 @@ { - "includes": [ - "**/*.{md,toml}" - ], - "excludes": [ - "**/target", - "py-polars/.pytest_cache", - "py-polars/.venv" - ], - "plugins": [ - "https://plugins.dprint.dev/markdown-0.15.2.wasm", - "https://plugins.dprint.dev/toml-0.5.4.wasm" - ] + "includes": [ + "**/*.{md,toml}" + ], + "excludes": [ + ".venv/", + "**/target/", + "py-polars/.hypothesis/", + "py-polars/.mypy_cache/", + "py-polars/.pytest_cache/", + "py-polars/.ruff_cache/" + ], + "plugins": [ + "https://plugins.dprint.dev/markdown-0.16.0.wasm", + "https://plugins.dprint.dev/toml-0.5.4.wasm" + ] } diff --git a/py-polars/Makefile b/py-polars/Makefile index e0fcee1b83a5..f5fd7c4404cd 100644 --- a/py-polars/Makefile +++ b/py-polars/Makefile @@ -2,7 +2,7 @@ PYTHONPATH= SHELL=/bin/bash -VENV = .venv +VENV=../.venv ifeq ($(OS),Windows_NT) VENV_BIN=$(VENV)/Scripts @@ -10,16 +10,13 @@ else VENV_BIN=$(VENV)/bin endif +.PHONY: .venv .venv: ## Set up virtual environment and install requirements - python3 -m venv $(VENV) - $(MAKE) requirements + @$(MAKE) -s -C .. $@ .PHONY: requirements requirements: .venv ## Install/refresh all project requirements - $(VENV_BIN)/python -m pip install --upgrade pip - $(VENV_BIN)/pip install --upgrade -r requirements-dev.txt - $(VENV_BIN)/pip install --upgrade -r requirements-lint.txt - $(VENV_BIN)/pip install --upgrade -r docs/requirements-docs.txt + @$(MAKE) -s -C .. $@ .PHONY: build build: .venv ## Compile and install Polars for development @@ -91,7 +88,6 @@ coverage: .venv build ## Run tests and report coverage .PHONY: clean clean: ## Clean up caches and build artifacts - @rm -rf .venv/ @rm -rf target/ @rm -rf docs/build/ @rm -rf docs/source/reference/api/