Skip to content

Commit

Permalink
Doc build resolution for extension package (#7217)
Browse files Browse the repository at this point in the history
* support for special casing in the doc build

* update the docs.yml to take advantage of the new feature
  • Loading branch information
scbedd authored Sep 11, 2019
1 parent 26319a8 commit 758f358
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .azure-pipelines/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
displayName: 'Install All Packages'
inputs:
scriptPath: 'scripts/dev_setup.py'

arguments: '--exceptionlist=azure-eventhubs-checkpointstoreblob-aio'
=
- powershell: |
cd $(Build.SourcesDirectory)/doc/sphinx
pip install -r requirements.txt
Expand Down
40 changes: 32 additions & 8 deletions scripts/dev_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ def pip_command(command, additional_dir=".", error_ok=False):
if not error_ok:
sys.exit(1)

def select_install_type(pkg, run_develop, exceptions):
# the default for disable_develop will be false, which means `run_develop` will be true
argument = ""
if run_develop:
argument = "-e"

if pkg in exceptions:
# opposite of whatever our decision was
if argument == "":
argument = "-e"
elif argument == "-e":
argument = ""

return argument

# optional argument in a situation where we want to build a variable subset of packages
parser = argparse.ArgumentParser(
Expand All @@ -44,22 +58,32 @@ def pip_command(command, additional_dir=".", error_ok=False):
)
parser.add_argument(
"--disabledevelop",
dest="develop_mode_disabled",
default=False,
action="store_true",
dest="install_in_develop_mode",
default=True,
action="store_false",
help="Add this argument if you would prefer to install the package with a simple `pip install` versus `pip install -e`",
)

# this is a hack to support generating docs for the single package that doesn't support develop mode. It will be removed when we
# migrate to generating docs on a per-package cadence.
parser.add_argument(
"--exceptionlist",
"-e",
dest="exception_list",
default="",
help="Comma separated list of packages that we want to take the 'opposite' installation method for.",
)

args = parser.parse_args()

packages = {
tuple(os.path.dirname(f).rsplit(os.sep, 1))
for f in glob.glob("sdk/*/azure*/setup.py") + glob.glob("tools/azure*/setup.py")
for f in glob.glob("sdk/*/azure-*/setup.py") + glob.glob("tools/azure-*/setup.py")
}
# [(base_folder, package_name), ...] to {package_name: base_folder, ...}
packages = {package_name: base_folder for (base_folder, package_name) in packages}

exceptions = [p.strip() for p in args.exception_list.split(',')]

# keep targeted packages separate. python2 needs the nspkgs to work properly.
if not args.packageList:
targeted_packages = list(packages.keys())
Expand Down Expand Up @@ -118,6 +142,8 @@ def pip_command(command, additional_dir=".", error_ok=False):
for package_name in nspkg_packages:
pip_command("install {}/{}/".format(packages[package_name], package_name))



# install packages
print("Packages to install: {}".format(content_packages))
for package_name in content_packages:
Expand All @@ -132,11 +158,9 @@ def pip_command(command, additional_dir=".", error_ok=False):
os.path.join(packages[package_name], package_name),
)

mode_arg = "" if args.develop_mode_disabled else "-e"

pip_command(
"install --ignore-requires-python {} {}".format(
mode_arg,
select_install_type(package_name, args.install_in_develop_mode, exceptions),
os.path.join(packages[package_name], package_name)
)
)
Expand Down

0 comments on commit 758f358

Please sign in to comment.