Skip to content

Commit

Permalink
Support Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Oct 9, 2023
1 parent 0003dc8 commit 052e3db
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 239 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-hatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
- hatch-v*
branches:
- master
pull_request:
branches:
- master
# pull_request:
# branches:
# - master

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand Down
278 changes: 140 additions & 138 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
# os: [ubuntu-latest, windows-latest, macos-latest]
# python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest]
python-version: ['3.12']

steps:
- uses: actions/checkout@v4
Expand All @@ -43,142 +45,142 @@ jobs:
pip install -e .
pip install -e ./backend
- if: ${{ !startsWith(matrix.python-version, 'pypy') }}
name: Lint
run: hatch run lint:all
# - if: ${{ !startsWith(matrix.python-version, 'pypy') }}
# name: Lint
# run: hatch run lint:all

- name: Run tests
run: hatch run full
run: hatch run dev tests/cli/new/test_new.py::test_initialize_setup_cfg_only

# - name: Disambiguate coverage filename
# run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"

# - name: Upload coverage data
# uses: actions/upload-artifact@v3
# with:
# name: coverage-data
# path: .coverage.*

- name: Disambiguate coverage filename
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"

- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*

coverage:
name: Report coverage
runs-on: ubuntu-latest
needs:
- run

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}

- name: Install Hatch
run: pip install hatch

- name: Trigger build for auto-generated files
run: hatch build --hooks-only

- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage data
run: hatch run coverage:combine

- name: Export coverage reports
run: |
hatch run coverage:report-xml
hatch run coverage:report-uncovered-html
- name: Upload uncovered HTML report
uses: actions/upload-artifact@v3
with:
name: uncovered-html-report
path: htmlcov

- name: Generate coverage summary
run: hatch run coverage:generate-summary

- name: Write coverage summary report
if: github.event_name == 'pull_request'
run: hatch run coverage:write-summary-report

- name: Update coverage pull request comment
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
uses: marocchino/sticky-pull-request-comment@v2
with:
path: coverage-report.md

downstream:
name: Downstream builds with Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install tools
run: pip install --upgrade -r backend/tests/downstream/requirements.txt

- name: Build downstream projects
run: python backend/tests/downstream/integrate.py

response-time:
name: CLI responsiveness with latest Python
runs-on: ubuntu-latest

env:
HYPERFINE_VERSION: '1.12.0'

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}

- name: Install hyperfine
run: |
wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb
sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb
- name: Install other tools
run: pip install --upgrade flit poetry pipenv

- name: Install ourself
run: pip install .

- name: Benchmark
run: |
hyperfine -m 100 --warmup 10 -i pipenv
hyperfine -m 100 --warmup 10 poetry
hyperfine -m 100 --warmup 10 -i flit
hyperfine -m 100 --warmup 10 hatch
# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection
if: always()

needs:
- coverage
- downstream
- response-time

runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
# coverage:
# name: Report coverage
# runs-on: ubuntu-latest
# needs:
# - run

# steps:
# - uses: actions/checkout@v4

# - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.STABLE_PYTHON_VERSION }}

# - name: Install Hatch
# run: pip install hatch

# - name: Trigger build for auto-generated files
# run: hatch build --hooks-only

# - name: Download coverage data
# uses: actions/download-artifact@v3
# with:
# name: coverage-data

# - name: Combine coverage data
# run: hatch run coverage:combine

# - name: Export coverage reports
# run: |
# hatch run coverage:report-xml
# hatch run coverage:report-uncovered-html

# - name: Upload uncovered HTML report
# uses: actions/upload-artifact@v3
# with:
# name: uncovered-html-report
# path: htmlcov

# - name: Generate coverage summary
# run: hatch run coverage:generate-summary

# - name: Write coverage summary report
# if: github.event_name == 'pull_request'
# run: hatch run coverage:write-summary-report

# - name: Update coverage pull request comment
# if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork
# uses: marocchino/sticky-pull-request-comment@v2
# with:
# path: coverage-report.md

