diff --git a/README.md b/README.md index 7c2b877419627dad217ac35bb64d6a6f5de2c39c..b8bba4ba93759cbd28922e4854b934f3a7ae0496 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,13 @@ This job allows building your Python project [distribution packages](https://pac It is bound to the `build` stage, it is **disabled by default** and can be enabled by setting `$PYTHON_PACKAGE_ENABLED` to `true`. +#### UV tip + +Currently, UV supports the following underlying build systems: + +- [hatchling](https://pypi.org/project/hatchling/) (this is the default setting when creating a new project with UV), so you may use the same build configuration as [Hatch](https://hatch.pypa.io/latest/build/). The recommended file layout is [`src-layout`](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/) to simplify [finding the source](https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection) otherwise configure [Hatch build config](https://hatch.pypa.io/latest/config/build/). +- or [setuptools](https://pypi.org/project/setuptools/) (this is the default if nothing is defined in your `pyproject.toml`). In this case, the recommended file layout is also [`src-layout`](https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/), otherwise configure [`package_discovery`](https://setuptools.pypa.io/en/latest/userguide/package_discovery.html). + ### Lint jobs #### `py-lint` job @@ -478,6 +485,7 @@ The publish job is bound to the `publish` stage, is executed on a Git tag matchi | `PYTHON_REPOSITORY_USERNAME`| Target PyPI repository username credential | `gitlab-ci-token` | | :lock: `PYTHON_REPOSITORY_PASSWORD`| Target PyPI repository password credential | `$CI_JOB_TOKEN` | +For information on building recommandations look (`py-package`)[/README.md#py-package-job] #### Setuptools tip diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index ba90622a888b5529f8dd1bc9e6cde89b8516b6c7..f31232a9278df0c79e7fb462056bb1d568577a9d 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -802,6 +802,9 @@ variables: function py_package() { _start_time=$(get_current_ts_ms) + # clean reports for this job but there not impact on other jobs + rm -fr "$PYTHON_PROJECT_DIR/reports" + if [[ "$PYTHON_BUILD_SYSTEM" =~ ^poetry ]] then maybe_install_build_system @@ -996,7 +999,7 @@ variables: } function py_publish() { - if [[ "$PYTHON_BUILD_SYSTEM" =~ ^hatch ]] && [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]] + if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]] then py_package fi @@ -1005,12 +1008,6 @@ variables: then maybe_install_build_system - if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]] - then - log_info "--- build packages (poetry)..." - poetry build ${TRACE+--verbose} - fi - log_info "--- publish packages (poetry) to $PYTHON_REPOSITORY_URL with user $PYTHON_REPOSITORY_USERNAME..." poetry config repositories.user_defined "$PYTHON_REPOSITORY_URL" poetry publish ${TRACE+--verbose} --username "$PYTHON_REPOSITORY_USERNAME" --password "$PYTHON_REPOSITORY_PASSWORD" --repository user_defined @@ -1018,30 +1015,18 @@ variables: then maybe_install_build_system - if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]] - then - log_info "--- build packages (uv)..." - uv build ${TRACE+--verbose} - fi - log_info "--- publish packages (uv) to $PYTHON_REPOSITORY_URL with user $PYTHON_REPOSITORY_USERNAME..." uv publish ${TRACE+--verbose} --username "$PYTHON_REPOSITORY_USERNAME" --password "$PYTHON_REPOSITORY_PASSWORD" --publish-url "$PYTHON_REPOSITORY_URL" elif [[ "$PYTHON_BUILD_SYSTEM" =~ ^hatch ]] then maybe_install_build_system + log_info "--- publish packages (hatch) to $PYTHON_REPOSITORY_URL with user $PYTHON_REPOSITORY_USERNAME..." hatch publish ${TRACE+--verbose} --no-prompt --yes --user "$PYTHON_REPOSITORY_USERNAME" --auth "$PYTHON_REPOSITORY_PASSWORD" --repo "$PYTHON_REPOSITORY_URL" else # shellcheck disable=SC2086 pip install ${PIP_OPTS} build twine - if [[ "$PYTHON_PACKAGE_ENABLED" != "true" ]] - then - log_info "--- build packages (build)..." - rm -rf dist - python -m build - fi - log_info "--- publish packages (twine) to $PYTHON_REPOSITORY_URL with user $PYTHON_REPOSITORY_USERNAME..." twine upload ${TRACE+--verbose} --username "$PYTHON_REPOSITORY_USERNAME" --password "$PYTHON_REPOSITORY_PASSWORD" --repository-url "$PYTHON_REPOSITORY_URL" dist/* fi