Skip to content

Commit

Permalink
New packaging system for all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Mar 30, 2017
1 parent bff2a6e commit e57bb60
Show file tree
Hide file tree
Showing 144 changed files with 2,005 additions and 77 deletions.
2 changes: 1 addition & 1 deletion azure-batch/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.rst
exclude azure/__init__.py
include azure_wheel.py
53 changes: 53 additions & 0 deletions azure-batch/azure_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------

from distutils import log as logger
import os.path
try:
from wheel.bdist_wheel import bdist_wheel as original_bdist_wheel
class bdist_wheel(original_bdist_wheel):

description = "Create an Azure wheel distribution"

user_options = original_bdist_wheel.user_options + \
[('azure-namespace-package=', None,
"Name of the deepest nspkg used")]

def initialize_options(self):
original_bdist_wheel.initialize_options(self)
self.azure_namespace_package = None

def finalize_options(self):
original_bdist_wheel.finalize_options(self)
if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"):
raise ValueError("azure_namespace_package must finish by -nspkg")

def run(self):
if not self.distribution.install_requires:
self.distribution.install_requires = []
self.distribution.install_requires.append(
"{}>=2.0.0".format(self.azure_namespace_package))
original_bdist_wheel.run(self)

def write_record(self, bdist_dir, distinfo_dir):
if self.azure_namespace_package:
# Split and remove last part, assuming it's "nspkg"
subparts = self.azure_namespace_package.split('-')[0:-1]
folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))]
for azure_sub_package in folder_with_init:
init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py')
if os.path.isfile(init_file):
logger.info("manually remove {} while building the wheel".format(init_file))
os.remove(init_file)
else:
raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file))
original_bdist_wheel.write_record(self, bdist_dir, distinfo_dir)
cmdclass = {
'bdist_wheel': bdist_wheel,
}
except ImportError:
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
1 change: 1 addition & 0 deletions azure-batch/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[bdist_wheel]
universal=1
azure-namespace-package=azure-nspkg

[install]
single-version-externally-managed=1
Expand Down
2 changes: 2 additions & 0 deletions azure-batch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#--------------------------------------------------------------------------

from setuptools import find_packages, setup
from azure_wheel import cmdclass
from io import open
import re
import os.path
Expand Down Expand Up @@ -75,4 +76,5 @@
'azure-common~=1.1.4',
'msrestazure~=0.4.7',
],
cmdclass=cmdclass
)
4 changes: 2 additions & 2 deletions azure-common/azure_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def finalize_options(self):
raise ValueError("azure_namespace_package must finish by -nspkg")

def run(self):
if not self.distribution.install_requires:
self.distribution.install_requires = []
self.distribution.install_requires.append(
"{}>=2.0.0".format(self.azure_namespace_package))
original_bdist_wheel.run(self)

def write_record(self, bdist_dir, distinfo_dir):
# following check could be improved, by parsing the package name
# package_name = self.distribution.get_name()
if self.azure_namespace_package:
# Split and remove last part, assuming it's "nspkg"
subparts = self.azure_namespace_package.split('-')[0:-1]
Expand Down
3 changes: 1 addition & 2 deletions azure-graphrbac/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include *.rst
exclude azure/__init__.py
exclude azure/mgmt/__init__.py
include azure_wheel.py
53 changes: 53 additions & 0 deletions azure-graphrbac/azure_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------

from distutils import log as logger
import os.path
try:
from wheel.bdist_wheel import bdist_wheel as original_bdist_wheel
class bdist_wheel(original_bdist_wheel):

description = "Create an Azure wheel distribution"

user_options = original_bdist_wheel.user_options + \
[('azure-namespace-package=', None,
"Name of the deepest nspkg used")]

def initialize_options(self):
original_bdist_wheel.initialize_options(self)
self.azure_namespace_package = None

def finalize_options(self):
original_bdist_wheel.finalize_options(self)
if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"):
raise ValueError("azure_namespace_package must finish by -nspkg")

def run(self):
if not self.distribution.install_requires:
self.distribution.install_requires = []
self.distribution.install_requires.append(
"{}>=2.0.0".format(self.azure_namespace_package))
original_bdist_wheel.run(self)

def write_record(self, bdist_dir, distinfo_dir):
if self.azure_namespace_package:
# Split and remove last part, assuming it's "nspkg"
subparts = self.azure_namespace_package.split('-')[0:-1]
folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))]
for azure_sub_package in folder_with_init:
init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py')
if os.path.isfile(init_file):
logger.info("manually remove {} while building the wheel".format(init_file))
os.remove(init_file)
else:
raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file))
original_bdist_wheel.write_record(self, bdist_dir, distinfo_dir)
cmdclass = {
'bdist_wheel': bdist_wheel,
}
except ImportError:
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
1 change: 1 addition & 0 deletions azure-graphrbac/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[bdist_wheel]
universal=1
azure-namespace-package=azure-nspkg

[install]
single-version-externally-managed=1
Expand Down
2 changes: 2 additions & 0 deletions azure-graphrbac/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#--------------------------------------------------------------------------

from setuptools import setup
from azure_wheel import cmdclass
from io import open
import re

