You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2020/12/04 16:43:32 UTC
[airflow] branch master updated: Get airflow version from
importlib.metadata rather than hard-coding (#12786)
This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 2936c13 Get airflow version from importlib.metadata rather than hard-coding (#12786)
2936c13 is described below
commit 2936c13a44369daae9d6099cd1070b3a8cd53443
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Fri Dec 4 16:42:25 2020 +0000
Get airflow version from importlib.metadata rather than hard-coding (#12786)
One less thing to change, and one less pre-commit step needed :)
---
.pre-commit-config.yaml | 5 ----
Dockerfile.ci | 1 -
STATIC_CODE_CHECKS.rst | 2 --
airflow/version.py | 11 +++++++-
dev/README.md | 2 --
dev/README_RELEASE_AIRFLOW.md | 6 ++---
.../enter_breeze_provider_package_tests.sh | 1 -
scripts/ci/libraries/_initialization.sh | 5 ++--
scripts/ci/libraries/_md5sum.sh | 1 -
scripts/ci/pre_commit/pre_commit_sync_version.sh | 29 ----------------------
.../ci_install_and_test_provider_packages.sh | 1 -
setup.py | 1 -
12 files changed, 15 insertions(+), 50 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4b283aa..6e19e1c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -440,11 +440,6 @@ repos:
files: ^airflow/www/.*\.(css|scss|sass)$
# Keep dependency versions in sync w/ airflow/www/package.json
additional_dependencies: ['stylelint@13.3.1', 'stylelint-config-standard@20.0.0']
- - id: version-sync
- name: Version sync
- files: ^airflow/version.py$|setup.py
- entry: ./scripts/ci/pre_commit/pre_commit_sync_version.sh
- language: system
- id: providers-init-file
name: Provider init file
pass_filenames: false
diff --git a/Dockerfile.ci b/Dockerfile.ci
index 7cf8f9d..575a9d9 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -306,7 +306,6 @@ RUN yarn --cwd airflow/www install --frozen-lockfile --no-cache
COPY setup.py ${AIRFLOW_SOURCES}/setup.py
COPY setup.cfg ${AIRFLOW_SOURCES}/setup.cfg
-COPY airflow/version.py ${AIRFLOW_SOURCES}/airflow/version.py
COPY airflow/__init__.py ${AIRFLOW_SOURCES}/airflow/__init__.py
ARG UPGRADE_TO_LATEST_CONSTRAINTS="false"
diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst
index b42975f..67cbce6 100644
--- a/STATIC_CODE_CHECKS.rst
+++ b/STATIC_CODE_CHECKS.rst
@@ -174,8 +174,6 @@ require Breeze Docker images to be installed locally:
----------------------------------- ---------------------------------------------------------------- ------------
``update-extras`` Updates extras in the documentation.
----------------------------------- ---------------------------------------------------------------- ------------
-``version-sync`` Synchronizes versions setup.py <-> airflow/version.py.
------------------------------------ ---------------------------------------------------------------- ------------
``yamllint`` Checks yaml files with yamllint.
=================================== ================================================================ ============
diff --git a/airflow/version.py b/airflow/version.py
index d8a0feb..6260ff9 100644
--- a/airflow/version.py
+++ b/airflow/version.py
@@ -17,4 +17,13 @@
# under the License.
#
-version = '2.0.0b3'
+__all__ = ['version']
+
+try:
+ from importlib import metadata
+except ImportError:
+ import importlib_metadata as metadata
+
+version = metadata.version('apache-airflow')
+
+del metadata
diff --git a/dev/README.md b/dev/README.md
index 3ae58c9..d969c1e 100644
--- a/dev/README.md
+++ b/dev/README.md
@@ -200,8 +200,6 @@ pip install twine
- Set proper permissions for the pypirc file:
`$ chmod 600 ~/.pypirc`
-- Confirm that `airflow/version.py` is set properly.
-
## Hardware used to prepare and verify the packages
diff --git a/dev/README_RELEASE_AIRFLOW.md b/dev/README_RELEASE_AIRFLOW.md
index 49f0117..2ebf9a3 100644
--- a/dev/README_RELEASE_AIRFLOW.md
+++ b/dev/README_RELEASE_AIRFLOW.md
@@ -65,7 +65,7 @@ The Release Candidate artifacts we vote upon should be the exact ones we vote ag
export AIRFLOW_REPO_ROOT=$(pwd)
```
-- Set your version to 1.10.2 in `airflow/version.py` (without the RC tag)
+- Set your version to 1.10.2 in `setup.py` (without the RC tag)
- Commit the version change.
- Tag your release
@@ -147,7 +147,7 @@ svn commit -m "Add artifacts for Airflow ${VERSION}"
At this point we have the artefact that we vote on, but as a convenience to developers we also want to
publish "snapshots" of the RC builds to pypi for installing via pip. To do this we need to
-- Edit the `airflow/version.py` to include the RC suffix.
+- Edit the `setup.py` to include the RC suffix.
- Build the package:
@@ -176,7 +176,7 @@ https://test.pypi.org/project/apache-airflow/#files
- Again, confirm that the package is available here:
https://pypi.python.org/pypi/apache-airflow
-- Throw away the change - we don't want to commit this: `git checkout airflow/version.py`
+- Throw away the change - we don't want to commit this: `git checkout setup.py`
It is important to stress that this snapshot should not be named "release", and it
is not supposed to be used by and advertised to the end-users who do not read the devlist.
diff --git a/dev/provider_packages/enter_breeze_provider_package_tests.sh b/dev/provider_packages/enter_breeze_provider_package_tests.sh
index 1ec7b51..d3e8f1a 100755
--- a/dev/provider_packages/enter_breeze_provider_package_tests.sh
+++ b/dev/provider_packages/enter_breeze_provider_package_tests.sh
@@ -26,7 +26,6 @@ function enter_breeze_with_mapped_sources() {
-v "${AIRFLOW_SOURCES}/setup.py:/airflow_sources/setup.py:cached" \
-v "${AIRFLOW_SOURCES}/setup.cfg:/airflow_sources/setup.cfg:cached" \
-v "${AIRFLOW_SOURCES}/airflow/__init__.py:/airflow_sources/airflow/__init__.py:cached" \
- -v "${AIRFLOW_SOURCES}/airflow/version.py:/airflow_sources/airflow/version.py:cached" \
-v "${AIRFLOW_SOURCES}/empty:/opt/airflow/airflow:cached" \
-v "${AIRFLOW_SOURCES}/scripts/in_container:/opt/airflow/scripts/in_container:cached" \
-v "${AIRFLOW_SOURCES}/dev/import_all_classes.py:/opt/airflow/dev/import_all_classes.py:cached" \
diff --git a/scripts/ci/libraries/_initialization.sh b/scripts/ci/libraries/_initialization.sh
index 7658411..b74e06e 100644
--- a/scripts/ci/libraries/_initialization.sh
+++ b/scripts/ci/libraries/_initialization.sh
@@ -134,8 +134,8 @@ function initialization::initialize_base_variables() {
# otherwise it will use files/airflow-breeze-config/init.sh
export INIT_SCRIPT_FILE=${INIT_SCRIPT_FILE:=""}
- # Read airflow version from the version.py
- AIRFLOW_VERSION=$(grep version "${AIRFLOW_SOURCES}/airflow/version.py" | awk '{print $3}' | sed "s/['+]//g")
+ # Read airflow version from the setup.py.
+ AIRFLOW_VERSION=$(awk '/^version =/ {print $3}' "${AIRFLOW_SOURCES}/setup.py" | sed "s/['+]//g")
export AIRFLOW_VERSION
# Whether credentials should be forwarded to inside the docker container
@@ -194,7 +194,6 @@ function initialization::initialize_files_for_rebuild_check() {
"setup.cfg"
"Dockerfile.ci"
".dockerignore"
- "airflow/version.py"
"airflow/www/package.json"
"airflow/www/yarn.lock"
"airflow/www/webpack.config.js"
diff --git a/scripts/ci/libraries/_md5sum.sh b/scripts/ci/libraries/_md5sum.sh
index 2ccbff8..4bd309a 100644
--- a/scripts/ci/libraries/_md5sum.sh
+++ b/scripts/ci/libraries/_md5sum.sh
@@ -102,7 +102,6 @@ function md5sum::calculate_md5sum_for_all_files() {
# * setup.py
# * setup.cfg
# * Dockerfile.ci
-# * airflow/version.py
#
# This is needed because we want to skip rebuilding of the image when only airflow sources change but
# Trigger rebuild in case we need to change dependencies (setup.py, setup.cfg, change version of Airflow
diff --git a/scripts/ci/pre_commit/pre_commit_sync_version.sh b/scripts/ci/pre_commit/pre_commit_sync_version.sh
deleted file mode 100755
index 4c38d9f..0000000
--- a/scripts/ci/pre_commit/pre_commit_sync_version.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-set -euo pipefail
-
-# shellcheck source=scripts/ci/libraries/_script_init.sh
-. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh"
-
-set -x
-
-AIRFLOW_VERSION_STRING=$(grep "version =" "${AIRFLOW_SOURCES}/airflow/version.py")
-readonly AIRFLOW_VERSION_STRING
-
-sed -i".out" -e "s/version =.*$/${AIRFLOW_VERSION_STRING}/" "${AIRFLOW_SOURCES}/setup.py"
-rm setup.py.out
diff --git a/scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh b/scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh
index 41406d9..f90f344 100755
--- a/scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh
+++ b/scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh
@@ -44,7 +44,6 @@ function run_test_package_import_all_classes() {
-v "${AIRFLOW_SOURCES}/setup.py:/airflow_sources/setup.py:cached" \
-v "${AIRFLOW_SOURCES}/setup.cfg:/airflow_sources/setup.cfg:cached" \
-v "${AIRFLOW_SOURCES}/airflow/__init__.py:/airflow_sources/airflow/__init__.py:cached" \
- -v "${AIRFLOW_SOURCES}/airflow/version.py:/airflow_sources/airflow/version.py:cached" \
-v "${AIRFLOW_SOURCES}/empty:/opt/airflow/airflow:cached" \
-v "${AIRFLOW_SOURCES}/scripts/in_container:/opt/airflow/scripts/in_container:cached" \
-v "${AIRFLOW_SOURCES}/dev/import_all_classes.py:/opt/airflow/dev/import_all_classes.py:cached" \
diff --git a/setup.py b/setup.py
index 129db85..5404b82 100644
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,6 @@ from setuptools import Command, find_namespace_packages, setup
logger = logging.getLogger(__name__)
-# This is automatically maintained in sync via pre-commit from airflow/version.py
version = '2.0.0b3'
PY3 = sys.version_info[0] == 3