Adds scripts for producing Nuget packages.

This commit is contained in:
Steve Dower 2016-06-24 10:32:15 -07:00
parent a064382925
commit 33f7310c5e
4 changed files with 103 additions and 12 deletions

View file

@ -75,10 +75,12 @@ def include_in_tools(p):
return p.suffix.lower() in {'.py', '.pyw', '.txt'}
FULL_LAYOUT = [
('/', 'PCBuild/$arch', 'python*.exe', is_not_debug),
('/', 'PCBuild/$arch', 'python*.dll', is_not_debug),
('/', 'PCBuild/$arch', 'python.exe', is_not_debug),
('/', 'PCBuild/$arch', 'pythonw.exe', is_not_debug),
('/', 'PCBuild/$arch', 'python{0.major}.dll'.format(sys.version_info), is_not_debug),
('/', 'PCBuild/$arch', 'python{0.major}{0.minor}.dll'.format(sys.version_info), is_not_debug),
('DLLs/', 'PCBuild/$arch', '*.pyd', is_not_debug),
('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug),
('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug_or_python),
('include/', 'include', '*.h', None),
('include/', 'PC', 'pyconfig.h', None),
('Lib/', 'Lib', '**/*', include_in_lib),
@ -150,17 +152,17 @@ def rglob(root, pattern, condition):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--source', metavar='dir', help='The directory containing the repository root', type=Path)
parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, required=True)
parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, default=None)
parser.add_argument('-t', '--temp', metavar='dir', help='A directory to temporarily extract files into', type=Path, default=None)
parser.add_argument('-e', '--embed', help='Create an embedding layout', action='store_true', default=False)
parser.add_argument('-a', '--arch', help='Specify the architecture to use (win32/amd64)', type=str, default="win32")
ns = parser.parse_args()
source = ns.source or (Path(__file__).parent.parent.parent)
source = ns.source or (Path(__file__).resolve().parent.parent.parent)
out = ns.out
arch = ns.arch
assert isinstance(source, Path)
assert isinstance(out, Path)
assert not out or isinstance(out, Path)
assert isinstance(arch, str)
if ns.temp:
@ -170,10 +172,11 @@ def main():
temp = Path(tempfile.mkdtemp())
delete_temp = True
try:
out.parent.mkdir(parents=True)
except FileExistsError:
pass
if out:
try:
out.parent.mkdir(parents=True)
except FileExistsError:
pass
try:
temp.mkdir(parents=True)
except FileExistsError:
@ -190,8 +193,9 @@ def main():
with open(str(temp / 'pyvenv.cfg'), 'w') as f:
print('applocal = true', file=f)
total = copy_to_layout(out, rglob(temp, '*', None))
print('Wrote {} files to {}'.format(total, out))
if out:
total = copy_to_layout(out, rglob(temp, '**/*', None))
print('Wrote {} files to {}'.format(total, out))
finally:
if delete_temp:
shutil.rmtree(temp, True)