Expand Down Expand Up @@ -70,4 +71,5 @@
'azure-common~=1.1.4',
'msrestazure~=0.4.6',
],
cmdclass=cmdclass
)
2 changes: 1 addition & 1 deletion azure-keyvault/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include *.rst
exclude azure/__init__.py
include azure_wheel.py
53 changes: 53 additions & 0 deletions azure-keyvault/azure_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------

from distutils import log as logger
import os.path
try:
from wheel.bdist_wheel import bdist_wheel as original_bdist_wheel
class bdist_wheel(original_bdist_wheel):

description = "Create an Azure wheel distribution"

user_options = original_bdist_wheel.user_options + \
[('azure-namespace-package=', None,
"Name of the deepest nspkg used")]

def initialize_options(self):
original_bdist_wheel.initialize_options(self)
self.azure_namespace_package = None

def finalize_options(self):
original_bdist_wheel.finalize_options(self)
if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"):
raise ValueError("azure_namespace_package must finish by -nspkg")

def run(self):
if not self.distribution.install_requires:
self.distribution.install_requires = []
self.distribution.install_requires.append(
"{}>=2.0.0".format(self.azure_namespace_package))
original_bdist_wheel.run(self)

def write_record(self, bdist_dir, distinfo_dir):
if self.azure_namespace_package:
# Split and remove last part, assuming it's "nspkg"
subparts = self.azure_namespace_package.split('-')[0:-1]
folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))]
for azure_sub_package in folder_with_init:
init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py')
if os.path.isfile(init_file):
logger.info("manually remove {} while building the wheel".format(init_file))
os.remove(init_file)
else:
raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file))
original_bdist_wheel.write_record(self, bdist_dir, distinfo_dir)
cmdclass = {
'bdist_wheel': bdist_wheel,
}
except ImportError:
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
1 change: 1 addition & 0 deletions azure-keyvault/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[bdist_wheel]
universal=1
azure-namespace-package=azure-nspkg

[install]
single-version-externally-managed=1
Expand Down
4 changes: 3 additions & 1 deletion azure-keyvault/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#--------------------------------------------------------------------------

from setuptools import find_packages, setup
from azure_wheel import cmdclass
from io import open
import re
import os.path
Expand Down Expand Up @@ -37,7 +38,7 @@

#For KeyVault only
package_folder_path = os.path.join(package_folder_path, 'generated')
# Version extraction inspired from 'requests'
with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd:
version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
Expand Down Expand Up @@ -78,4 +79,5 @@
'azure-common~=1.1.4',
'msrestazure~=0.4.6',
],
cmdclass=cmdclass
)
3 changes: 1 addition & 2 deletions azure-mgmt-authorization/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include *.rst
exclude azure/__init__.py
exclude azure/mgmt/__init__.py
include azure_wheel.py
53 changes: 53 additions & 0 deletions azure-mgmt-authorization/azure_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------

from distutils import log as logger
import os.path
try:
from wheel.bdist_wheel import bdist_wheel as original_bdist_wheel
class bdist_wheel(original_bdist_wheel):

description = "Create an Azure wheel distribution"

user_options = original_bdist_wheel.user_options + \
[('azure-namespace-package=', None,
"Name of the deepest nspkg used")]

def initialize_options(self):
original_bdist_wheel.initialize_options(self)
self.azure_namespace_package = None

def finalize_options(self):
original_bdist_wheel.finalize_options(self)
if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"):
raise ValueError("azure_namespace_package must finish by -nspkg")

def run(self):
if not self.distribution.install_requires:
self.distribution.install_requires = []
self.distribution.install_requires.append(
"{}>=2.0.0".format(self.azure_namespace_package))
original_bdist_wheel.run(self)

def write_record(self, bdist_dir, distinfo_dir):
if self.azure_namespace_package:
# Split and remove last part, assuming it's "nspkg"
subparts = self.azure_namespace_package.split('-')[0:-1]
folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))]
for azure_sub_package in folder_with_init:
init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py')
if os.path.isfile(init_file):
logger.info("manually remove {} while building the wheel".format(init_file))
os.remove(init_file)
else:
raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file))
original_bdist_wheel.write_record(self, bdist_dir, distinfo_dir)
cmdclass = {
'bdist_wheel': bdist_wheel,
}
except ImportError:
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}
1 change: 1 addition & 0 deletions azure-mgmt-authorization/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[bdist_wheel]
universal=1
azure-namespace-package=azure-mgmt-nspkg

[install]
single-version-externally-managed=1
Expand Down
2 changes: 2 additions & 0 deletions azure-mgmt-authorization/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#--------------------------------------------------------------------------

from setuptools import setup
from azure_wheel import cmdclass
import re

# azure v0.x is not compatible with this package
Expand Down Expand Up @@ -66,4 +67,5 @@
'msrestazure~=0.4.6',
'azure-mgmt-nspkg',
],
cmdclass=cmdclass
)
3 changes: 1 addition & 2 deletions azure-mgmt-batch/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
include *.rst
exclude azure/__init__.py
exclude azure/mgmt/__init__.py
include azure_wheel.py
Loading

0 comments on commit e57bb60

Please sign in to comment.