diff --git a/compiled_starters/python/.codecrafters/run.sh b/compiled_starters/python/.codecrafters/run.sh index 4b294809..b616c2ab 100755 --- a/compiled_starters/python/.codecrafters/run.sh +++ b/compiled_starters/python/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec pipenv run python3 -m app.main "$@" +exec uv run --quiet -m app.main "$@" \ No newline at end of file diff --git a/compiled_starters/python/.gitignore b/compiled_starters/python/.gitignore index 06109db2..fe2425e1 100644 --- a/compiled_starters/python/.gitignore +++ b/compiled_starters/python/.gitignore @@ -94,6 +94,12 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more @@ -106,8 +112,10 @@ ipython_config.py #pdm.lock # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it # in version control. -# https://pdm.fming.dev/#use-with-ide +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control .pdm.toml +.pdm-python +.pdm-build/ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ @@ -151,3 +159,16 @@ dmypy.json # Cython debug symbols cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc \ No newline at end of file diff --git a/compiled_starters/python/.python-version b/compiled_starters/python/.python-version new file mode 100644 index 00000000..6324d401 --- /dev/null +++ b/compiled_starters/python/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/compiled_starters/python/Pipfile b/compiled_starters/python/Pipfile deleted file mode 100644 index 68c079ed..00000000 --- a/compiled_starters/python/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -pyparsing = "~=3.0" -lark = "~=1.1" - -[dev-packages] - -[requires] -python_version = "3" diff --git a/compiled_starters/python/Pipfile.lock b/compiled_starters/python/Pipfile.lock deleted file mode 100644 index 5274de2e..00000000 --- a/compiled_starters/python/Pipfile.lock +++ /dev/null @@ -1,37 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "636ee93600ada7ba54b93ebb3484fcb8e306b2ca2ef6289c37dbbd3cc7b9c909" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "lark": { - "hashes": [ - "sha256:7a8d0c07d663da9391d7faee1bf1d7df4998c47ca43a593cbef5c7566acd057a", - "sha256:c1ab213fc5e2d273fe2d91da218ccc8b5b92d065b17faa5e743499cb16594b7d" - ], - "index": "pypi", - "version": "==1.1.2" - }, - "pyparsing": { - "hashes": [ - "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - ], - "index": "pypi", - "version": "==3.0.9" - } - }, - "develop": {} -} diff --git a/compiled_starters/python/README.md b/compiled_starters/python/README.md index 06a43d63..99eff0ff 100644 --- a/compiled_starters/python/README.md +++ b/compiled_starters/python/README.md @@ -31,7 +31,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `python (3.13)` installed locally +1. Ensure you have `uv` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `app/main.py`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/compiled_starters/python/codecrafters.yml b/compiled_starters/python/codecrafters.yml index bd98df7e..995338c9 100644 --- a/compiled_starters/python/codecrafters.yml +++ b/compiled_starters/python/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Python version used to run your code # on Codecrafters. # -# Available versions: python-3.13 -buildpack: python-3.13 +# Available versions: python-3.14 +buildpack: python-3.14 diff --git a/compiled_starters/python/pyproject.toml b/compiled_starters/python/pyproject.toml new file mode 100644 index 00000000..c0f8c448 --- /dev/null +++ b/compiled_starters/python/pyproject.toml @@ -0,0 +1,5 @@ +[project] +name = "codecrafters-grep" +version = "0.1.0" +requires-python = ">=3.14" +dependencies = [] diff --git a/compiled_starters/python/uv.lock b/compiled_starters/python/uv.lock new file mode 100644 index 00000000..bc57bb57 --- /dev/null +++ b/compiled_starters/python/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 3 +requires-python = ">=3.14" + +[[package]] +name = "codecrafters-grep" +version = "0.1.0" +source = { virtual = "." } diff --git a/compiled_starters/python/your_program.sh b/compiled_starters/python/your_program.sh index 0fa36a5a..6f090df9 100755 --- a/compiled_starters/python/your_program.sh +++ b/compiled_starters/python/your_program.sh @@ -12,4 +12,4 @@ set -e # Exit early if any commands fail # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec pipenv run python3 -m app.main "$@" +exec uv run --quiet -m app.main "$@" diff --git a/dockerfiles/python-3.14.Dockerfile b/dockerfiles/python-3.14.Dockerfile new file mode 100644 index 00000000..d4f618df --- /dev/null +++ b/dockerfiles/python-3.14.Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:1.7-labs +FROM astral/uv:python3.14-alpine + +# Ensures the container is re-built if dependency files change +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="pyproject.toml,uv.lock" + +# Prevents Python from buffering stdout and stderr +ENV PYTHONUNBUFFERED=1 + +ENV PYTHONPATH=/app:$PYTHONPATH + +WORKDIR /app + +# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses +COPY --exclude=.git --exclude=README.md . /app + +# Force environment creation +RUN uv sync \ No newline at end of file diff --git a/solutions/python/01-cq2/code/.codecrafters/run.sh b/solutions/python/01-cq2/code/.codecrafters/run.sh index 4b294809..b616c2ab 100755 --- a/solutions/python/01-cq2/code/.codecrafters/run.sh +++ b/solutions/python/01-cq2/code/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec pipenv run python3 -m app.main "$@" +exec uv run --quiet -m app.main "$@" \ No newline at end of file diff --git a/solutions/python/01-cq2/code/.gitignore b/solutions/python/01-cq2/code/.gitignore index 06109db2..fe2425e1 100644 --- a/solutions/python/01-cq2/code/.gitignore +++ b/solutions/python/01-cq2/code/.gitignore @@ -94,6 +94,12 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more @@ -106,8 +112,10 @@ ipython_config.py #pdm.lock # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it # in version control. -# https://pdm.fming.dev/#use-with-ide +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control .pdm.toml +.pdm-python +.pdm-build/ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ @@ -151,3 +159,16 @@ dmypy.json # Cython debug symbols cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc \ No newline at end of file diff --git a/solutions/python/01-cq2/code/.python-version b/solutions/python/01-cq2/code/.python-version new file mode 100644 index 00000000..6324d401 --- /dev/null +++ b/solutions/python/01-cq2/code/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/solutions/python/01-cq2/code/Pipfile b/solutions/python/01-cq2/code/Pipfile deleted file mode 100644 index 68c079ed..00000000 --- a/solutions/python/01-cq2/code/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -pyparsing = "~=3.0" -lark = "~=1.1" - -[dev-packages] - -[requires] -python_version = "3" diff --git a/solutions/python/01-cq2/code/Pipfile.lock b/solutions/python/01-cq2/code/Pipfile.lock deleted file mode 100644 index 5274de2e..00000000 --- a/solutions/python/01-cq2/code/Pipfile.lock +++ /dev/null @@ -1,37 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "636ee93600ada7ba54b93ebb3484fcb8e306b2ca2ef6289c37dbbd3cc7b9c909" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "lark": { - "hashes": [ - "sha256:7a8d0c07d663da9391d7faee1bf1d7df4998c47ca43a593cbef5c7566acd057a", - "sha256:c1ab213fc5e2d273fe2d91da218ccc8b5b92d065b17faa5e743499cb16594b7d" - ], - "index": "pypi", - "version": "==1.1.2" - }, - "pyparsing": { - "hashes": [ - "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - ], - "index": "pypi", - "version": "==3.0.9" - } - }, - "develop": {} -} diff --git a/solutions/python/01-cq2/code/README.md b/solutions/python/01-cq2/code/README.md index 06a43d63..99eff0ff 100644 --- a/solutions/python/01-cq2/code/README.md +++ b/solutions/python/01-cq2/code/README.md @@ -31,7 +31,7 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `python (3.13)` installed locally +1. Ensure you have `uv` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in `app/main.py`. 1. Commit your changes and run `git push origin master` to submit your solution diff --git a/solutions/python/01-cq2/code/codecrafters.yml b/solutions/python/01-cq2/code/codecrafters.yml index bd98df7e..995338c9 100644 --- a/solutions/python/01-cq2/code/codecrafters.yml +++ b/solutions/python/01-cq2/code/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Python version used to run your code # on Codecrafters. # -# Available versions: python-3.13 -buildpack: python-3.13 +# Available versions: python-3.14 +buildpack: python-3.14 diff --git a/solutions/python/01-cq2/code/pyproject.toml b/solutions/python/01-cq2/code/pyproject.toml new file mode 100644 index 00000000..c0f8c448 --- /dev/null +++ b/solutions/python/01-cq2/code/pyproject.toml @@ -0,0 +1,5 @@ +[project] +name = "codecrafters-grep" +version = "0.1.0" +requires-python = ">=3.14" +dependencies = [] diff --git a/solutions/python/01-cq2/code/uv.lock b/solutions/python/01-cq2/code/uv.lock new file mode 100644 index 00000000..bc57bb57 --- /dev/null +++ b/solutions/python/01-cq2/code/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 3 +requires-python = ">=3.14" + +[[package]] +name = "codecrafters-grep" +version = "0.1.0" +source = { virtual = "." } diff --git a/solutions/python/01-cq2/code/your_program.sh b/solutions/python/01-cq2/code/your_program.sh index 0fa36a5a..6f090df9 100755 --- a/solutions/python/01-cq2/code/your_program.sh +++ b/solutions/python/01-cq2/code/your_program.sh @@ -12,4 +12,4 @@ set -e # Exit early if any commands fail # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec pipenv run python3 -m app.main "$@" +exec uv run --quiet -m app.main "$@" diff --git a/starter_templates/python/code/.codecrafters/run.sh b/starter_templates/python/code/.codecrafters/run.sh index 4b294809..b616c2ab 100755 --- a/starter_templates/python/code/.codecrafters/run.sh +++ b/starter_templates/python/code/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec pipenv run python3 -m app.main "$@" +exec uv run --quiet -m app.main "$@" \ No newline at end of file diff --git a/starter_templates/python/code/.gitignore b/starter_templates/python/code/.gitignore index 06109db2..fe2425e1 100644 --- a/starter_templates/python/code/.gitignore +++ b/starter_templates/python/code/.gitignore @@ -94,6 +94,12 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + # poetry # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. # This is especially recommended for binary packages to ensure reproducibility, and is more @@ -106,8 +112,10 @@ ipython_config.py #pdm.lock # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it # in version control. -# https://pdm.fming.dev/#use-with-ide +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control .pdm.toml +.pdm-python +.pdm-build/ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm __pypackages__/ @@ -151,3 +159,16 @@ dmypy.json # Cython debug symbols cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc \ No newline at end of file diff --git a/starter_templates/python/code/.python-version b/starter_templates/python/code/.python-version new file mode 100644 index 00000000..6324d401 --- /dev/null +++ b/starter_templates/python/code/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/starter_templates/python/code/Pipfile b/starter_templates/python/code/Pipfile deleted file mode 100644 index 68c079ed..00000000 --- a/starter_templates/python/code/Pipfile +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -pyparsing = "~=3.0" -lark = "~=1.1" - -[dev-packages] - -[requires] -python_version = "3" diff --git a/starter_templates/python/code/Pipfile.lock b/starter_templates/python/code/Pipfile.lock deleted file mode 100644 index 5274de2e..00000000 --- a/starter_templates/python/code/Pipfile.lock +++ /dev/null @@ -1,37 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "636ee93600ada7ba54b93ebb3484fcb8e306b2ca2ef6289c37dbbd3cc7b9c909" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "lark": { - "hashes": [ - "sha256:7a8d0c07d663da9391d7faee1bf1d7df4998c47ca43a593cbef5c7566acd057a", - "sha256:c1ab213fc5e2d273fe2d91da218ccc8b5b92d065b17faa5e743499cb16594b7d" - ], - "index": "pypi", - "version": "==1.1.2" - }, - "pyparsing": { - "hashes": [ - "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - ], - "index": "pypi", - "version": "==3.0.9" - } - }, - "develop": {} -} diff --git a/starter_templates/python/code/pyproject.toml b/starter_templates/python/code/pyproject.toml new file mode 100644 index 00000000..c0f8c448 --- /dev/null +++ b/starter_templates/python/code/pyproject.toml @@ -0,0 +1,5 @@ +[project] +name = "codecrafters-grep" +version = "0.1.0" +requires-python = ">=3.14" +dependencies = [] diff --git a/starter_templates/python/code/uv.lock b/starter_templates/python/code/uv.lock new file mode 100644 index 00000000..bc57bb57 --- /dev/null +++ b/starter_templates/python/code/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 3 +requires-python = ">=3.14" + +[[package]] +name = "codecrafters-grep" +version = "0.1.0" +source = { virtual = "." } diff --git a/starter_templates/python/config.yml b/starter_templates/python/config.yml index 22a03709..08c1bd5f 100644 --- a/starter_templates/python/config.yml +++ b/starter_templates/python/config.yml @@ -1,3 +1,3 @@ attributes: - required_executable: python (3.13) - user_editable_file: app/main.py + required_executable: "uv" + user_editable_file: "app/main.py"