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

Resolve "Why is poetry.lock mandatory?"

parent 6548ed80
No related branches found
No related tags found
No related merge requests found
......@@ -35,12 +35,14 @@ Default configuration follows [this Python project structure](https://docs.pytho
The Python template supports [Poetry](https://python-poetry.org/) as packaging and dependency management tool.
If a `pyproject.toml` and `poetry.lock` file is detected at the root of your project structure, requirements will automatically be generated from Poetry.
Poetry support is disabled if `PYTHON_POETRY_DISABLED` is set to `true`.
If a `pyproject.toml` file is detected at the root of your Python project, requirements will automatically be generated from Poetry.
Poetry support can be explicitly disabled by setting `PYTHON_POETRY_DISABLED` to `true`.
:warning: as stated in [Poetry documentation](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control), _You should commit the `poetry.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies_.
:warning: If no `poetry.lock` file is found, the template will emit a (non-blocking) warning message, to enforce [Poetry recommendation](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control):
It uses the following variables:
> You should commit the `poetry.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies.
Poetry support uses the following variables:
| Name | description | default value |
| ------------------------ | ---------------------------------------------------------- | ----------------- |
......
......@@ -69,10 +69,6 @@ variables:
fi
}
function install_ca_certs() {
certs=$1
if [[ -z "$certs" ]]
......@@ -213,9 +209,8 @@ variables:
function install_requirements() {
target=$1
if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if [[ ! -f "poetry.lock" ]]; then
log_error "Poetry detected but \\e[33;1mpoetry.lock\\e[0m file not found: you shall commit it with your project files"
exit 1
if [[ ! -f "poetry.lock" ]]; then
log_warn "Poetry detected but \\e[33;1mpoetry.lock\\e[0m file not found: you shall commit it with your project files"
fi
pip install -U poetry
if [[ "$target" == "build" ]]; then
......@@ -244,7 +239,7 @@ variables:
}
function _run() {
if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if ! command -v poetry > /dev/null
then
pip install -U poetry
......@@ -264,15 +259,16 @@ variables:
}
function _package(){
if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
pip install -U poetry
poetry build
else
python setup.py sdist bdist_wheel
fi
}
function _publish() {
if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
pip install -U poetry
poetry config repositories.user_defined "$TWINE_REPOSITORY_URL"
poetry publish --username "$TWINE_USERNAME" --password "$TWINE_PASSWORD" --repository user_defined
......@@ -286,7 +282,7 @@ variables:
}
function _release() {
if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then
pip install -U poetry
poetry version "${RELEASE_VERSION_PART}"
else
......@@ -381,12 +377,10 @@ py-lint:
if ! _run pylint --ignore=.cache --output-format=text ${PYLINT_ARGS} ${PYLINT_FILES:-$(find -type f -name "*.py")}
then
# failed: also generate codeclimate report
_run pylint --ignore=.cache --output-format=pylint_gitlab.GitlabCodeClimateReporter ${PYLINT_ARGS} ${PYLINT_FILES:-$(find -type f -name "*.py")} > reports/pylint-codeclimate.json
exit 1
else
# success: generate empty codeclimate report (required by GitLab :( )
echo "[]" > reports/pylint-codeclimate.json
fi
artifacts:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment