Skip to content

Commit

Permalink
Optional Argument to dev_setup.py - Codifying Dev Dependencies (#4067)
Browse files Browse the repository at this point in the history
* initial attempt + logic in dev_setup.py.

* removing commented stuff

* adding a couple example dev_requirements.txt

* adding a comment to explain targeted_packages

* adding requirements files for any package that has tests.

* removing 'azure-common' as it is a runtime package that doesn't need to be explicitly added

* making some progress. replaced all the dev_requirements files, now to see how it will react to my install actions

* removing expandDependencies, swapping entirely to leverage only dev_requirements.txt

* working

* setting this up such that travis.ci won't get punished by the dev_requirements addition

* updating yaml to take advantage of the new dev_setup stuff

* we'll just rely on pip to rationalize that everything is installed
  • Loading branch information
scbedd authored and lmazuel committed Dec 20, 2018
1 parent 92c969f commit 46b4b17
Show file tree
Hide file tree
Showing 68 changed files with 140 additions and 24 deletions.
13 changes: 12 additions & 1 deletion .azure-pipelines/generic.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ jobs:
inputs:
versionSpec: '$(python.version)'

- script: 'python scripts/dev_setup.py'
- powershell: |
$inputFilterSet="$(build_targeting_string)"
if ($inputFilterSet -eq "")
{
$inputFilterSet = "azure-*"
}
foreach($inputFilter in $inputFilterSet.split(","))
{
python scripts/dev_setup.py -g $inputFilter
}
displayName: 'Test Setup'
- powershell: |
Expand Down
24 changes: 16 additions & 8 deletions .azure-pipelines/specialcase.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ jobs:
$storedPath=$Env:PATH
$Env:PATH="/home/vsts/pypy3-v6.0.0-linux64/bin:" + $Env:PATH
pypy3 -m ensurepip
pypy3 scripts/dev_setup.py
$inputFilterSet="$(build_targeting_string)"
if ($inputFilterSet -eq "")
{
$inputFilterSet = "azure-*"
}
pypy3 -m ensurepip
foreach($inputFilter in $inputFilterSet.split(","))
{
pypy3 scripts/dev_setup.py -g $inputFilter
}
foreach($inputFilter in "$inputFilterSet".split(","))
{
$folderCombination = (gci -Directory -Name -Filter "$inputFilter" | %{ "$(Build.SourcesDirectory)/$_/" }) -join " "
Expand All @@ -53,16 +57,20 @@ jobs:
$storedPath=$Env:PATH
$Env:PATH="/home/vsts/bin:" + $Env:PATH
python3 -m ensurepip
python3 scripts/dev_setup.py
$inputFilterSet="$(build_targeting_string)"
if ($inputFilterSet -eq "")
{
$inputFilterSet = "azure-*"
}
python3 -m ensurepip
foreach($inputFilter in $inputFilterSet.split(","))
{
python3 scripts/dev_setup.py -g $inputFilter
}
foreach($inputFilter in "$inputFilterSet".split(","))
{
$folderCombination = (gci -Directory -Name -Filter "$inputFilter" | %{ "$(Build.SourcesDirectory)/$_/" }) -join " "
Expand Down
1 change: 1 addition & 0 deletions azure-applicationinsights/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-batch/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-batch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-cognitiveservices-vision-face/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-common/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-eventgrid/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-graphrbac/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
3 changes: 3 additions & 0 deletions azure-keyvault/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-e ../azure-mgmt-authorization
-e ../azure-mgmt-keyvault
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-loganalytics/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-advisor/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-authorization/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-batch/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-keyvault
1 change: 1 addition & 0 deletions azure-mgmt-batchai/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-billing/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-botservice/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-cdn/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-commerce/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
4 changes: 4 additions & 0 deletions azure-mgmt-compute/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-authorization
-e ../azure-mgmt-storage
-e ../azure-mgmt-network
1 change: 1 addition & 0 deletions azure-mgmt-consumption/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-containerinstance/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-containerregistry/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-storage
1 change: 1 addition & 0 deletions azure-mgmt-containerservice/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-cosmosdb/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-datafactory/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-datalake-analytics/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-datalake-store/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-datamigration/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-network
1 change: 1 addition & 0 deletions azure-mgmt-devtestlabs/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-dns/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-network
1 change: 1 addition & 0 deletions azure-mgmt-documentdb/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-eventgrid/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-eventhub/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-hanaonazure/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-iotcentral/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-iothub/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-keyvault/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-logic/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-machinelearningcompute/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-resource
1 change: 1 addition & 0 deletions azure-mgmt-managementpartner/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-media/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-storage
1 change: 1 addition & 0 deletions azure-mgmt-monitor/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-network/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-notificationhubs/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-recoveryservices/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-resource
2 changes: 2 additions & 0 deletions azure-mgmt-recoveryservicesbackup/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-recoveryservices
1 change: 1 addition & 0 deletions azure-mgmt-redis/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-relay/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-reservations/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-resource/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-resourcegraph/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-scheduler/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-search/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-servermanager/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-servicebus/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-sql/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-storage/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
2 changes: 2 additions & 0 deletions azure-mgmt-subscription/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ../azure-sdk-tools
-e ../azure-mgmt-billing
1 change: 1 addition & 0 deletions azure-mgmt-trafficmanager/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-mgmt-web/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
12 changes: 6 additions & 6 deletions azure-sdk-tools/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
'pytest>=3.5.1',
# 'azure-devtools>=0.4.1' override by packaging needs
'readme_renderer',

# Should not be here, but split per package once they have test dependencies
'azure-storage-blob', # azure-servicemanagement-legacy azure-keyvault
'azure-storage-file', # azure-mgmt-batchai
'azure-storage-common', # azure-keyvault
'pyopenssl' # azure-servicemanagement-legacy
'azure-storage-blob',
'azure-storage-file',
'azure-storage-common',
'pyopenssl',
'azure-mgmt-resource',
'azure-mgmt-storage'
]

setup(
Expand Down
1 change: 1 addition & 0 deletions azure-servicebus/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
1 change: 1 addition & 0 deletions azure-servicemanagement-legacy/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../azure-sdk-tools
36 changes: 27 additions & 9 deletions scripts/dev_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,49 @@
import sys
import glob
import os
import argparse
from collections import Counter
from subprocess import check_call, CalledProcessError

root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..'))


def pip_command(command, error_ok=False):
def pip_command(command, additionalDir='.', error_ok=False):
try:
print('Executing: ' + command)
check_call([sys.executable, '-m', 'pip'] + command.split(), cwd=root_dir)
check_call([sys.executable, '-m', 'pip'] + command.split(), cwd=os.path.join(root_dir, additionalDir))
print()
except CalledProcessError as err:
print(err, file=sys.stderr)
if not error_ok:
sys.exit(1)

# optional argument in a situation where we want to build a single package
parser = argparse.ArgumentParser(description='Set up the dev environment for selected packages.')
parser.add_argument('--globArg', '-g', dest='globArg', default='azure*', help='Defaulted to "azure*", used to limit the number of packages that dependencies will be installed for. ')
args = parser.parse_args()

packages = [os.path.dirname(p) for p in glob.glob('azure*/setup.py')]

# keep targeted packages separate. python2 needs the nspkgs to work properly.
targeted_packages = [os.path.dirname(p) for p in glob.glob('{0}/setup.py'.format(args.globArg))]

# Extract nspkg and sort nspkg by number of "-"
nspkg_packages = [p for p in packages if "nspkg" in p]
nspkg_packages = [p for p in packages if 'nspkg' in p]
nspkg_packages.sort(key = lambda x: len([c for c in x if c == '-']))

# Manually push meta-packages at the end, in reverse dependency order
meta_packages = ['azure-mgmt', 'azure']

content_packages = [p for p in packages if p not in nspkg_packages+meta_packages]
content_packages = [p for p in packages if p not in nspkg_packages+meta_packages and p in targeted_packages]

# Put azure-common in front
content_packages.remove("azure-common")
content_packages.insert(0, "azure-common")
if 'azure-common' in content_packages:
content_packages.remove('azure-common')
content_packages.insert(0, 'azure-common')

if 'azure-sdk-tools' in content_packages:
content_packages.remove('azure-sdk-tools')
content_packages.insert(1, 'azure-sdk-tools')

print('Running dev setup...')
print('Root directory \'{}\'\n'.format(root_dir))
Expand All @@ -55,11 +70,14 @@ def pip_command(command, error_ok=False):

# install packages
for package_name in content_packages:
# if we are running dev_setup with no arguments. going after dev_requirements will be a pointless exercise
# and waste of cycles as all the dependencies will be installed regardless.
if os.path.isfile('{}/dev_requirements.txt'.format(package_name)):
pip_command('install -r dev_requirements.txt', package_name)
pip_command('install --ignore-requires-python -e {}'.format(package_name))

# On Python 3, uninstall azure-nspkg if he got installed
if sys.version_info >= (3, ):
pip_command('uninstall -y azure-nspkg', error_ok=True)


print('Finished dev setup.')
print('Finished dev setup.')

0 comments on commit 46b4b17

Please sign in to comment.