Skip to content
Snippets Groups Projects
Commit 37bd52e0 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'fix/uv_build' into 'master'

fix: py-package remove reports dir #98

Closes #98

See merge request to-be-continuous/python!152
parents 0d4c0421 300d31f5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment