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

Add pyproject.toml #28385

Merged
merged 8 commits into from
Oct 12, 2023
Prev Previous commit
Next Next commit
Update stager to use build. If it fails, use legacy setup to build sdist
Fix mypy issue
  • Loading branch information
AnandInguva committed Oct 10, 2023
commit 4c8018312e1e4a4a907e585dafa6b0d410efca3b
28 changes: 21 additions & 7 deletions sdks/python/apache_beam/runners/portability/stager.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import glob
import hashlib
import importlib.util
import logging
import os
import shutil
Expand Down Expand Up @@ -771,13 +772,26 @@ def _build_setup_package(setup_file, # type: str
try:
os.chdir(os.path.dirname(setup_file))
if build_setup_args is None:
build_setup_args = [
Stager._get_python_executable(),
os.path.basename(setup_file),
'sdist',
'--dist-dir',
temp_dir
]
# if build is installed in the user env, use it to
# build the sdist else fallback to legacy setup.py sdist call.
if importlib.util.find_spec('build'):
tvalentyn marked this conversation as resolved.
Show resolved Hide resolved
build_setup_args = [
Stager._get_python_executable(),
'-m',
'build',
'--sdist',
'--outdir',
temp_dir,
os.path.dirname(setup_file),
]
else:
build_setup_args = [
Stager._get_python_executable(),
os.path.basename(setup_file),
'sdist',
'--dist-dir',
temp_dir
]
_LOGGER.info('Executing command: %s', build_setup_args)
processes.check_output(build_setup_args)
output_files = glob.glob(os.path.join(temp_dir, '*.tar.gz'))
Expand Down