Skip to content

Commit

Permalink
Increment release version
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Jan 18, 2022
1 parent f02974e commit 5f94917
Showing 1 changed file with 130 additions and 93 deletions.
223 changes: 130 additions & 93 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@
from __future__ import print_function
import sys

# The current version of the system. Format is #.#.#[-DEV].
version = '1.2.6'
# The current version of the release.
# Note: This is NOT the version number PyXB uses internally to
# test compatibility. The version number used by PyXB is
# set in pyxb/__init__.py:__version__
# Given that PyXB is no longer being maintained, PyXB-X is
# really a project to keep backwards compatibility with the
# last release of PyXB (1.2.6), so the PyXB version will remain
# the same. The release number will remain based on 1.2.6,
# but the rightmost number will be incremented with each patch.
version = "1.2.6.1"

# Require Python 2.6 or higher or Python 3.1 or higher
if (sys.version_info[:2] < (2, 6)) or ((sys.version_info[0] == 3) and sys.version_info[:2] < (3, 1)):
raise ValueError('''PyXB-X requires:
if (sys.version_info[:2] < (2, 6)) or (
(sys.version_info[0] == 3) and sys.version_info[:2] < (3, 1)
):
raise ValueError(
"""PyXB-X requires:
Python2 version 2.6 or later; or
Python3 version 3.1 or later
(You have %s.)''' % (sys.version,))
(You have %s.)"""
% (sys.version,)
)

import os
import stat
Expand All @@ -23,74 +36,84 @@

# Stupid little command to automatically update the version number
# where it needs to be updated.
class update_version (Command):
class update_version(Command):
# Brief (40-50 characters) description of the command
description = "Substitute @VERSION@ in relevant files"

# List of option tuples: long name, short name (None if no short
# name), and help string.
user_options = [ ]
boolean_options = [ ]
user_options = []
boolean_options = []

# Files in the distribution that need to be rewritten when the
# version number changes
files = ( 'pyxb/__init__.py', 'doc/conf.py' )
files = ("pyxb/__init__.py", "doc/conf.py")

# The substitutions (key braced by @ signs)
substitutions = { 'VERSION' : version,
'THIS_YEAR' : datetime.date.today().strftime('%Y'),
'SHORTVERSION' : '.'.join(version.split('.')[:2]) }
substitutions = {
"VERSION": version,
"THIS_YEAR": datetime.date.today().strftime("%Y"),
"SHORTVERSION": ".".join(version.split(".")[:2]),
}

def initialize_options (self):
def initialize_options(self):
pass

def finalize_options (self):
def finalize_options(self):
pass

def run (self):
def run(self):
for f in self.files:
text = open('%s.in' % (f,)).read()
text = open("%s.in" % (f,)).read()
for (k, v) in self.substitutions.items():
text = text.replace('@%s@' % (k,), v)
os.chmod(f, os.stat(f)[stat.ST_MODE] | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
open(f,'w').write(text)
os.chmod(f, os.stat(f)[stat.ST_MODE] & ~(stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH))
text = text.replace("@%s@" % (k,), v)
os.chmod(
f, os.stat(f)[stat.ST_MODE] | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
)
open(f, "w").write(text)
os.chmod(
f,
os.stat(f)[stat.ST_MODE]
& ~(stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH),
)

class test (Command):

class test(Command):

# Brief (40-50 characters) description of the command
description = "Run all unit tests found in testdirs"

# List of option tuples: long name, short name (None if no short
# name), and help string.
user_options = [ ( 'testdirs=', None, 'colon separated list of directories to search for tests' ),
( 'trace-tests', 'v', 'trace search for tests' ),
( 'inhibit-output', 'q', 'inhibit test output' ),
]
boolean_options = [ 'trace-tests', 'inhibit-output' ]

def initialize_options (self):
user_options = [
("testdirs=", None, "colon separated list of directories to search for tests"),
("trace-tests", "v", "trace search for tests"),
("inhibit-output", "q", "inhibit test output"),
]
boolean_options = ["trace-tests", "inhibit-output"]

def initialize_options(self):
self.trace_tests = None
self.inhibit_output = None
self.testdirs = 'tests'
self.testdirs = "tests"

def finalize_options (self):
def finalize_options(self):
pass

# Regular expression that matches unittest sources
__TestFile_re = re.compile('^test.*\.py$')
__TestFile_re = re.compile("^test.*\.py$")

def run (self):
def run(self):
# Make sure log messages are supported
logging.basicConfig()

# Walk the tests hierarchy looking for tests
dirs = self.testdirs.split(':')
tests = [ ]
dirs = self.testdirs.split(":")
tests = []
while dirs:
dir = dirs.pop(0)
if self.trace_tests:
print('Searching for tests in %s' % (dir,))
print("Searching for tests in %s" % (dir,))
for f in os.listdir(dir):
fn = os.path.join(dir, f)
statb = os.stat(fn)
Expand All @@ -111,35 +134,35 @@ def run (self):
suite = unittest.TestSuite()
used_names = set()
for fn in tests:
stage = 'compile'
stage = "compile"
try:
# Assign a unique name for this test
test_name = os.path.basename(fn).split('.')[0]
test_name = test_name.replace('-', '_')
test_name = os.path.basename(fn).split(".")[0]
test_name = test_name.replace("-", "_")
number = 2
base_name = test_name
while test_name in used_names:
test_name = '%s%d' % (base_name, number)
test_name = "%s%d" % (base_name, number)
number += 1

# Read the test source in and compile it
rv = compile(open(fn).read(), test_name, 'exec')
state = 'evaluate'
rv = compile(open(fn).read(), test_name, "exec")
state = "evaluate"

# Make a copy of the globals array so we don't
# contaminate this environment.
g = globals().copy()

# The test cases use __file__ to determine the path to
# the schemas
g['__file__'] = fn
g["__file__"] = fn

# Create a module into which the test will be evaluated.
module = types.ModuleType(test_name)

# The generated code uses __name__ to look up the
# containing module in sys.modules.
g['__name__'] = test_name
g["__name__"] = test_name
sys.modules[test_name] = module

# Import the test into the module, making sure the created globals look like they're in the module.
Expand All @@ -152,9 +175,9 @@ def run (self):
if (type == type(obj)) and issubclass(obj, unittest.TestCase):
suite.addTest(loader.loadTestsFromTestCase(obj))
if self.trace_tests:
print('%s imported' % (fn,))
print("%s imported" % (fn,))
except Exception as e:
print('%s failed in %s: %s' % (fn, stage, e))
print("%s failed in %s: %s" % (fn, stage, e))
raise

# Run everything
Expand All @@ -167,21 +190,26 @@ def run (self):
runner = unittest.TextTestRunner(verbosity=verbosity)
runner.run(suite)


import glob
import sys
import pyxb.utils.utility

packages = [
'pyxb', 'pyxb.namespace', 'pyxb.binding', 'pyxb.utils', 'pyxb.xmlschema',
"pyxb.bundles"
]
"pyxb",
"pyxb.namespace",
"pyxb.binding",
"pyxb.utils",
"pyxb.xmlschema",
"pyxb.bundles",
]
package_data = {}

init_re = re.compile('^__init__\.py$')
wxs_re = re.compile('^.*\.wxs$')
init_re = re.compile("^__init__\.py$")
wxs_re = re.compile("^.*\.wxs$")

setup_path = os.path.dirname(__file__)
bundle_base = os.path.join(setup_path, 'pyxb', 'bundles')
bundle_base = os.path.join(setup_path, "pyxb", "bundles")
possible_bundles = []
try:
possible_bundles.extend(os.listdir(bundle_base))
Expand All @@ -192,38 +220,45 @@ def run (self):
if not os.path.isdir(bundle_root):
continue
b_packages = []
b_data = { }
for fp in pyxb.utils.utility.GetMatchingFiles('%s//' % (bundle_root,), init_re):
b_data = {}
for fp in pyxb.utils.utility.GetMatchingFiles("%s//" % (bundle_root,), init_re):
bundle_path = os.path.dirname(os.path.normpath(fp))
try:
package_relpath = os.path.relpath(bundle_path, setup_path)
except AttributeError as e:
package_relpath = bundle_path
if setup_path and '.' != setup_path:
if setup_path and "." != setup_path:
prefix_path = setup_path + os.path.sep
if not package_relpath.startswith(prefix_path):
print("Unable to determine relative path from %s to %s installation" % (setup_path, bundle_path))
print(
"Unable to determine relative path from %s to %s installation"
% (setup_path, bundle_path)
)
sys.exit(1)
package_relpath = package_relpath[len(prefix_path):]
package = package_relpath.replace(os.path.sep, '.')
package_relpath = package_relpath[len(prefix_path) :]
package = package_relpath.replace(os.path.sep, ".")
b_packages.append(package)
wxs_files = [os.path.basename(_f) for _f in pyxb.utils.utility.GetMatchingFiles(bundle_path, wxs_re) ]
wxs_files = [
os.path.basename(_f)
for _f in pyxb.utils.utility.GetMatchingFiles(bundle_path, wxs_re)
]
if wxs_files:
b_data[package] = wxs_files
if 0 < len(b_data):
print('Found bundle in %s' % (bundle_root,))
print("Found bundle in %s" % (bundle_root,))
packages.extend(b_packages)
package_data.update(b_data)

setup(name='PyXB-X',
description = 'PyXB-X ("pixbix") is a pure Python package that generates Python source code for classes that correspond to data structures defined by XMLSchema.',
author='Peter A. Bigot',
author_email='pabigot@users.sourceforge.net',
url='http://pyxb.sourceforge.net',
# Also change in README.TXT, pyxb/__init__.py, and doc/conf.py
version=version,
license='Apache License 2.0',
long_description='''PyXB is a pure `Python <http://www.python.org>`_ package that generates
setup(
name="PyXB-X",
description='PyXB-X ("pixbix") is a pure Python package that generates Python source code for classes that correspond to data structures defined by XMLSchema.',
author="Peter A. Bigot",
author_email="pabigot@users.sourceforge.net",
url="http://pyxb.sourceforge.net",
# Also change in README.TXT, pyxb/__init__.py, and doc/conf.py
version=version,
license="Apache License 2.0",
long_description="""PyXB is a pure `Python <http://www.python.org>`_ package that generates
Python code for classes that correspond to data structures defined by
`XMLSchema <http://www.w3.org/XML/Schema>`_. In concept it is similar to
`JAXB <http://en.wikipedia.org/wiki/JAXB>`_ for Java and `CodeSynthesis XSD
Expand Down Expand Up @@ -251,28 +286,30 @@ def run (self):
+ cross-namespace dependencies
+ include and import directives
+ constraints on simple types
''',
provides=[ 'PyXB' ],
packages=packages,
package_data=package_data,
# I normally keep these in $purelib, but distutils won't tell me where that is.
# We don't need them in the installation anyway.
#data_files= [ ('pyxb/standard/schemas', glob.glob(os.path.join(*'pyxb/standard/schemas/*.xsd'.split('/'))) ) ],
scripts=[ 'scripts/pyxbgen', 'scripts/pyxbwsdl', 'scripts/pyxbdump' ],
cmdclass = { 'test' : test,
'update_version' : update_version },
classifiers = [ 'Development Status :: 5 - Production/Stable'
, 'Intended Audience :: Developers'
, 'License :: OSI Approved :: Apache Software License'
, 'Topic :: Software Development :: Code Generators'
, 'Topic :: Text Processing :: Markup :: XML'
, 'Programming Language :: Python :: 2'
, 'Programming Language :: Python :: 2.6'
, 'Programming Language :: Python :: 2.7'
, 'Programming Language :: Python :: 3'
# Skip 3.0 because it doesn't know how to be built with hashlib support
, 'Programming Language :: Python :: 3.1'
, 'Programming Language :: Python :: 3.2'
, 'Programming Language :: Python :: 3.3'
, 'Programming Language :: Python :: 3.4'
] )
""",
provides=["PyXB"],
packages=packages,
package_data=package_data,
# I normally keep these in $purelib, but distutils won't tell me where that is.
# We don't need them in the installation anyway.
# data_files= [ ('pyxb/standard/schemas', glob.glob(os.path.join(*'pyxb/standard/schemas/*.xsd'.split('/'))) ) ],
scripts=["scripts/pyxbgen", "scripts/pyxbwsdl", "scripts/pyxbdump"],
cmdclass={"test": test, "update_version": update_version},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Topic :: Software Development :: Code Generators",
"Topic :: Text Processing :: Markup :: XML",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3"
# Skip 3.0 because it doesn't know how to be built with hashlib support
,
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
],
)

0 comments on commit 5f94917

Please sign in to comment.