diff --git a/.github/workflows/codeflash-optimize.yaml b/.github/workflows/codeflash-optimize.yaml index d04b1e884..9776394dd 100644 --- a/.github/workflows/codeflash-optimize.yaml +++ b/.github/workflows/codeflash-optimize.yaml @@ -42,5 +42,4 @@ jobs: - name: ⚡️Codeflash Optimization id: optimize_code run: | - source .venv/bin/activate - poetry run codeflash \ No newline at end of file + uv run codeflash \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml b/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml index 793c07860..2d93df41b 100644 --- a/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml +++ b/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml @@ -22,18 +22,6 @@ jobs: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python 3.11 for CLI - uses: astral-sh/setup-uv@v5 - with: - python-version: 3.11.6 - - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Remove .git run: | if [ -d ".git" ]; then @@ -49,9 +37,12 @@ jobs: echo ".git directory does not exist. Nothing to remove." exit 1 fi + - name: Set up uv Python 3.11 for CLI + uses: astral-sh/setup-uv@v5 + with: + python-version: 3.11.6 - name: Run Codeflash to optimize code id: optimize_code run: | - source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_bubblesort_pytest.py + uv run -p 3.11 python tests/scripts/end_to_end_test_bubblesort_pytest.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-bubblesort-unittest.yaml b/.github/workflows/end-to-end-test-bubblesort-unittest.yaml index 9fcf04f7d..1ac5c4740 100644 --- a/.github/workflows/end-to-end-test-bubblesort-unittest.yaml +++ b/.github/workflows/end-to-end-test-bubblesort-unittest.yaml @@ -22,20 +22,12 @@ jobs: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python 3.11 for CLI + - name: Set up uv Python 3.11 for CLI uses: astral-sh/setup-uv@v5 with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Run Codeflash to optimize code id: optimize_code run: | - source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_bubblesort_unittest.py \ No newline at end of file + uv run -p 3.11 python tests/scripts/end_to_end_test_bubblesort_unittest.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-coverage.yaml b/.github/workflows/end-to-end-test-coverage.yaml index 91a3faf2d..335143a7f 100644 --- a/.github/workflows/end-to-end-test-coverage.yaml +++ b/.github/workflows/end-to-end-test-coverage.yaml @@ -25,16 +25,7 @@ jobs: with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - poetry add black # my-best-repo in end_to_end_test_coverage.py is configured to use black - - name: Run Codeflash to optimize code id: optimize_code run: | - source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_coverage.py \ No newline at end of file + uv run --with black -p 3.11 python tests/scripts/end_to_end_test_coverage.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-futurehouse.yaml b/.github/workflows/end-to-end-test-futurehouse.yaml index f0c3ae409..5f492a023 100644 --- a/.github/workflows/end-to-end-test-futurehouse.yaml +++ b/.github/workflows/end-to-end-test-futurehouse.yaml @@ -27,15 +27,8 @@ jobs: with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Run Codeflash to optimize code id: optimize_code run: | source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_futurehouse.py \ No newline at end of file + uv run -p 3.11 python tests/scripts/end_to_end_test_futurehouse.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-init-optim.yaml b/.github/workflows/end-to-end-test-init-optim.yaml index 5d6bded10..04d06ed5c 100644 --- a/.github/workflows/end-to-end-test-init-optim.yaml +++ b/.github/workflows/end-to-end-test-init-optim.yaml @@ -27,15 +27,8 @@ jobs: with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Run Codeflash to optimize code id: optimize_code run: | source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_init_optimization.py \ No newline at end of file + uv run -p 3.11 python tests/scripts/end_to_end_test_init_optimization.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-test-tracer-replay.yaml b/.github/workflows/end-to-end-test-tracer-replay.yaml index 2902575b1..9a8e3502f 100644 --- a/.github/workflows/end-to-end-test-tracer-replay.yaml +++ b/.github/workflows/end-to-end-test-tracer-replay.yaml @@ -27,15 +27,7 @@ jobs: with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Run Codeflash to optimize code id: optimize_code run: | - source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_tracer_replay.py \ No newline at end of file + uv run -p 3.11 python tests/scripts/end_to_end_test_tracer_replay.py \ No newline at end of file diff --git a/.github/workflows/end-to-end-topological-sort-test.yaml b/.github/workflows/end-to-end-topological-sort-test.yaml index 76d28b858..7a231db15 100644 --- a/.github/workflows/end-to-end-topological-sort-test.yaml +++ b/.github/workflows/end-to-end-topological-sort-test.yaml @@ -27,15 +27,7 @@ jobs: with: python-version: 3.11.6 - - name: Install dependencies (CLI) - run: | - uv tool install poetry - uv venv - source .venv/bin/activate - poetry install --with dev - - name: Run Codeflash to optimize code id: optimize_code run: | - source .venv/bin/activate - poetry run python tests/scripts/end_to_end_test_topological_sort.py \ No newline at end of file + uv run -p 3.11 python tests/scripts/end_to_end_test_topological_sort.py \ No newline at end of file diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 83b85d86c..4bf5ebe5e 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -18,14 +18,6 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v5 - with: - version: "0.5.30" - - - name: install poetry as a tool - run: uv tool install poetry - - - name: install dependencies - run: uvx poetry install --with dev - name: Run mypy on allowlist - run: uvx poetry run mypy --non-interactive --config-file pyproject.toml @mypy_allowlist.txt + run: uv run --all-groups mypy --non-interactive --config-file pyproject.toml @mypy_allowlist.txt diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index a1e7da8ea..3d6ff68ca 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -24,15 +24,9 @@ jobs: uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - version: "0.5.30" - - name: install poetry as a tool - run: uv tool install poetry - - - name: install dependencies - run: uvx poetry install --with dev - name: Unit tests - run: uvx poetry run pytest tests/ --cov --cov-report=xml + run: uv run pytest tests/ --cov --cov-report=xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 diff --git a/codeflash/version.py b/codeflash/version.py index 075de2843..f606c63ad 100644 --- a/codeflash/version.py +++ b/codeflash/version.py @@ -1,3 +1,3 @@ -# These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`. +# These version placeholders will be replaced by hatch-vcs during build. __version__ = "0.10.3" __version_tuple__ = (0, 10, 3) diff --git a/pyproject.toml b/pyproject.toml index a181fac2e..282f70dc6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,10 @@ -[tool] -[tool.poetry] +[project] name = "codeflash" -version = "0.0.0" # Determined by poetry-dynamic-versioning during `poetry build` description = "Client for codeflash.ai - automatic code performance optimization, powered by AI" -license = "BSL-1.1" -authors = ["CodeFlash Inc. "] -homepage = "https://codeflash.ai" +authors = [{ name = "CodeFlash Inc.", email = "contact@codeflash.ai" }] +requires-python = ">=3.9" readme = "README.md" -packages = [{ include = "codeflash", format = ["sdist"] }] +license = "BUSL-1.1 " keywords = [ "codeflash", "performance", @@ -17,6 +14,64 @@ keywords = [ "machine learning", "LLM", ] +dependencies = [ + "unidiff>=0.7.4", + "pytest>=7.0.0,<8.3.4", + "gitpython>=3.1.31", + "libcst>=1.0.1", + "jedi>=0.19.1", + "tiktoken>=0.3.2", + "timeout-decorator>=0.5.0", + "pytest-timeout>=2.1.0", + "tomlkit>=0.11.7", + "unittest-xml-reporting>=3.2.0", + "junitparser>=3.1.0", + "pydantic>=1.10.1", + "humanize>=4.0.0", + "posthog>=3.0.0,<=3.11.0", + "click>=8.1.0", + "inquirer>=3.0.0", + "sentry-sdk>=1.40.6,<3.0.0", + "parameterized>=0.9.0", + "isort>=5.11.0", + "dill>=0.3.8", + "rich>=13.8.1", + "lxml>=5.3.0", + "crosshair-tool>=0.0.78", + "coverage>=7.6.4", +] +urls = { "Homepage" = "https://codeflash.ai" } +scripts = { codeflash = "codeflash.main:main" } + +dynamic = ["version"] # Determined by uv-dynamic-versioning during `uv build` + +[dependency-groups] +dev = [ + "ipython>=8.12.0", + "mypy>=1.13", + "ruff>=0.7.0", + "lxml-stubs>=0.5.1", + "pandas-stubs>=2.2.2.240807, <2.2.3.241009", + "types-Pygments>=2.18.0.20240506", + "types-colorama>=0.4.15.20240311", + "types-decorator>=5.1.8.20240310", + "types-jsonschema>=4.23.0.20240813", + "types-requests>=2.32.0.20241016", + "types-six>=1.16.21.20241009", + "types-cffi>=1.16.0.20240331", + "types-openpyxl>=3.1.5.20241020", + "types-regex>=2024.9.11.20240912", + "types-python-dateutil>=2.9.0.20241003", + "pytest-cov>=6.0.0,<7", + "types-gevent>=24.11.0.20241230,<25", + "types-greenlet>=3.1.0.20241221,<4", + "types-pexpect>=4.9.0.20241208,<5", + "types-unidiff>=0.7.0.20240505,<0.8", + "uv>=0.6.2", +] + +[tool.hatch.build] +include = ["codeflash"] exclude = [ "docs/*", "experiments/*", @@ -65,69 +120,6 @@ exclude = [ "env", ] -# Versions here the minimum required versions for the project. These should be as loose as possible. -[tool.poetry.dependencies] -python = ">=3.9" -unidiff = ">=0.7.4" -pytest = ">=7.0.0,<8.3.4" -gitpython = ">=3.1.31" -libcst = ">=1.0.1" -jedi = ">=0.19.1" -tiktoken = ">=0.3.2" -timeout-decorator = ">=0.5.0" -pytest-timeout = ">=2.1.0" -tomlkit = ">=0.11.7" -unittest-xml-reporting = ">=3.2.0" -junitparser = ">=3.1.0" -pydantic = ">=1.10.1" -humanize = ">=4.0.0" -posthog = ">=3.0.0,<=3.11.0" -click = ">=8.1.0" -inquirer = ">=3.0.0" -sentry-sdk = ">=1.40.6,<3.0.0" -parameterized = ">=0.9.0" -isort = ">=5.11.0" -dill = ">=0.3.8" -rich = ">=13.8.1" -lxml = ">=5.3.0" -crosshair-tool = ">=0.0.78" -coverage = ">=7.6.4" -line_profiler=">=4.2.0" #this is the minimum version which supports python 3.13 -[tool.poetry.group.dev] -optional = true - -# Don't forget to install the poetry plugins we use too: -# poetry self add poetry-dynamic-versioning - -[tool.poetry.group.dev.dependencies] -ipython = ">=8.12.0" -mypy = ">=1.13" -ruff = ">=0.7.0" -lxml-stubs = ">=0.5.1" -pandas-stubs = ">=2.2.2.240807, <2.2.3.241009" -types-Pygments = ">=2.18.0.20240506" -types-colorama = ">=0.4.15.20240311" -types-decorator = ">=5.1.8.20240310" -types-jsonschema = ">=4.23.0.20240813" -types-requests = ">=2.32.0.20241016" -types-six = ">=1.16.21.20241009" -types-cffi = ">=1.16.0.20240331" -types-openpyxl = ">=3.1.5.20241020" -types-regex = ">=2024.9.11.20240912" -types-python-dateutil = ">=2.9.0.20241003" -pytest-cov = "^6.0.0" -types-gevent = "^24.11.0.20241230" -types-greenlet = "^3.1.0.20241221" -types-pexpect = "^4.9.0.20241208" -types-unidiff = "^0.7.0.20240505" -uv = ">=0.6.2" - -[tool.poetry.build] -script = "codeflash/update_license_version.py" - -[tool.poetry.scripts] -codeflash = "codeflash.main:main" - [tool.mypy] show_error_code_links = true pretty = true @@ -199,22 +191,6 @@ split-on-trailing-comma = false docstring-code-format = true skip-magic-trailing-comma = true -[tool.poetry-dynamic-versioning] -enable = true -style = "pep440" -vcs = "git" - -[tool.poetry-dynamic-versioning.substitution] -files = ["codeflash/version.py"] - -[tool.poetry-dynamic-versioning.files."codeflash/version.py"] -persistent-substitution = true -initial-content = """ - # These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`. - __version__ = "0.0.0" - __version_tuple__ = (0, 0, 0) -""" - [tool.codeflash] module-root = "codeflash" @@ -225,7 +201,14 @@ formatter-cmds = [ "uvx ruff format $file", ] +[tool.hatch.build.hooks.vcs] +version-file = "codeflash/version.py" + +[tool.hatch.version] +source = "vcs" +tag-pattern = "(?:^|^v|^release/)(?P[0-9]+\\.[0-9]+\\.[0-9]+)$" + [build-system] -requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.2.0,<2.0.0"] -build-backend = "poetry_dynamic_versioning.backend" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build"