Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get airflow version from importlib.metadata rather than hard-coding #12786

Merged
merged 3 commits into from Dec 4, 2020

Conversation

ashb
Copy link
Member

@ashb ashb commented Dec 3, 2020

One less thing to change, and one less pre-commit step needed :)


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

One less thing to change, and one less pre-commit step needed :)
@ashb ashb requested a review from potiuk December 3, 2020 15:43
@ashb ashb requested a review from kaxil December 3, 2020 15:43

version = metadata.version('apache-airflow')

del metadata
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This line isn't strictly needed, it was just so that the only symbol in this module was version. For no god reason really)

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! This is so much better in this direction than previously !

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked more closely and we need to change it in few more places. Comment follows.

@potiuk
Copy link
Member

potiuk commented Dec 3, 2020

We should fix it in few other places as well:

  • scripts/ci/provider_packages/ci_install_and_test_provider_packages.sh -> it can be removed, it was needed because setup.py imported it before
  • Dockerfile.ci -> ditto
  • STATIC_CODE_CHECKS.rst has reference to removed pre-commit rule
  • dev/README.md needs to be updated
  • dev/README_RELEASE_AIRLFOW.md as well
  • dev/provider_packages/enter_breeze_provider_package_tests.sh also can be removed as it was needed only for setup.py
  • scripts/ci/libraries/_initialization.sh - it reads version from airflow/version.py, it should from setup.py, also it uses airfflow/version.py in calculation of md5sum of files for which changes trigger the build (includes comment about the mechanism)

@ashb
Copy link
Member Author

ashb commented Dec 3, 2020

Cool, I'll update those use cases.

@ashb
Copy link
Member Author

ashb commented Dec 3, 2020

scripts/ci/libraries/_initialization.sh - it reads version from airflow/version.py, it should from setup.py

We could use python setup.py --version, but do we have enough of a python environment wherever that is run? I feel we should, all it needs is setuptools.

Pushed a fixup with that -- lets see what happens.

# 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=$(python "${AIRFLOW_SOURCES}/setup.py" --version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to run Python here if possible. While this is a reasonable expectation that Python is installed in the hos, there are still some cases where people will have python2 by default for example and i would rather keep it bash only. There is another case in the future where we will use those scripts in code spaces environment and vs code to run docker-only environment and i would not like to have to depend on Python there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/ci/libraries/_initialization.sh: line 138: python: command not found

Failed anyway :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course that all untill we rewrite breeze in python - which might change the whole approach: #12282

@potiuk
Copy link
Member

potiuk commented Dec 3, 2020

scripts/ci/libraries/_initialization.sh - it reads version from airflow/version.py, it should from setup.py

We could use python setup.py --version, but do we have enough of a python environment wherever that is run? I feel we should, all it needs is setuptools.

Pushed a fixup with that -- lets see what happens.

As commented - i'd prefer base it on having POSIX compliant OS simply.

@mik-laj
Copy link
Member

mik-laj commented Dec 3, 2020

I'm not sure, but Google tried to use a similar trick and it causes problems.
googleapis/google-api-python-client#876

@ashb
Copy link
Member Author

ashb commented Dec 4, 2020

I'm not sure, but Google tried to use a similar trick and it causes problems.
googleapis/google-api-python-client#876

That seems specific to using Pyinstaller

@ashb ashb requested a review from potiuk December 4, 2020 11:28
@potiuk
Copy link
Member

potiuk commented Dec 4, 2020

I'm not sure, but Google tried to use a similar trick and it causes problems.
googleapis/google-api-python-client#876

That seems specific to using Pyinstaller

Yeah. I would not worry about it. At worst, it might only cause problems in the dev environment. If we find some, we can always catch any exceptions and make a workaround for dev-only env.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Dec 4, 2020
@github-actions
Copy link

github-actions bot commented Dec 4, 2020

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@ashb ashb merged commit 2936c13 into apache:master Dec 4, 2020
@ashb ashb deleted the version-from-metadata branch December 4, 2020 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants