Installation Fixes and Improvements

Installation as well as distribution generation are now simplified.
With the elimination of MinGW support there is now a unique set of
platform binaries for 32-bit and 64-bit Windows. Pip will now
automatically choose the proper binary wheel or the source
distribution, depending under which platform and Python version it
is being invoked.

	* README.md: add installation section
	* setup.py: rewrite to use bdist_wheel for Windows
incoming
Ray 2017-04-07 13:53:48 -07:00
parent 9bf91c202a
commit 8ec1dfb56c
3 changed files with 104 additions and 92 deletions

View File

@ -1,3 +1,12 @@
2017-04-06 Ray Brown <code@liquibits.com>
Installation Fixes and Improvements
Installation as well as distribution generation are now simplified. With the elimination of MinGW support there is now a unique set of platform binaries for 32-bit and 64-bit Windows. Pip will now automatically choose the proper binary wheel or the source distribution, depending under which platform and Python version it is being invoked.
* README.md: add installation section
* setup.py: rewrite to use bdist_wheel for Windows
2017-04-03 Ray Brown <ray@Virtor10> 2017-04-03 Ray Brown <ray@Virtor10>
Release 1.2.0 Release 1.2.0

View File

@ -27,6 +27,14 @@ As of version 1.2.0, PyDTLS supports DTLS version 1.2 in addition to
version 1.0. This version also introduces forward secrecy using version 1.0. This version also introduces forward secrecy using
elliptic curve cryptography and more fine-grained configuration options. elliptic curve cryptography and more fine-grained configuration options.
## Installation
To install from PyPI, on any supported platform enter:
```
pip install Dtls
```
## Design Goals ## Design Goals
The primary design goal of PyDTLS is broad availability. It has therefore The primary design goal of PyDTLS is broad availability. It has therefore

153
setup.py
View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# PyDTLS setup script. # PyDTLS setup script.
# Copyright 2012 Ray Brown # Copyright 2017 Ray Brown
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -22,102 +22,97 @@
Install or create a distribution of the PyDTLS package. Install or create a distribution of the PyDTLS package.
""" """
from os import listdir, path, remove, rename from os import path, remove
from sys import argv from shutil import copy2, rmtree
from argparse import ArgumentParser
from pickle import dump, load from pickle import dump, load
from distutils.core import setup from setuptools import setup
from distutils.command.install import INSTALL_SCHEMES
# Make the root for data file installations the same as Python code
for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']
NAME = "Dtls" NAME = "Dtls"
VERSION = "1.2.0" VERSION = "1.2.0"
DIST_DIR = "dist" if __name__ == "__main__":
FORMAT_TO_SUFFIX = { "zip": ".zip", # Full upload sequence for new version:
"gztar": ".tar.gz", # 1. python setup.py sdist
"bztar": ".tar.bz2", # 2. python setup.py bdist_wheel -p win32
"ztar": ".tar.Z", # 3. python setup.py bdist_wheel -p win_amd64
"tar": ".tar" } # 4. twine upload dist/*
def invoke_setup(data_files=None): parser = ArgumentParser(add_help=False)
data_files_file = "data_files" parser.add_argument("-h", "--help", action="store_true")
data_files_file_created = False parser.add_argument("command", nargs="*")
try: parser.add_argument("-p", "--plat-name")
if data_files: args = parser.parse_known_args()[0]
# Save the value of data_files with the distribution archive sdist = "sdist" in args.command and not args.help
data_files_file_created = True bdist = "bdist_wheel" in args.command and not args.help
with open(data_files_file, "wb") as fl: if sdist or bdist:
dump(data_files, fl) from pypandoc import convert
data_files.append(('', [data_files_file]),) long_description = convert("README.md", "rst")\
.translate({ord("\r"): None})
else: else:
# Load data_files from the distribution archive, if present long_description = open("README.md").read()
top_package_plat_files_file = "dtls_package_files"
if bdist:
prebuilt_platform_root = "dtls/prebuilt"
if args.plat_name == "win32":
platform = "win32-x86"
elif args.plat_name == "win_amd64":
platform = "win32-x86_64"
else:
raise ValueError("Unknown platform")
prebuilt_path = prebuilt_platform_root + "/" + platform
config = {"MANIFEST_DIR": prebuilt_path}
execfile(prebuilt_path + "/manifest.pycfg", config)
top_package_plat_files = map(lambda x: prebuilt_path + "/" + x,
config["FILES"])
# Save top_package_plat_files with the distribution archive
with open(top_package_plat_files_file, "wb") as fl:
dump(top_package_plat_files, fl)
else:
# Load top_package_files from the distribution archive, if present
try: try:
with open(data_files_file, "rb") as fl: with open(top_package_plat_files_file, "rb") as fl:
data_files = load(fl) top_package_plat_files = load(fl)
except IOError: except IOError:
data_files = [] top_package_plat_files = []
data_files.append(('dtls', ["NOTICE", top_package_extra_files = ["NOTICE",
"LICENSE", "LICENSE",
"README.txt", "README.md",
"ChangeLog"]),) "ChangeLog"] + top_package_plat_files
for extra_file in top_package_extra_files:
copy2(extra_file, "dtls")
top_package_extra_files = [path.basename(f)
for f in top_package_extra_files]
setup(name=NAME, setup(name=NAME,
version=VERSION, version=VERSION,
description="Python Datagram Transport Layer Security", description="Python Datagram Transport Layer Security",
author="Ray Brown", author="Ray Brown",
author_email="code@liquibits.com", author_email="code@liquibits.com",
url="https://github.com/rbit/pydtls", url="https://github.com/rbit/pydtls",
license="LICENSE", license="Apache-2.0",
long_description=open("README.txt").read(), classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Security :: Cryptography',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 2.7',
],
long_description=long_description,
packages=["dtls", "dtls.demux", "dtls.test"], packages=["dtls", "dtls.demux", "dtls.test"],
package_data={"dtls.test": ["makecerts", package_data={"dtls": top_package_extra_files,
"dtls.test": ["makecerts",
"makecerts_ec.bat",
"openssl_ca.cnf", "openssl_ca.cnf",
"openssl_server.cnf", "openssl_server.cnf",
"certs/*.pem"]}, "certs/*.pem"]},
data_files=data_files, data_files=[('', [top_package_plat_files_file])]
) )
finally: for extra_file in top_package_extra_files:
if data_files_file_created: remove("dtls/" + extra_file)
try: if bdist:
remove(data_files_file) remove(top_package_plat_files_file)
except OSError: rmtree("Dtls.egg-info", True)
pass rmtree("build", True)
def make_dists():
prebuilt_platform_root = path.join("dtls", "prebuilt")
for platform in listdir(prebuilt_platform_root):
config = {"MANIFEST_DIR": path.join(prebuilt_platform_root, platform)}
execfile(path.join(prebuilt_platform_root, platform, "manifest.pycfg"),
config)
files = map(lambda x: "dtls/prebuilt/" + platform + "/" + x,
config["FILES"])
argv.append("--formats=" + config["FORMATS"])
invoke_setup([('dtls', files)])
del argv[-1]
for dist_format in config["FORMATS"].split(','):
source_name = path.join(DIST_DIR,
NAME + "-" + VERSION +
FORMAT_TO_SUFFIX[dist_format])
target_name = path.join(DIST_DIR,
NAME + "-" + VERSION +
".sdist_with_openssl." +
config["ARCHITECTURE"] +
FORMAT_TO_SUFFIX[dist_format])
try:
remove(target_name)
except OSError:
pass
rename(source_name, target_name)
if __name__ == "__main__":
# Full upload sequence for new version:
# python setup.py sdist --formats=zip,gztar upload
# python setup.py sdist --prebuilts
# Manually add .sdist_with_openssl. archives to repository
if argv[-1] == "--prebuilts":
del argv[-1]
make_dists()
else:
invoke_setup()