Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install black hatch
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with black
run: |
black --diff --check -t py311 .
Expand Down
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.PHONY: venv install install-dev clean lint test install-uv

# Define variables
VENV_DIR := .venv

# Default target
all: help

# Create virtual environment using uv
venv: install-uv
@echo "Creating virtual environment using uv..."
@uv venv $(VENV_DIR)

# Install dependencies from pyproject.toml
install: venv
@echo "Installing dependencies from pyproject.toml..."
@uv pip install -e .

# Install development dependencies (black and hatch)
install-dev: install
@echo "Installing development dependencies (black and hatch)..."
@uv pip install black hatch

# Clean up virtual environment
clean:
@echo "Cleaning up..."
@rm -rf $(VENV_DIR)
@rm -rf *.egg-info
@rm -rf dist
@rm -rf build
@find . -type d -name __pycache__ -exec rm -rf {} +
@find . -type f -name "*.pyc" -delete

# Run linting with black
lint: install-dev
@echo "Running black..."
@uv run black --diff --check -t py311 .

# Run tests with hatch
test: install-dev
@echo "Running tests with hatch..."
@uv run hatch run cov

# Install uv and uvx
install-uv:
@echo "Installing uv and uvx..."
@curl -LsSf https://astral.sh/uv/install.sh | sh

# Help target
help:
@echo "Available targets:"
@echo " venv - Create virtual environment using uv"
@echo " install - Install dependencies from pyproject.toml"
@echo " install-dev - Install development dependencies (black and hatch)"
@echo " install-uv - Install uv and uvx"
@echo " lint - Run linting with black"
@echo " test - Run tests with hatch"
@echo " clean - Clean up virtual environment and build artifacts"
@echo " all - Create venv and install dependencies (default)"
@echo " help - Show this help message"
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,40 @@ These instructions are tested on Linux and Windows but should work in other envi
as well.

## Prerequisites
You need a Python environment with hatch installed:
You need a Python environment with either hatch or uv installed:

```bash
# Install hatch
$ pip install hatch

# Or install uv
$ pip install uv
```

## Using the Makefile (recommended)
A Makefile is provided to simplify development setup. It uses uv to create a virtual environment and install dependencies.

```bash
# Show available commands
$ make help

# Create virtual environment and install all dependencies
$ make all

# Install development dependencies (black and hatch)
$ make install-dev

# Run tests
$ make test

# Run linting
$ make lint

# Install uv and uvx (if not already installed)
$ make install-uv

# Clean up
$ make clean
```

## Build Memento
Expand Down
2 changes: 1 addition & 1 deletion tests/test_storage_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def test_serialize_longbytes(self):
@pytest.mark.slow
def test_serialize_longstring(self):
strategy = DefaultCodec.ValuePickleStrategy()
val = "\u0009\u000A\u0026\u2022\u25E6\u2219\u2023\u2043" * (2**27)
val = "\u0009\u000a\u0026\u2022\u25e6\u2219\u2023\u2043" * (2**27)
encoded = strategy.encode(val)
decoded = strategy.decode(encoded)
assert val == decoded, f"Failed test on: {val}, decoded={decoded}"
Expand Down
2 changes: 1 addition & 1 deletion twosigma/memento/code_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def hash_if_code_object(o):


def resolve_to_symbolic_names(
dependencies: List[Union[str, MementoFunctionType]]
dependencies: List[Union[str, MementoFunctionType]],
) -> Set[str]:
"""
Takes a set of str and MementoFunctionType and resolves each to a symbolic name,
Expand Down