You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Taragolis (via GitHub)" <gi...@apache.org> on 2024/02/15 13:14:15 UTC

[PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Taragolis opened a new pull request, #37444:
URL: https://github.com/apache/airflow/pull/37444

   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   Check that there are no any missing files or broken build for sdist distribution of `apache-airflow` package.
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491675071


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -711,8 +804,8 @@ def prepare_provider_packages(
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
     get_console().print("\n[info]Packages available in dist:\n")
-    for file in sorted(DIST_DIR.glob("apache*")):
-        get_console().print(file.name)
+    for dist_info in _dist_packages(package_format=package_format, build_type="providers"):
+        get_console().print(str(dist_info))

Review Comment:
   BTW. Since it is sdist - it is only enabled in canary build, so you can either change the condtion in ci.yml it to test it in CI or push it to "airflow" repo and assign `canary` label to get it work in the same way as canary build.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491043471


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -374,6 +404,58 @@ def _build_airflow_packages_with_hatch(
     )
 
 
+def _dist_packages(
+    *, package_format: str, build_type: Literal["airflow", "providers"]
+) -> Iterator[DistributionPackageInfo]:
+    if build_type == "airflow":
+        default_glob_pattern = "apache[_-]airflow-[0-9]"
+    else:
+        default_glob_pattern = "apache[_-]airflow[_-]providers"
+
+    if package_format in ["sdist", "both"]:
+        for file in DIST_DIR.glob(f"{default_glob_pattern}*tar.gz"):
+            if not file.is_file():
+                continue
+            yield DistributionPackageInfo.from_sdist(filepath=file)
+    if package_format in ["wheel", "both"]:
+        for file in DIST_DIR.glob(f"{default_glob_pattern}*whl"):
+            if not file.is_file():
+                continue
+            yield DistributionPackageInfo.from_wheel(filepath=file)
+
+
+def _check_sdist_to_wheel(dist_info: DistributionPackageInfo):
+    if dist_info.dist_type != "sdist":
+        return
+
+    with tempfile.TemporaryDirectory() as tmp_dir_name:
+        venv_path = Path(tmp_dir_name) / ".venv"
+        venv.EnvBuilder(with_pip=True).create(venv_path)
+        python_path = venv_path / "bin" / "python"
+        if not python_path.exists():
+            msg = f"Python interpreter is not exist in path {python_path}"
+            raise FileNotFoundError(msg)

Review Comment:
   I'm not sure should we create venv from the `run_command` or via [`venv`](https://docs.python.org/3/library/venv.html) module.
   Technically `venv` could be missing in some distributions, in this case entire `release_management_commands` would fail on import statement.



##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -711,8 +804,8 @@ def prepare_provider_packages(
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
     get_console().print("\n[info]Packages available in dist:\n")
-    for file in sorted(DIST_DIR.glob("apache*")):
-        get_console().print(file.name)
+    for dist_info in _dist_packages(package_format=package_format, build_type="providers"):
+        get_console().print(str(dist_info))

Review Comment:
   For providers I do not add this check but maybe I should?
   In case of `apache-airflow` it doesn't big overhead, build package from sources take for about 1m - 1m 20s, and additional 10 seconds in negligible in the other hand create new venv for each provider package might add huge overhead in total.



##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -406,8 +488,19 @@ def prepare_airflow_packages(
             version_suffix_for_pypi=version_suffix_for_pypi,
         )
     get_console().print("[success]Successfully prepared Airflow packages:")
-    for file in sorted(DIST_DIR.glob("apache_airflow*")):
-        get_console().print(file.name)
+    packages = tuple(_dist_packages(package_format=package_format, build_type="airflow"))
+    for dist_info in packages:
+        get_console().print(str(dist_info))
+    get_console().print()
+    if package_format == "wheel":
+        return
+
+    for dist_info in packages:
+        if dist_info.dist_type == "sdist":
+            get_console().print(
+                f"[info]Validate build wheel from sdist distribution: {dist_info.filepath.name!r}[/]"
+            )
+            _check_sdist_to_wheel(dist_info)

Review Comment:
   This check run pretty fast, for about 5-15 seconds, but I've also have a filling that this check might be optional



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491063071


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -711,8 +804,8 @@ def prepare_provider_packages(
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
     get_console().print("\n[info]Packages available in dist:\n")
-    for file in sorted(DIST_DIR.glob("apache*")):
-        get_console().print(file.name)
+    for dist_info in _dist_packages(package_format=package_format, build_type="providers"):
+        get_console().print(str(dist_info))

Review Comment:
   BTW. We could create single venv and install all providers there - after all of them are prepared, we usually prepare 10-15 providers together, so I think the overhead will be almost not noticeable there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491057063


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -374,6 +404,58 @@ def _build_airflow_packages_with_hatch(
     )
 
 
+def _dist_packages(
+    *, package_format: str, build_type: Literal["airflow", "providers"]
+) -> Iterator[DistributionPackageInfo]:
+    if build_type == "airflow":
+        default_glob_pattern = "apache[_-]airflow-[0-9]"
+    else:
+        default_glob_pattern = "apache[_-]airflow[_-]providers"
+
+    if package_format in ["sdist", "both"]:
+        for file in DIST_DIR.glob(f"{default_glob_pattern}*tar.gz"):
+            if not file.is_file():
+                continue
+            yield DistributionPackageInfo.from_sdist(filepath=file)
+    if package_format in ["wheel", "both"]:
+        for file in DIST_DIR.glob(f"{default_glob_pattern}*whl"):
+            if not file.is_file():
+                continue
+            yield DistributionPackageInfo.from_wheel(filepath=file)
+
+
+def _check_sdist_to_wheel(dist_info: DistributionPackageInfo):
+    if dist_info.dist_type != "sdist":
+        return
+
+    with tempfile.TemporaryDirectory() as tmp_dir_name:
+        venv_path = Path(tmp_dir_name) / ".venv"
+        venv.EnvBuilder(with_pip=True).create(venv_path)
+        python_path = venv_path / "bin" / "python"
+        if not python_path.exists():
+            msg = f"Python interpreter is not exist in path {python_path}"
+            raise FileNotFoundError(msg)

Review Comment:
   venv is fine - this method is run by release manager only, and we can have **some** expectations about it. Also by default - even if this method is run by regular contributor, it only creates whl file so it's fine



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491060978


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -711,8 +804,8 @@ def prepare_provider_packages(
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
     get_console().print("\n[info]Packages available in dist:\n")
-    for file in sorted(DIST_DIR.glob("apache*")):
-        get_console().print(file.name)
+    for dist_info in _dist_packages(package_format=package_format, build_type="providers"):
+        get_console().print(str(dist_info))

Review Comment:
   I think for providers it's less of a problem, because 1) we do not have custom build hooks there 2) pyproject.toml is automatically generated from template, and is basically the same for every provided (- paths it uses). And we also check it during main build. But if you feel like adding it would be good - we can definitely add it as follow-up



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #37444:
URL: https://github.com/apache/airflow/pull/37444#issuecomment-1948213727

   closed in favor of https://github.com/apache/airflow/pull/37476


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis closed pull request #37444: [POC] Validate is it possible to build wheel from sdist distribution
URL: https://github.com/apache/airflow/pull/37444


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #37444:
URL: https://github.com/apache/airflow/pull/37444#issuecomment-1946091640

   Good idea. It's  not strictly neeed - it's implicitly tested by the "install from sdist" job - but as we saw -  it was not run because of a bug, so yeah - extra check (who tests the tests) would not hurt.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491058028


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -406,8 +488,19 @@ def prepare_airflow_packages(
             version_suffix_for_pypi=version_suffix_for_pypi,
         )
     get_console().print("[success]Successfully prepared Airflow packages:")
-    for file in sorted(DIST_DIR.glob("apache_airflow*")):
-        get_console().print(file.name)
+    packages = tuple(_dist_packages(package_format=package_format, build_type="airflow"))
+    for dist_info in packages:
+        get_console().print(str(dist_info))
+    get_console().print()
+    if package_format == "wheel":
+        return
+
+    for dist_info in packages:
+        if dist_info.dist_type == "sdist":
+            get_console().print(
+                f"[info]Validate build wheel from sdist distribution: {dist_info.filepath.name!r}[/]"
+            )
+            _check_sdist_to_wheel(dist_info)

Review Comment:
   It's fine - let's keep it. The more guardrails we have while releasing packages, the better.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [POC] Validate is it possible to build wheel from sdist distribution [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #37444:
URL: https://github.com/apache/airflow/pull/37444#discussion_r1491687286


##########
dev/breeze/src/airflow_breeze/commands/release_management_commands.py:
##########
@@ -711,8 +804,8 @@ def prepare_provider_packages(
         sys.exit(0)
     get_console().print("\n[success]Successfully built packages!\n\n")
     get_console().print("\n[info]Packages available in dist:\n")
-    for file in sorted(DIST_DIR.glob("apache*")):
-        get_console().print(file.name)
+    for dist_info in _dist_packages(package_format=package_format, build_type="providers"):
+        get_console().print(str(dist_info))

Review Comment:
   Yeah, will push it into the airflow repo tomorrow, after check how it impact on providers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org