Skip to content

Commit

Permalink
chore(python): Create .venv in repo root (#10789)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored Aug 30, 2023
1 parent 43ab40d commit 6759b53
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 39 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 1 addition & 16 deletions .github/workflows/test-bytecode-parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
27 changes: 15 additions & 12 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
12 changes: 4 additions & 8 deletions py-polars/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

PYTHONPATH=
SHELL=/bin/bash
VENV = .venv
VENV=../.venv

ifeq ($(OS),Windows_NT)
VENV_BIN=$(VENV)/Scripts
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
Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit 6759b53

Please sign in to comment.