diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 829f321..fc2b739 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -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 . diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0a9dbdc --- /dev/null +++ b/Makefile @@ -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" \ No newline at end of file diff --git a/README.md b/README.md index 6b1e5ec..abb949e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tests/test_storage_base.py b/tests/test_storage_base.py index 21d0d14..815edd3 100644 --- a/tests/test_storage_base.py +++ b/tests/test_storage_base.py @@ -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}" diff --git a/twosigma/memento/code_hash.py b/twosigma/memento/code_hash.py index 9667ed7..578af87 100644 --- a/twosigma/memento/code_hash.py +++ b/twosigma/memento/code_hash.py @@ -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,