# downstream:
# name: Downstream builds with Python ${{ matrix.python-version }}
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python-version: ['3.8', '3.9', '3.10', '3.11']

# steps:
# - uses: actions/checkout@v4

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}

# - name: Install tools
# run: pip install --upgrade -r backend/tests/downstream/requirements.txt

# - name: Build downstream projects
# run: python backend/tests/downstream/integrate.py

# response-time:
# name: CLI responsiveness with latest Python
# runs-on: ubuntu-latest

# env:
# HYPERFINE_VERSION: '1.12.0'

# steps:
# - uses: actions/checkout@v4

# - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.STABLE_PYTHON_VERSION }}

# - name: Install hyperfine
# run: |
# wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb
# sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb

# - name: Install other tools
# run: pip install --upgrade flit poetry pipenv

# - name: Install ourself
# run: pip install .

# - name: Benchmark
# run: |
# hyperfine -m 100 --warmup 10 -i pipenv
# hyperfine -m 100 --warmup 10 poetry
# hyperfine -m 100 --warmup 10 -i flit
# hyperfine -m 100 --warmup 10 hatch

# # https://github.com/marketplace/actions/alls-green#why
# check: # This job does nothing and is only used for the branch protection
# if: always()

# needs:
# - coverage
# - downstream
# - response-time

# runs-on: ubuntu-latest

# steps:
# - name: Decide whether the needed jobs succeeded or failed
# uses: re-actors/alls-green@release/v1
# with:
# jobs: ${{ toJSON(needs) }}
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Build Tools",
Expand Down
1 change: 1 addition & 0 deletions docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Add standalone binaries
- Add the ability to manage Python installations
- Support Python 3.12
- Bump the minimum supported version of Hatchling to 1.17.1
- Bump the minimum supported version of `click` to 8.0.6

Expand Down
4 changes: 4 additions & 0 deletions docs/history/hatchling.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

***Added:***

- Officially support Python 3.12

***Fixed:***

- Fix parsing dependencies for environments when warnings are emitted
Expand Down
4 changes: 2 additions & 2 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env.GITHUB_ACTIONS.env-vars = "COVERAGE_REPORT="
[envs.default.scripts]
# --cov must not come before an argument in order to use the sources defined by config
_cov = "pytest --cov --cov-report={env:COVERAGE_REPORT:term-missing} --cov-config=pyproject.toml"
dev = "pytest -p no:randomly --no-cov {args:tests}"
dev = "pytest -vv -p no:randomly --no-cov {args:tests}"
cov = "_cov -p no:randomly {args:tests}"
full = "_cov -n auto --reruns 5 --reruns-delay 3 -r aR {args:tests}"

Expand All @@ -29,7 +29,7 @@ env.HERMETIC_TESTS.type = [
]

[[envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11"]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[envs.coverage]
detached = true
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Build Tools",
Expand Down
9 changes: 7 additions & 2 deletions src/hatch/cli/new/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@click.pass_obj
def new(app, name, location, interactive, feature_cli, initialize, setuptools_options):
"""Create or initialize a project."""
import sys
from copy import deepcopy
from datetime import datetime, timezone

Expand Down Expand Up @@ -52,10 +53,14 @@ def new(app, name, location, interactive, feature_cli, initialize, setuptools_op

if migration_possible:
from hatch.cli.new.migrate import migrate
from hatch.venv.core import TempVirtualEnv

try:
with app.status('Migrating project metadata from setuptools'):
migrate(str(location), setuptools_options)
with app.status('Migrating project metadata from setuptools'), TempVirtualEnv(
sys.executable, app.platform
) as venv:
app.platform.run_command(['python', '-m', 'pip', 'install', '-q', 'setuptools'])
migrate(str(location), setuptools_options, venv.sys_path)
except Exception as e:
app.display_error(f'Could not automatically migrate from setuptools: {e}')
if name == 'temporary':
Expand Down
Loading

0 comments on commit 052e3db

Please sign in to comment.