Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the uv package and project manager #408

Merged
merged 13 commits into from
Mar 5, 2025
Merged
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
7 changes: 7 additions & 0 deletions ccds-help.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@
"more_information": "[Docs](https://pipenv.pypa.io/en/latest/)"
}
},
{
"choice": "uv",
"help": {
"description": "An extremely fast Python package and project manager, written in Rust.",
"more_information": "[Docs](https://docs.astral.sh/uv/)"
}
},
{
"choice": "none",
"help": {
Expand Down
1 change: 1 addition & 0 deletions ccds.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"virtualenv",
"conda",
"pipenv",
"uv",
"none"
],
"dependency_file": [
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ pipenv
pytest
termynal
twine
uv
virtualenvwrapper; sys_platform != 'win32'
virtualenvwrapper-win; sys_platform == 'win32'
2 changes: 2 additions & 0 deletions tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def verify_makefile_commands(root, config):
harness_path = test_path / "virtualenv_harness.sh"
elif config["environment_manager"] == "pipenv":
harness_path = test_path / "pipenv_harness.sh"
elif config["environment_manager"] == "uv":
harness_path = test_path / "uv_harness.sh"
elif config["environment_manager"] == "none":
return True
else:
Expand Down
43 changes: 43 additions & 0 deletions tests/uv_harness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -ex

PROJECT_NAME=$(basename $1)
CCDS_ROOT=$(dirname $0)
MODULE_NAME=$2

# Configure exit / teardown behavior
function finish {
# Deactivate venv if we're in one
if [[ $(which python) == *"$PROJECT_NAME"* ]]; then
deactivate
fi
# Clean up venv directory
if [ -d ".venv" ]; then
rm -rf .venv
fi
}
trap finish EXIT

# Source the steps in the test
source $CCDS_ROOT/test_functions.sh

# Navigate to the generated project and run make commands
cd $1
make

# Create and activate virtual environment
make create_environment


# Check if running on Windows and use appropriate activate path
if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* ]]; then
source ".venv/Scripts/activate"
else
source ".venv/bin/activate"
fi

make requirements
make lint
make format

run_tests $PROJECT_NAME $MODULE_NAME
1 change: 0 additions & 1 deletion tests/virtualenv_harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ fi
make requirements

run_tests $PROJECT_NAME $MODULE_NAME

9 changes: 9 additions & 0 deletions {{ cookiecutter.repo_name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ PYTHON_INTERPRETER = python
.PHONY: requirements
requirements:
{% if "requirements.txt" == cookiecutter.dependency_file -%}
{% if "uv" == cookiecutter.environment_manager -%}
uv pip install -r requirements.txt
{% else -%}
$(PYTHON_INTERPRETER) -m pip install -U pip
$(PYTHON_INTERPRETER) -m pip install -r requirements.txt
{% endif -%}
{% elif "environment.yml" == cookiecutter.dependency_file -%}
conda env update --name $(PROJECT_NAME) --file environment.yml --prune
{% elif "Pipfile" == cookiecutter.dependency_file -%}
Expand Down Expand Up @@ -88,6 +92,11 @@ create_environment:
{% elif cookiecutter.environment_manager == 'pipenv' -%}
pipenv --python $(PYTHON_VERSION)
@echo ">>> New pipenv created. Activate with:\npipenv shell"
{% elif cookiecutter.environment_manager == 'uv' -%}
uv venv --python $(PYTHON_VERSION)
@echo ">>> New uv virtual environment created. Activate with:"
@echo ">>> Windows: .\\\\.venv\\\\Scripts\\\\activate"
@echo ">>> Unix/macOS: source ./.venv/bin/activate"
{% endif %}
{% endif %}

Expand Down
Loading