From cbdd64fd4af267f607db44d3b2dbe7a6566b4dd1 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 11:33:08 +0100 Subject: [PATCH 01/33] MAINT: Switch version manager and upgrade black Upgrade black to 22.3 Switch to setuptools-scm from versioneer --- MANIFEST.in | 1 - ci/azure/azure_template_posix.yml | 2 + doc/source/custom-bit-generators.ipynb | 69 +- pyproject.toml | 12 +- randomgen/__init__.py | 5 +- randomgen/_version.py | 555 ----- randomgen/tests/data/compute_hashes.py | 2 +- randomgen/tests/test_against_numpy.py | 2 +- randomgen/tests/test_common.py | 10 +- randomgen/tests/test_direct.py | 132 +- randomgen/tests/test_extended_generator.py | 2 +- randomgen/tests/test_final_release_changes.py | 4 +- randomgen/tests/test_generator_mt19937.py | 22 +- .../test_generator_mt19937_regressions.py | 2 +- randomgen/tests/test_lcg128mix_pcg64dxsm.py | 4 +- randomgen/tests/test_randomstate.py | 8 +- .../tests/test_randomstate_regression.py | 10 +- randomgen/tests/test_recent_numpy_changes.py | 6 +- randomgen/tests/test_smoke.py | 106 +- randomgen/tests/test_wrapper.py | 18 +- randomgen/tests/test_wrapper_numba.py | 8 +- requirements-dev.txt | 4 +- setup.cfg | 8 - setup.py | 4 - versioneer.py | 1886 ----------------- 25 files changed, 227 insertions(+), 2655 deletions(-) delete mode 100644 randomgen/_version.py delete mode 100644 versioneer.py diff --git a/MANIFEST.in b/MANIFEST.in index 9c243e4ff..25ab3f662 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ recursive-exclude randomgen *.c -include versioneer.py include randomgen/_version.py include requirements.txt include README.md diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index 2e6d313e2..d6ebef712 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -28,6 +28,8 @@ jobs: NUMPY: 1.16.6 python39_latest: python.version: '3.9' + python310_latest: + python.version: '3.10' python36_latest: python.version: '3.6' python38_mid_conda: diff --git a/doc/source/custom-bit-generators.ipynb b/doc/source/custom-bit-generators.ipynb index ae6e73e52..29dea4457 100644 --- a/doc/source/custom-bit-generators.ipynb +++ b/doc/source/custom-bit-generators.ipynb @@ -78,7 +78,7 @@ "class PythonPCG64:\n", " # A 128 bit multiplier\n", " PCG_DEFAULT_MULTIPLIER = (2549297995355413924 << 64) + 4865540595714422341\n", - " MODULUS = 2 ** 128\n", + " MODULUS = 2**128\n", "\n", " def __init__(self, state, inc):\n", " \"\"\"Directly set the state and increment, no seed support\"\"\"\n", @@ -104,9 +104,10 @@ " a closure than to wrap the state in an array, pass it's address as a\n", " ctypes void pointer, and then to get the pointer in the function.\n", " \"\"\"\n", + "\n", " def _next_64(void_p):\n", " return self.random_raw()\n", - " \n", + "\n", " self._next_64 = _next_64\n", " return _next_64\n", "\n", @@ -117,6 +118,7 @@ " ``next_64`` except that it return a 32-bit unsigned int. Here we save\n", " half of the raw 64 bit output for subsequent calls.\n", " \"\"\"\n", + "\n", " def _next_32(void_p):\n", " if self._has_uint32:\n", " self._has_uint32 = False\n", @@ -128,11 +130,12 @@ "\n", " self._next_32 = _next_32\n", " return _next_32\n", - " \n", + "\n", " @property\n", " def state_getter(self):\n", " def f():\n", " return {\"state\": self.state, \"inc\": self.inc}\n", + "\n", " return f\n", "\n", " @property\n", @@ -140,7 +143,8 @@ " def f(value):\n", " self.state = value[\"state\"]\n", " self.inc = value[\"inc\"]\n", - " return f\n" + "\n", + " return f" ] }, { @@ -239,6 +243,7 @@ ], "source": [ "from numpy.random import Generator\n", + "\n", "gen = Generator(python_pcg)\n", "print(f\"Before: {prng.state}\")\n", "print(f\"Std. Normal : {gen.standard_normal()}\")\n", @@ -282,7 +287,13 @@ } ], "source": [ - "python_pcg = UserBitGenerator(prng.next_64, 64, next_32=prng.next_32, state_getter=prng.state_getter, state_setter=prng.state_setter)\n", + "python_pcg = UserBitGenerator(\n", + " prng.next_64,\n", + " 64,\n", + " next_32=prng.next_32,\n", + " state_getter=prng.state_getter,\n", + " state_setter=prng.state_setter,\n", + ")\n", "python_pcg.state" ] }, @@ -356,17 +367,20 @@ "\n", "rotate64_sig = types.uint64(types.uint64, types.int_)\n", "\n", + "\n", "@jit(signature_or_function=rotate64_sig, inline=\"always\")\n", "def rotate64(x, k):\n", - " return (x << k) | (x >> (64 - k));\n", + " return (x << k) | (x >> (64 - k))\n", + "\n", "\n", "jsf_next_sig = types.uint64(types.uint64[:])\n", "\n", + "\n", "@jit(signature_or_function=jsf_next_sig, inline=\"always\")\n", "def jsf_next(state):\n", " \"\"\"\n", " Update the state in place\n", - " \n", + "\n", " This is a literal translation of the C code where the value p, q,\n", " and r are fixed.\n", " \"\"\"\n", @@ -375,17 +389,17 @@ " q = 13\n", " r = 37\n", " # Update\n", - " e = state[0] - rotate64(state[1], p);\n", - " state[0] = state[1] ^ rotate64(state[2], q);\n", - " state[1] = state[2] + (rotate64(state[3], r) if r else state[3]);\n", - " state[2] = state[3] + e;\n", - " state[3] = e + state[0];\n", - " return state[3];\n", + " e = state[0] - rotate64(state[1], p)\n", + " state[0] = state[1] ^ rotate64(state[2], q)\n", + " state[1] = state[2] + (rotate64(state[3], r) if r else state[3])\n", + " state[2] = state[3] + e\n", + " state[3] = e + state[0]\n", + " return state[3]\n", "\n", "\n", "class NumbaJSF:\n", " def __init__(self, seed):\n", - " if not isinstance(seed, (int, np.integer)) or not (0 <= state < 2 ** 64):\n", + " if not isinstance(seed, (int, np.integer)) or not (0 <= state < 2**64):\n", " raise ValueError(\"seed must be a valid uint64\")\n", " # state[0:4] is the JSF state\n", " # state[4] contains both the has_uint flag in bit 0\n", @@ -398,13 +412,13 @@ " self.seed(seed)\n", "\n", " def seed(self, value):\n", - " self._state[0] = 0xf1ea5eed;\n", - " self._state[1] = value;\n", - " self._state[2] = value;\n", - " self._state[3] = value;\n", + " self._state[0] = 0xF1EA5EED\n", + " self._state[1] = value\n", + " self._state[2] = value\n", + " self._state[3] = value\n", " for i in range(20):\n", " jsf_next(self._state)\n", - " \n", + "\n", " @property\n", " def state_address(self):\n", " \"\"\"Get the location in memory of the state NumPy array.\"\"\"\n", @@ -485,6 +499,7 @@ " @property\n", " def state_getter(self):\n", " \"\"\"A function that returns the state. This is Python and is not decorated\"\"\"\n", + "\n", " def f() -> dict:\n", " return {\n", " \"bit_gen\": type(self).__name__,\n", @@ -498,6 +513,7 @@ " @property\n", " def state_setter(self):\n", " \"\"\"A function that sets the state. This is Python and is not decorated\"\"\"\n", + "\n", " def f(value: dict):\n", " name = value.get(\"bit_gen\", None)\n", " if name != type(self).__name__:\n", @@ -547,7 +563,9 @@ ], "source": [ "# From random.org\n", - "state = np.array([0x77, 0x5e, 0xb7, 0x11, 0x14, 0x3f, 0xd1, 0x0e], dtype=np.uint8).view(np.uint64)[0]\n", + "state = np.array([0x77, 0x5E, 0xB7, 0x11, 0x14, 0x3F, 0xD1, 0x0E], dtype=np.uint8).view(\n", + " np.uint64\n", + ")[0]\n", "njsf = NumbaJSF(state)\n", "njsf.state_getter()" ] @@ -585,8 +603,15 @@ } ], "source": [ - "jsf_ubg = UserBitGenerator.from_cfunc(njsf.next_raw, njsf.next_64, njsf.next_32, njsf.next_double, njsf.state_address, \n", - " state_getter=njsf.state_getter, state_setter=njsf.state_setter)\n", + "jsf_ubg = UserBitGenerator.from_cfunc(\n", + " njsf.next_raw,\n", + " njsf.next_64,\n", + " njsf.next_32,\n", + " njsf.next_double,\n", + " njsf.state_address,\n", + " state_getter=njsf.state_getter,\n", + " state_setter=njsf.state_setter,\n", + ")\n", "print(jsf_ubg.state)\n", "print(jsf_ubg.random_raw(2))\n", "print(jsf_ubg.state)" diff --git a/pyproject.toml b/pyproject.toml index fcca015eb..746b48084 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,11 @@ requires = [ "setuptools", "wheel", "Cython>=0.29.24,<3.0", - "numpy==1.16.6; python_version<='3.7'", - "numpy==1.17.5; python_version=='3.8'", - "numpy==1.19.5; python_version=='3.9'", - "numpy; python_version>='3.10'", - "numpy>=1.14" + "oldest-supported-numpy", + "numpy; python_version>='3.11'", + "setuptools_scm[toml]>=6.4.2,<7.0.0", ] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "randomgen/_version.py" diff --git a/randomgen/__init__.py b/randomgen/__init__.py index e5f6ac1a4..1d360c5c1 100644 --- a/randomgen/__init__.py +++ b/randomgen/__init__.py @@ -30,7 +30,7 @@ from randomgen.xoshiro256 import Xoshiro256 from randomgen.xoshiro512 import Xoshiro512 -from ._version import get_versions +from ._version import version as __version__, version_tuple as __version_info__ PKG_TESTS = os.path.join(os.path.dirname(__file__), "tests") @@ -69,9 +69,6 @@ "random_entropy", ] -__version__ = get_versions()["version"] -del get_versions - def test(extra_args: Union[str, List[str]] = None) -> None: try: diff --git a/randomgen/_version.py b/randomgen/_version.py deleted file mode 100644 index 2857e53a9..000000000 --- a/randomgen/_version.py +++ /dev/null @@ -1,555 +0,0 @@ -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys - - -def get_keywords(): - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "$Format:%d$" - git_full = "$Format:%H$" - git_date = "$Format:%ci$" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_config(): - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "pep440" - cfg.tag_prefix = "" - cfg.parentdir_prefix = "randomgen-" - cfg.versionfile_source = "randomgen/_version.py" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - - return decorate - - -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen( - [c] + args, - cwd=cwd, - env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr else None), - ) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return { - "version": dirname[len(parentdir_prefix) :], - "full-revisionid": None, - "dirty": False, - "error": None, - "date": None, - } - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "main". - tags = set([r for r in refs if re.search(r"\d", r)]) - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix) :] - if verbose: - print("picking %s" % r) - return { - "version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": None, - "date": date, - } - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return { - "version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": "no suitable tags", - "date": None, - } - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command( - GITS, - [ - "describe", - "--tags", - "--dirty", - "--always", - "--long", - "--match", - "%s*" % tag_prefix, - ], - cwd=root, - ) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[: git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( - full_tag, - tag_prefix, - ) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix) :] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ - 0 - ].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return { - "version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None, - } - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return { - "version": rendered, - "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], - "error": None, - "date": pieces.get("date"), - } - - -def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split("/"): - root = os.path.dirname(root) - except NameError: - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None, - } - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", - "date": None, - } diff --git a/randomgen/tests/data/compute_hashes.py b/randomgen/tests/data/compute_hashes.py index f9544bcc1..f0ac67fd7 100644 --- a/randomgen/tests/data/compute_hashes.py +++ b/randomgen/tests/data/compute_hashes.py @@ -71,7 +71,7 @@ def fix_random_123(name, kwargs): def int_to_array(int_val): arr_data = [] while int_val > 0: - arr_data.append(int_val % (2 ** 24)) + arr_data.append(int_val % (2**24)) int_val >>= 64 return np.array(arr_data, dtype=np.uint64) diff --git a/randomgen/tests/test_against_numpy.py b/randomgen/tests/test_against_numpy.py index d16a3e47c..b3ba37699 100644 --- a/randomgen/tests/test_against_numpy.py +++ b/randomgen/tests/test_against_numpy.py @@ -122,7 +122,7 @@ class TestAgainstNumPy(object): def setup_class(cls): cls.np = numpy.random cls.bit_generator = MT19937 - cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.rs = RandomState(cls.bit_generator(*cls.seed, mode="legacy")) cls.nprs = cls.np.RandomState(*cls.seed) diff --git a/randomgen/tests/test_common.py b/randomgen/tests/test_common.py index 580d6c88f..3d04404aa 100644 --- a/randomgen/tests/test_common.py +++ b/randomgen/tests/test_common.py @@ -10,7 +10,7 @@ def test_view_little_endian(): - a = np.uint64([2 ** 63]) + a = np.uint64([2**63]) b = view_little_endian_shim(a, np.uint32) expected = np.array([0, 2147483648], dtype=np.uint32) np.testing.assert_equal(b, expected) @@ -20,13 +20,13 @@ def test_view_little_endian(): def test_view_little_endian_err(): - a = np.double([2 ** 51]) + a = np.double([2**51]) with pytest.raises(ValueError): view_little_endian_shim(a, np.uint32) - a = np.uint64([2 ** 63]) + a = np.uint64([2**63]) with pytest.raises(ValueError): view_little_endian_shim(a, np.uint16) - a = np.array([[2 ** 63]], np.uint64) + a = np.array([[2**63]], np.uint64) with pytest.raises(ValueError): view_little_endian_shim(a, np.uint32) @@ -39,7 +39,7 @@ def test_int_to_array(): seed = 0 for pow in (255, 129, 93, 65, 63, 33, 1, 0): - seed += 2 ** pow + seed += 2**pow result = int_to_array_shim(seed, "seed", None, 64) expected = np.array( [9223372045444710403, 536870914, 2, 9223372036854775808], dtype=np.uint64 diff --git a/randomgen/tests/test_direct.py b/randomgen/tests/test_direct.py index 874b47a50..a378f334f 100644 --- a/randomgen/tests/test_direct.py +++ b/randomgen/tests/test_direct.py @@ -122,19 +122,19 @@ def uniform32_from_uint64(x): lower = np.uint64(0xFFFFFFFF) lower = np.array(x & lower, dtype=np.uint32) joined = np.column_stack([lower, upper]).ravel() - out = (joined >> np.uint32(9)) * (1.0 / 2 ** 23) + out = (joined >> np.uint32(9)) * (1.0 / 2**23) return out.astype(np.float32) def uniform32_from_uint53(x): x = np.uint64(x) >> np.uint64(16) x = np.uint32(x & np.uint64(0xFFFFFFFF)) - out = (x >> np.uint32(9)) * (1.0 / 2 ** 23) + out = (x >> np.uint32(9)) * (1.0 / 2**23) return out.astype(np.float32) def uniform32_from_uint32(x): - return (x >> np.uint32(9)) * (1.0 / 2 ** 23) + return (x >> np.uint32(9)) * (1.0 / 2**23) def uniform32_from_uint(x, bits): @@ -424,7 +424,7 @@ def test_getstate(self): def test_uinteger_reset_seed(self): bg = self.setup_bitgenerator([None]) g = Generator(bg) - g.integers(0, 2 ** 32, dtype=np.uint32) + g.integers(0, 2**32, dtype=np.uint32) if "has_uint32" not in bg.state or bg.state["has_uint32"] == 0: name = bg.__class__.__name__ pytest.skip("bit generator does not cache 32-bit value ({0})".format(name)) @@ -436,14 +436,14 @@ def test_uinteger_reset_jump(self): if not hasattr(bg, "jumped"): pytest.skip("bit generator does not support jumping") g = Generator(bg) - g.integers(0, 2 ** 32, dtype=np.uint32) + g.integers(0, 2**32, dtype=np.uint32) jumped = Generator(bg.jumped()) if "has_uint32" in jumped.bit_generator.state: assert jumped.bit_generator.state["has_uint32"] == 0 return # This next test could fail with prob 1 in 2**32 - next_g = g.integers(0, 2 ** 32, dtype=np.uint32) - next_jumped = jumped.integers(0, 2 ** 32, dtype=np.uint32) + next_g = g.integers(0, 2**32, dtype=np.uint32) + next_jumped = jumped.integers(0, 2**32, dtype=np.uint32) assert next_g != next_jumped def test_uinteger_reset_advance(self): @@ -451,7 +451,7 @@ def test_uinteger_reset_advance(self): if not hasattr(bg, "advance"): pytest.skip("bit generator does not support advancing") g = Generator(bg) - g.integers(0, 2 ** 32, dtype=np.uint32) + g.integers(0, 2**32, dtype=np.uint32) state = bg.state if isinstance(bg, (Philox, ThreeFry)): bg.advance(1000, False) @@ -461,9 +461,9 @@ def test_uinteger_reset_advance(self): assert bg.state["has_uint32"] == 0 return # This next test could fail with prob 1 in 2**32 - next_advanced = g.integers(0, 2 ** 32, dtype=np.uint32) + next_advanced = g.integers(0, 2**32, dtype=np.uint32) bg.state = state - next_g = g.integers(0, 2 ** 32, dtype=np.uint32) + next_g = g.integers(0, 2**32, dtype=np.uint32) assert next_g != next_advanced def test_seed_sequence(self): @@ -529,13 +529,13 @@ def test_advance(self, step, counter_only, warmup): def test_advance_large(self): dtype = np.uint64 if self.width == 64 else np.uint32 bg = self.bit_generator(mode="legacy") - step = 2 ** self.width + step = 2**self.width bg.advance(step, True) state = bg.state assert_equal(state["state"]["counter"], np.array([0, 1, 0, 0], dtype=dtype)) bg = self.bit_generator(mode="sequence") - step = 2 ** self.width - 1 + step = 2**self.width - 1 bg.advance(step, True) state = bg.state size_max = np.iinfo(dtype).max @@ -751,8 +751,8 @@ def setup_class(cls): cls.invalid_seed_values = [ (1, None, 1), (-1,), - (2 ** 257 + 1,), - (None, None, 2 ** 257 + 1), + (2**257 + 1,), + (None, None, 2**257 + 1), ] def test_set_key(self): @@ -774,12 +774,12 @@ def test_advance(self): assert_equal( bg.state["state"]["counter"], np.array([2, 0, 0, 0], dtype=np.uint64) ) - bg.advance(2 ** 64, True) + bg.advance(2**64, True) assert_equal( bg.state["state"]["counter"], np.array([2, 1, 0, 0], dtype=np.uint64) ) bg.state = state0 - bg.advance(2 ** 128, True) + bg.advance(2**128, True) assert_equal( bg.state["state"]["counter"], np.array([0, 0, 1, 0], dtype=np.uint64) ) @@ -800,7 +800,7 @@ def setup_class(cls): cls.invalid_seed_types = [(np.array([1, 2]),), (3.2,)] cls.invalid_seed_values = [ (-2,), - (2 ** 129 + 1,), + (2**129 + 1,), ] cls.large_advance_initial = 141078743063826365544432622475512570578 cls.large_advance_final = 32639015182640331666105117402520879107 @@ -833,10 +833,10 @@ def test_advance_symmetry(self): rs.bit_generator.advance(step) val_neg = rs.integers(10) rs.bit_generator.state = state - rs.bit_generator.advance(2 ** 128 + step) + rs.bit_generator.advance(2**128 + step) val_pos = rs.integers(10) rs.bit_generator.state = state - rs.bit_generator.advance(10 * 2 ** 128 + step) + rs.bit_generator.advance(10 * 2**128 + step) val_big = rs.integers(10) assert val_neg == val_pos assert val_big == val_pos @@ -867,7 +867,7 @@ def test_large_advance(self): bg = self.setup_bitgenerator([0], inc=1) state = bg.state["state"] assert state["state"] == self.large_advance_initial - bg.advance(sum(2 ** i for i in range(96))) + bg.advance(sum(2**i for i in range(96))) state = bg.state["state"] assert state["state"] == self.large_advance_final @@ -888,8 +888,8 @@ def setup_class(cls): cls.invalid_seed_values = [ (1, None, 1), (-1,), - (2 ** 257 + 1,), - (None, None, 2 ** 257 + 1), + (2**257 + 1,), + (None, None, 2**257 + 1), ] def test_set_key(self): @@ -928,8 +928,8 @@ def setup_class(cls): cls.invalid_seed_values = [ (1, None, 1), (-1,), - (2 ** 257 + 1,), - (None, None, 2 ** 257 + 1), + (2**257 + 1,), + (None, None, 2**257 + 1), ] def test_seed_sequence(self): @@ -972,8 +972,8 @@ def setup_class(cls): cls.invalid_seed_values = [ (1, None, 1), (-1,), - (2 ** 257 + 1,), - (None, None, 2 ** 257 + 1), + (2**257 + 1,), + (None, None, 2**257 + 1), ] @pytest.fixture(autouse=True, params=USE_AESNI) @@ -989,7 +989,7 @@ def test_set_key(self): bit_generator = self.setup_bitgenerator(self.data1["seed"]) state = bit_generator.state key = state["s"]["seed"][:2] - key = int(key[0]) + int(key[1]) * 2 ** 64 + key = int(key[0]) + int(key[1]) * 2**64 counter = state["s"]["counter"][0] keyed = self.bit_generator(counter=counter, key=key, mode="legacy") assert_state_equal(bit_generator.state, keyed.state) @@ -1041,7 +1041,7 @@ def test_advance_one_repeat(self): def test_advance_large(self): bg = self.bit_generator(mode="legacy") - step = 2 ** 65 + step = 2**65 bg.advance(step) state = bg.state assert_equal( @@ -1049,7 +1049,7 @@ def test_advance_large(self): ) bg = self.bit_generator(mode="sequence") - step = 2 ** 65 - 7 + step = 2**65 - 7 bg.advance(step) state = bg.state assert_equal( @@ -1057,7 +1057,7 @@ def test_advance_large(self): ) bg = self.bit_generator(mode="sequence") - step = 2 ** 129 - 16 + step = 2**129 - 16 bg.advance(step) state = bg.state m = np.iinfo(np.uint64).max @@ -1073,7 +1073,7 @@ def test_advance_large(self): bg = self.bit_generator(mode="sequence") state0 = bg.state - step = 2 ** 129 + step = 2**129 bg.advance(step) state = bg.state assert_state_equal(state0, state) @@ -1098,7 +1098,7 @@ def test_seed_key(self): def test_large_counter(self): # GH 267 - bg = self.bit_generator(counter=2 ** 128 - 2, mode="sequence") + bg = self.bit_generator(counter=2**128 - 2, mode="sequence") state = bg.state assert_equal( state["s"]["counter"][-4:], np.array([0, 0, 1, 0], dtype=np.uint64) @@ -1117,7 +1117,7 @@ def setup_class(cls): cls.data2 = cls._read_csv(join(pwd, "./data/mt19937-testset-2.csv")) cls.seed_error_type = ValueError cls.invalid_seed_types = [] - cls.invalid_seed_values = [(-1,), (np.array([2 ** 33]),)] + cls.invalid_seed_values = [(-1,), (np.array([2**33]),)] cls.state_name = "key" def test_seed_out_of_range(self): @@ -1155,14 +1155,14 @@ def test_state_tuple(self): rs = Generator(self.setup_bitgenerator(self.data1["seed"])) bit_generator = rs.bit_generator state = bit_generator.state - desired = rs.integers(2 ** 16) + desired = rs.integers(2**16) tup = (state["bit_generator"], state["state"]["key"], state["state"]["pos"]) bit_generator.state = tup - actual = rs.integers(2 ** 16) + actual = rs.integers(2**16) assert_equal(actual, desired) tup = tup + (0, 0.0) bit_generator.state = tup - actual = rs.integers(2 ** 16) + actual = rs.integers(2**16) assert_equal(actual, desired) def test_invalid_state(self): @@ -1197,8 +1197,8 @@ def setup_class(cls): cls.invalid_seed_types = [] cls.invalid_seed_values = [ (-1,), - (np.array([2 ** 33]),), - (np.array([2 ** 33, 2 ** 33]),), + (np.array([2**33]),), + (np.array([2**33, 2**33]),), ] cls.state_name = "state" @@ -1224,8 +1224,8 @@ def setup_class(cls): cls.invalid_seed_types = [] cls.invalid_seed_values = [ (-1,), - (np.array([2 ** 33]),), - (np.array([2 ** 33, 2 ** 33]),), + (np.array([2**33]),), + (np.array([2**33, 2**33]),), ] def test_uniform_double(self): @@ -1311,8 +1311,8 @@ def setup_class(cls): cls.invalid_seed_values = [ (1, None, 1), (-1,), - (2 ** 257 + 1,), - (None, None, 2 ** 129 + 1), + (2**257 + 1,), + (None, None, 2**129 + 1), ] def test_seed_sequence(self): @@ -1360,9 +1360,9 @@ def setup_class(cls): cls.invalid_seed_types = [(np.array([1, 2]),), (3.2,), (None, np.zeros(1))] cls.invalid_seed_values = [ (-1,), - (2 ** 129 + 1,), + (2**129 + 1,), (None, -1), - (None, 2 ** 129 + 1), + (None, 2**129 + 1), ] cls.large_advance_initial = 645664597830827402 cls.large_advance_final = 3 @@ -1377,10 +1377,10 @@ def test_advance_symmetry(self): rs.bit_generator.advance(step) val_neg = rs.integers(10) rs.bit_generator.state = state - rs.bit_generator.advance(2 ** 64 + step) + rs.bit_generator.advance(2**64 + step) val_pos = rs.integers(10) rs.bit_generator.state = state - rs.bit_generator.advance(10 * 2 ** 64 + step) + rs.bit_generator.advance(10 * 2**64 + step) val_big = rs.integers(10) assert val_neg == val_pos assert val_big == val_pos @@ -1398,7 +1398,7 @@ def setup_class(cls): cls.seed_error_type = TypeError cls.seed_error_type = ValueError cls.invalid_seed_types = [] - cls.invalid_seed_values = [(-1,), (np.array([2 ** 65]),)] + cls.invalid_seed_values = [(-1,), (np.array([2**65]),)] def test_seed_float_array(self): # GH #82 @@ -1441,7 +1441,7 @@ def test_initialization(self): assert state["retries"] == 10 assert state["status"] == 1 gen = Generator(bit_generator) - gen.integers(0, 2 ** 64, dtype=np.uint64, size=10) + gen.integers(0, 2**64, dtype=np.uint64, size=10) state = bit_generator.state # Incredibly conservative test assert (state["buffer"] == np.iinfo(np.uint64).max).sum() < 10 @@ -1459,7 +1459,7 @@ def test_generator_raises(self): bit_generator.state = state gen = Generator(bit_generator) with pytest.raises(RuntimeError): - gen.integers(0, 2 ** 64, dtype=np.uint64, size=10) + gen.integers(0, 2**64, dtype=np.uint64, size=10) assert bit_generator.state["status"] == 0 bit_generator._reset() state = bit_generator.state @@ -1579,14 +1579,14 @@ def setup_class(cls): cls.data1 = cls._read_csv(join(pwd, "./data/chacha-testset-1.csv")) cls.data2 = cls._read_csv(join(pwd, "./data/chacha-testset-2.csv")) cls.seed_error_type = TypeError - cls.invalid_seed_types = [(np.array([2 ** 65]),)] - cls.invalid_seed_values = [(-1,), [2 ** 257]] + cls.invalid_seed_types = [(np.array([2**65]),)] + cls.invalid_seed_values = [(-1,), [2**257]] cls.state_name = "key" def setup_bitgenerator(self, seed, mode="legacy", **kwargs): - stream = 3735928559 * 2 ** 64 + 3735928559 * 2 ** 96 + stream = 3735928559 * 2**64 + 3735928559 * 2**96 seed = [0] if None in seed else seed - key = seed[0] + stream + 2 ** 128 * stream + key = seed[0] + stream + 2**128 * stream if mode == "legacy": bg = self.bit_generator(key=key, counter=0, mode=mode) else: @@ -1630,20 +1630,20 @@ def test_advance_one_repeat(self): def test_advance_large(self): bg = self.bit_generator(mode="legacy") - step = 2 ** 64 + step = 2**64 bg.advance(step) state = bg.state assert_equal(state["state"]["ctr"], np.array([0, 1], dtype=np.uint64)) bg = self.bit_generator(mode="sequence") - step = 2 ** 64 - 1 + step = 2**64 - 1 bg.advance(step) state = bg.state u64_max = np.iinfo(np.uint64).max assert_equal(state["state"]["ctr"], np.array([u64_max, 0], dtype=np.uint64)) bg = self.bit_generator(mode="sequence") - step = 2 ** 128 - 16 + step = 2**128 - 16 bg.advance(step) state = bg.state assert_equal( @@ -1651,7 +1651,7 @@ def test_advance_large(self): ) bg = self.bit_generator(mode="sequence") - step = 2 ** 128 - 1 + step = 2**128 - 1 bg.advance(step) state = bg.state assert_equal( @@ -1663,7 +1663,7 @@ def test_advance_large(self): bg = self.bit_generator(mode="sequence") state0 = bg.state - step = 2 ** 128 + step = 2**128 bg.advance(step) state = bg.state assert_state_equal(state0, state) @@ -1729,7 +1729,7 @@ def test_key_init(self): with pytest.raises(ValueError): self.bit_generator(key=-1, mode="legacy") with pytest.raises(ValueError): - self.bit_generator(key=2 ** 256, mode="legacy") + self.bit_generator(key=2**256, mode="legacy") with pytest.raises(ValueError): self.bit_generator(seed=1, key=1, mode="legacy") @@ -1756,7 +1756,7 @@ def setup_class(cls): def test_seed_out_of_range(self): # GH #82 rs = Generator(self.setup_bitgenerator(self.data1["seed"])) - assert_raises(ValueError, rs.bit_generator.seed, 2 ** 257) + assert_raises(ValueError, rs.bit_generator.seed, 2**257) assert_raises(ValueError, rs.bit_generator.seed, -1) def test_invalid_seed_type(self): @@ -1769,7 +1769,7 @@ def test_key_init(self): with pytest.raises(ValueError): self.bit_generator(key=-1, mode="legacy") with pytest.raises(ValueError): - self.bit_generator(key=2 ** 256, mode="legacy") + self.bit_generator(key=2**256, mode="legacy") with pytest.raises(ValueError): self.bit_generator(seed=1, key=1, mode="legacy") @@ -1803,7 +1803,7 @@ def test_advance_one_repeat(self): def test_advance_large(self): bg = self.bit_generator(mode="legacy") - step = 2 ** 65 + step = 2**65 bg.advance(step) state = bg.state assert_equal( @@ -1812,7 +1812,7 @@ def test_advance_large(self): ) bg = self.bit_generator(mode="sequence") - step = 2 ** 65 - 11 + step = 2**65 - 11 bg.advance(step) state = bg.state assert_equal( @@ -1821,7 +1821,7 @@ def test_advance_large(self): ) bg = self.bit_generator(mode="sequence") - step = 2 ** 129 - 24 + step = 2**129 - 24 bg.advance(step) state = bg.state m = np.iinfo(np.uint64).max @@ -1841,7 +1841,7 @@ def test_advance_large(self): bg = self.bit_generator(mode="sequence") state0 = bg.state - step = 2 ** 129 + step = 2**129 bg.advance(step) state = bg.state assert_state_equal(state0, state) @@ -1970,7 +1970,7 @@ def test_large_advance(self): bg = self.setup_bitgenerator([0], inc=1) state = bg.state["state"] assert state["state"] == self.large_advance_initial - bg.advance(sum(2 ** i for i in range(96))) + bg.advance(sum(2**i for i in range(96))) state = bg.state["state"] assert state["state"] == self.large_advance_final diff --git a/randomgen/tests/test_extended_generator.py b/randomgen/tests/test_extended_generator.py index b0c0856d8..a8d66f068 100644 --- a/randomgen/tests/test_extended_generator.py +++ b/randomgen/tests/test_extended_generator.py @@ -545,7 +545,7 @@ def test_standard_wishart_direct_large(extended_gen): n = gen.standard_normal() v22 = gen.chisquare(2) direct[0, 0] = v11 - direct[1, 1] = n ** 2 + v22 + direct[1, 1] = n**2 + v22 direct[1, 0] = direct[0, 1] = n * np.sqrt(v11) assert_allclose(direct, w[i]) diff --git a/randomgen/tests/test_final_release_changes.py b/randomgen/tests/test_final_release_changes.py index 37435c634..a3974fc91 100644 --- a/randomgen/tests/test_final_release_changes.py +++ b/randomgen/tests/test_final_release_changes.py @@ -80,6 +80,6 @@ def test_integers_use_masked(): def test_integers_large_negative_value(): with pytest.raises(ValueError): - random_gen.integers(0, -(2 ** 65), endpoint=endpoint) + random_gen.integers(0, -(2**65), endpoint=endpoint) with pytest.raises(ValueError): - random_gen.integers(0, [-(2 ** 65)], endpoint=endpoint) + random_gen.integers(0, [-(2**65)], endpoint=endpoint) diff --git a/randomgen/tests/test_generator_mt19937.py b/randomgen/tests/test_generator_mt19937.py index 1b6b32b6b..99a1aab59 100644 --- a/randomgen/tests/test_generator_mt19937.py +++ b/randomgen/tests/test_generator_mt19937.py @@ -385,12 +385,12 @@ def test_in_bounds_fuzz(self, endpoint): for dt in self.itype[1:]: for ubnd in [4, 8, 16]: vals = self.rfunc( - 2, ubnd - endpoint, size=2 ** 16, endpoint=endpoint, dtype=dt + 2, ubnd - endpoint, size=2**16, endpoint=endpoint, dtype=dt ) assert_(vals.max() < ubnd) assert_(vals.min() >= 2) - vals = self.rfunc(0, 2 - endpoint, size=2 ** 16, endpoint=endpoint, dtype=bool) + vals = self.rfunc(0, 2 - endpoint, size=2**16, endpoint=endpoint, dtype=bool) assert_(vals.max() < 2) assert_(vals.min() >= 0) @@ -513,19 +513,19 @@ def test_repeatability_32bit_boundary_broadcasting(self): for size in [None, (5, 3, 3)]: random = Generator(MT19937(12345, mode="sequence")) x = random.integers( - [[-1], [0], [1]], [2 ** 32 - 1, 2 ** 32, 2 ** 32 + 1], size=size + [[-1], [0], [1]], [2**32 - 1, 2**32, 2**32 + 1], size=size ) assert_array_equal(x, desired if size is not None else desired[0]) def test_int64_uint64_broadcast_exceptions(self, endpoint): configs = { - np.uint64: ((0, 2 ** 65), (-1, 2 ** 62), (10, 9), (0, 0)), + np.uint64: ((0, 2**65), (-1, 2**62), (10, 9), (0, 0)), np.int64: ( - (0, 2 ** 64), - (-(2 ** 64), 2 ** 62), + (0, 2**64), + (-(2**64), 2**62), (10, 9), (0, 0), - (-(2 ** 63) - 1, -(2 ** 63) - 1), + (-(2**63) - 1, -(2**63) - 1), ), } for dtype in configs: @@ -1900,7 +1900,7 @@ def test_vonmises(self): def test_vonmises_small(self): # check infinite loop, gh-4720 random.bit_generator.seed(self.seed) - r = random.vonmises(mu=0.0, kappa=1.1e-8, size=10 ** 6) + r = random.vonmises(mu=0.0, kappa=1.1e-8, size=10**6) assert_(np.isfinite(r).all()) def test_vonmises_nan(self): @@ -2534,9 +2534,9 @@ def test_hypergeometric(self): assert_raises(ValueError, hypergeom, 10, 10, 25) # ValueError for arguments that are too big. - assert_raises(ValueError, hypergeom, 2 ** 30, 10, 20) - assert_raises(ValueError, hypergeom, 999, 2 ** 31, 50) - assert_raises(ValueError, hypergeom, 999, [2 ** 29, 2 ** 30], 1000) + assert_raises(ValueError, hypergeom, 2**30, 10, 20) + assert_raises(ValueError, hypergeom, 999, 2**31, 50) + assert_raises(ValueError, hypergeom, 999, [2**29, 2**30], 1000) def test_logseries(self): p = [0.5] diff --git a/randomgen/tests/test_generator_mt19937_regressions.py b/randomgen/tests/test_generator_mt19937_regressions.py index c34f5695b..f2627a618 100644 --- a/randomgen/tests/test_generator_mt19937_regressions.py +++ b/randomgen/tests/test_generator_mt19937_regressions.py @@ -21,7 +21,7 @@ def test_hypergeometric_range(self): assert_(np.all(mt19937.hypergeometric(18, 3, 11, size=10) > 0)) # Test for ticket #5623 - args = (2 ** 20 - 2, 2 ** 20 - 2, 2 ** 20 - 2) # Check for 32-bit systems + args = (2**20 - 2, 2**20 - 2, 2**20 - 2) # Check for 32-bit systems assert_(mt19937.hypergeometric(*args) > 0) def test_logseries_convergence(self): diff --git a/randomgen/tests/test_lcg128mix_pcg64dxsm.py b/randomgen/tests/test_lcg128mix_pcg64dxsm.py index f13f92926..f8b3dd47d 100644 --- a/randomgen/tests/test_lcg128mix_pcg64dxsm.py +++ b/randomgen/tests/test_lcg128mix_pcg64dxsm.py @@ -199,8 +199,8 @@ def test_exceptions(): LCG128Mix(SEED, post=3) -@pytest.mark.parametrize("seed", [0, sum([2 ** i for i in range(1, 128, 2)])]) -@pytest.mark.parametrize("inc", [0, sum([2 ** i for i in range(0, 128, 3)])]) +@pytest.mark.parametrize("seed", [0, sum([2**i for i in range(1, 128, 2)])]) +@pytest.mark.parametrize("inc", [0, sum([2**i for i in range(0, 128, 3)])]) def test_equivalence_pcg64dxsm(seed, inc): a = PCG64(seed, inc, mode="sequence", variant="dxsm") b = PCG64DXSM(seed, inc) diff --git a/randomgen/tests/test_randomstate.py b/randomgen/tests/test_randomstate.py index 4e9be3ddb..258e05bb8 100644 --- a/randomgen/tests/test_randomstate.py +++ b/randomgen/tests/test_randomstate.py @@ -33,7 +33,7 @@ "zipf": (2,), } -if np.iinfo(int).max < 2 ** 32: +if np.iinfo(int).max < 2**32: # Windows and some 32-bit platforms, e.g., ARM INT_FUNC_HASHES = { "binomial": "670e1c04223ffdbab27e08fbbad7bdba", @@ -339,11 +339,11 @@ def test_in_bounds_fuzz(self): for dt in self.itype[1:]: for ubnd in [4, 8, 16]: - vals = self.rfunc(2, ubnd, size=2 ** 16, dtype=dt) + vals = self.rfunc(2, ubnd, size=2**16, dtype=dt) assert_(vals.max() < ubnd) assert_(vals.min() >= 2) - vals = self.rfunc(0, 2, size=2 ** 16, dtype=np.bool_) + vals = self.rfunc(0, 2, size=2**16, dtype=np.bool_) assert_(vals.max() < 2) assert_(vals.min() >= 0) @@ -1349,7 +1349,7 @@ def test_vonmises(self): def test_vonmises_small(self): # check infinite loop, gh-4720 random.seed(self.seed) - r = random.vonmises(mu=0.0, kappa=1.1e-8, size=10 ** 6) + r = random.vonmises(mu=0.0, kappa=1.1e-8, size=10**6) assert_(np.isfinite(r).all()) def test_vonmises_nan(self): diff --git a/randomgen/tests/test_randomstate_regression.py b/randomgen/tests/test_randomstate_regression.py index e57b3606c..eb19921a8 100644 --- a/randomgen/tests/test_randomstate_regression.py +++ b/randomgen/tests/test_randomstate_regression.py @@ -6,7 +6,7 @@ from randomgen import mtrand as random -HAS_32BIT_CLONG = np.iinfo("l").max < 2 ** 32 +HAS_32BIT_CLONG = np.iinfo("l").max < 2**32 class TestRegression(object): @@ -24,12 +24,12 @@ def test_hypergeometric_range(self): # Test for ticket #5623 args = [ - (2 ** 20 - 2, 2 ** 20 - 2, 2 ** 20 - 2), # Check for 32-bit systems + (2**20 - 2, 2**20 - 2, 2**20 - 2), # Check for 32-bit systems ] - is_64bits = sys.maxsize > 2 ** 32 + is_64bits = sys.maxsize > 2**32 if is_64bits and sys.platform != "win32": # Check for 64-bit systems - args.append((2 ** 40 - 2, 2 ** 40 - 2, 2 ** 40 - 2)) + args.append((2**40 - 2, 2**40 - 2, 2**40 - 2)) for arg in args: assert_(random.hypergeometric(*arg) > 0) @@ -178,5 +178,5 @@ def test_randint_117(self): ], dtype="int64", ) - actual = random.randint(2 ** 32, size=10) + actual = random.randint(2**32, size=10) assert_array_equal(actual, expected) diff --git a/randomgen/tests/test_recent_numpy_changes.py b/randomgen/tests/test_recent_numpy_changes.py index 0562e5295..38d1448da 100644 --- a/randomgen/tests/test_recent_numpy_changes.py +++ b/randomgen/tests/test_recent_numpy_changes.py @@ -28,7 +28,7 @@ def random(): "bound, expected", [ ( - 2 ** 32 - 1, + 2**32 - 1, np.array( [ 517043486, @@ -42,7 +42,7 @@ def random(): ), ), ( - 2 ** 32, + 2**32, np.array( [ 517043487, @@ -56,7 +56,7 @@ def random(): ), ), ( - 2 ** 32 + 1, + 2**32 + 1, np.array( [ 517043487, diff --git a/randomgen/tests/test_smoke.py b/randomgen/tests/test_smoke.py index 2ec17838d..c72241bb5 100644 --- a/randomgen/tests/test_smoke.py +++ b/randomgen/tests/test_smoke.py @@ -131,8 +131,8 @@ def warmup(rg, n=None): rg.standard_normal(n) rg.standard_normal(n, dtype=np.float32) rg.standard_normal(n, dtype=np.float32) - rg.integers(0, 2 ** 24, n, dtype=np.uint64) - rg.integers(0, 2 ** 48, n, dtype=np.uint64) + rg.integers(0, 2**24, n, dtype=np.uint64) + rg.integers(0, 2**48, n, dtype=np.uint64) rg.standard_gamma(11.0, n) rg.standard_gamma(11.0, n, dtype=np.float32) rg.random(n, dtype=np.float64) @@ -325,9 +325,9 @@ def test_binomial(self): def test_reset_state(self): state = self.rg.bit_generator.state - int_1 = self.rg.integers(2 ** 31) + int_1 = self.rg.integers(2**31) self.rg.bit_generator.state = state - int_2 = self.rg.integers(2 ** 31) + int_2 = self.rg.integers(2**31) assert_(int_1 == int_2) with pytest.raises(TypeError): self.rg.bit_generator.state = [(k, v) for k, v in state.items()] @@ -361,12 +361,12 @@ def test_reset_state_gauss(self): def test_reset_state_uint32(self): rg = self.init_generator(seed=self.seed, mode="legacy") - rg.integers(0, 2 ** 24, 120, dtype=np.uint32) + rg.integers(0, 2**24, 120, dtype=np.uint32) state = rg.bit_generator.state - n1 = rg.integers(0, 2 ** 24, 10, dtype=np.uint32) + n1 = rg.integers(0, 2**24, 10, dtype=np.uint32) rg2 = self.init_generator() rg2.bit_generator.state = state - n2 = rg2.integers(0, 2 ** 24, 10, dtype=np.uint32) + n2 = rg2.integers(0, 2**24, 10, dtype=np.uint32) assert_array_equal(n1, n2) def test_reset_state_float(self): @@ -394,16 +394,16 @@ def test_tomaxint(self): vals = self.rg.tomaxint(size=100000) maxsize = 0 if os.name == "nt": - maxsize = 2 ** 31 - 1 + maxsize = 2**31 - 1 else: try: maxsize = sys.maxint except AttributeError: maxsize = sys.maxsize - if maxsize < 2 ** 32: + if maxsize < 2**32: assert_((vals < sys.maxsize).all()) else: - assert_((vals >= 2 ** 32).any()) + assert_((vals >= 2**32).any()) def test_beta(self): vals = self.rg.beta(2.0, 2.0, 10) @@ -662,9 +662,9 @@ def test_array_scalar_seed_diff(self): def test_seed_array_error(self): if self.seed_vector_bits == 32: - out_of_bounds = 2 ** 32 + out_of_bounds = 2**32 else: - out_of_bounds = 2 ** 64 + out_of_bounds = 2**64 seed = -1 with pytest.raises(ValueError): @@ -946,7 +946,7 @@ def test_complex_normal(self): v_imag = 2.5 rho = cov / np.sqrt(v_real * v_imag) imag = 7 + np.sqrt(v_imag) * ( - rho * norms[:, 0] + np.sqrt(1 - rho ** 2) * norms[:, 1] + rho * norms[:, 0] + np.sqrt(1 - rho**2) * norms[:, 1] ) real = 2 + np.sqrt(v_real) * norms[:, 0] vals4 = [re + im * (0 + 1.0j) for re, im in zip(real, imag)] @@ -1029,7 +1029,7 @@ def setup_class(cls): super().setup_class() cls.bit_generator = MT19937 cls.advance = None - cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 32 @@ -1052,7 +1052,7 @@ def setup_class(cls): super().setup_class() cls.bit_generator = MT64 cls.advance = None - cls.seed = [2 ** 43 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**43 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 @@ -1091,10 +1091,10 @@ class TestPCG64(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = PCG64 - cls.advance = 2 ** 96 + 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1 + cls.advance = 2**96 + 2**48 + 2**21 + 2**16 + 2**5 + 1 cls.seed = [ - 2 ** 96 + 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, - 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, + 2**96 + 2**48 + 2**21 + 2**16 + 2**5 + 1, + 2**21 + 2**16 + 2**5 + 1, ] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1104,9 +1104,9 @@ def setup_class(cls): def test_seed_array_error(self): # GH #82 for error type changes if self.seed_vector_bits == 32: - out_of_bounds = 2 ** 32 + out_of_bounds = 2**32 else: - out_of_bounds = 2 ** 64 + out_of_bounds = 2**64 seed = -1 with pytest.raises(ValueError): @@ -1157,7 +1157,7 @@ def setup_class(cls): cls.width = 64 cls.bit_generator_base = Philox cls.bit_generator = partial(Philox, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1183,7 +1183,7 @@ def setup_class(cls): cls.number = 2 cls.width = 64 cls.bit_generator = partial(Philox, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1199,7 +1199,7 @@ def setup_class(cls): cls.number = 2 cls.width = 32 cls.bit_generator = partial(Philox, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1214,7 +1214,7 @@ def setup_class(cls): cls.number = 4 cls.width = 32 cls.bit_generator = partial(Philox, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1230,7 +1230,7 @@ def setup_class(cls): cls.width = 64 cls.bit_generator_base = ThreeFry cls.bit_generator = partial(ThreeFry, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1245,7 +1245,7 @@ def setup_class(cls): cls.number = 2 cls.width = 64 cls.bit_generator = partial(ThreeFry, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1260,7 +1260,7 @@ def setup_class(cls): cls.number = 2 cls.width = 32 cls.bit_generator = partial(ThreeFry, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1275,7 +1275,7 @@ def setup_class(cls): cls.number = 4 cls.width = 32 cls.bit_generator = partial(ThreeFry, number=cls.number, width=cls.width) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1395,10 +1395,10 @@ class TestPCG32(TestPCG64): def setup_class(cls): super().setup_class() cls.bit_generator = PCG32 - cls.advance = 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1 + cls.advance = 2**48 + 2**21 + 2**16 + 2**5 + 1 cls.seed = [ - 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, - 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, + 2**48 + 2**21 + 2**16 + 2**5 + 1, + 2**21 + 2**16 + 2**5 + 1, ] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state @@ -1411,8 +1411,8 @@ class TestAESCounter(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = AESCounter - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 - cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.advance = 2**63 + 2**31 + 2**15 + 1 + cls.seed = [2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 @@ -1426,8 +1426,8 @@ class TestChaCha(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = ChaCha - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 - cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.advance = 2**63 + 2**31 + 2**15 + 1 + cls.seed = [2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 @@ -1440,7 +1440,7 @@ class TestHC128(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = HC128 - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 @@ -1453,9 +1453,9 @@ class TestSPECK128(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = SPECK128 - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed, mode="legacy")) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -1467,14 +1467,14 @@ class TestLXM(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = LXM - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed)) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError - cls.out_of_bounds = 2 ** 192 + 1 + cls.out_of_bounds = 2**192 + 1 def init_generator(self, seed=None, mode="sequence"): return Generator(self.bit_generator(seed=seed)) @@ -1485,14 +1485,14 @@ class TestLCG128Mix(RNG): def setup_class(cls): super().setup_class() cls.bit_generator = LCG128Mix - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed)) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError - cls.out_of_bounds = 2 ** 192 + 1 + cls.out_of_bounds = 2**192 + 1 def init_generator(self, seed=None, mode="sequence"): return Generator(self.bit_generator(seed=seed)) @@ -1503,14 +1503,14 @@ class TestPCG64DXSM(TestLCG128Mix): def setup_class(cls): super().setup_class() cls.bit_generator = PCG64DXSM - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed)) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError - cls.out_of_bounds = 2 ** 192 + 1 + cls.out_of_bounds = 2**192 + 1 class TestEFIIX64(TestLCG128Mix): @@ -1518,14 +1518,14 @@ class TestEFIIX64(TestLCG128Mix): def setup_class(cls): super().setup_class() cls.bit_generator = EFIIX64 - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed)) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError - cls.out_of_bounds = 2 ** 192 + 1 + cls.out_of_bounds = 2**192 + 1 class TestRomu(TestLCG128Mix): @@ -1533,11 +1533,11 @@ class TestRomu(TestLCG128Mix): def setup_class(cls): super().setup_class() cls.bit_generator = Romu - cls.seed = [2 ** 231 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] + cls.seed = [2**231 + 2**21 + 2**16 + 2**5 + 1] cls.rg = Generator(cls.bit_generator(*cls.seed)) - cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 + cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.initial_state = cls.rg.bit_generator.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError - cls.out_of_bounds = 2 ** 192 + 1 + cls.out_of_bounds = 2**192 + 1 diff --git a/randomgen/tests/test_wrapper.py b/randomgen/tests/test_wrapper.py index d6698337f..f8d71ea1a 100644 --- a/randomgen/tests/test_wrapper.py +++ b/randomgen/tests/test_wrapper.py @@ -14,7 +14,7 @@ def rotr_64(value, rot): class _PCG64: PCG_DEFAULT_MULTIPLIER = (2549297995355413924 << 64) + 4865540595714422341 - MODULUS = 2 ** 128 + MODULUS = 2**128 def __init__(self, state, inc): self._state = state @@ -77,8 +77,8 @@ def test_smoke(python_pcg): gen = Generator(bg) assert isinstance(gen.random(), float) assert isinstance(gen.standard_normal(dtype=np.float32), float) - assert isinstance(gen.integers(0, 2 ** 32, dtype=np.uint32), np.integer) - assert isinstance(gen.integers(0, 2 ** 64, dtype=np.uint64), np.integer) + assert isinstance(gen.integers(0, 2**32, dtype=np.uint32), np.integer) + assert isinstance(gen.integers(0, 2**64, dtype=np.uint64), np.integer) def test_random_raw(pcg_python, pcg_native): @@ -94,10 +94,10 @@ def test_random_raw(pcg_python, pcg_native): lambda bg: bg.standard_normal(size=(20, 3)), lambda bg: bg.standard_normal(dtype=np.float32), lambda bg: bg.standard_normal(size=(20, 3), dtype=np.float32), - lambda bg: bg.integers(0, 2 ** 32, dtype=np.uint32), - lambda bg: bg.integers(0, 2 ** 32, dtype=np.uint32, size=(7, 5, 3, 2)), - lambda bg: bg.integers(0, 2 ** 64, dtype=np.uint64), - lambda bg: bg.integers(0, 2 ** 32, dtype=np.uint64, size=(7, 5, 3, 2)), + lambda bg: bg.integers(0, 2**32, dtype=np.uint32), + lambda bg: bg.integers(0, 2**32, dtype=np.uint32, size=(7, 5, 3, 2)), + lambda bg: bg.integers(0, 2**64, dtype=np.uint64), + lambda bg: bg.integers(0, 2**32, dtype=np.uint64, size=(7, 5, 3, 2)), ], ) def test_against_ref(func, pcg_python, pcg_native): @@ -113,6 +113,6 @@ def next_raw(vp): bg = UserBitGenerator(next_raw, 32) assert bg.random_raw() == np.iinfo(np.uint32).max gen = Generator(bg) - assert gen.integers(0, 2 ** 64, dtype=np.uint64) == np.iinfo(np.uint64).max - np.testing.assert_allclose(gen.random(), (2 ** 53 - 1) / (2 ** 53), rtol=1e-14) + assert gen.integers(0, 2**64, dtype=np.uint64) == np.iinfo(np.uint64).max + np.testing.assert_allclose(gen.random(), (2**53 - 1) / (2**53), rtol=1e-14) assert "UserBitGenerator(Python)" in repr(bg) diff --git a/randomgen/tests/test_wrapper_numba.py b/randomgen/tests/test_wrapper_numba.py index 040af5492..4a56381f2 100644 --- a/randomgen/tests/test_wrapper_numba.py +++ b/randomgen/tests/test_wrapper_numba.py @@ -33,7 +33,7 @@ def splitmix_next(state): class NumbaSplitMix64: def __init__(self, state): - if not isinstance(state, (int, np.integer)) or not (0 <= state < 2 ** 64): + if not isinstance(state, (int, np.integer)) or not (0 <= state < 2**64): raise ValueError("state must be a valid uint64") # state[0] is the splitmix64 state # state[1] contains both the has_uint flag in bit 0 @@ -152,7 +152,7 @@ def test_ctypes_smoke(split_mix): assert bgf.state == split_mix.state_getter() gen.standard_normal(dtype=np.float32) assert bgf.state == split_mix.state_getter() - gen.integers(0, 2 ** 63, dtype=np.uint64, size=10) + gen.integers(0, 2**63, dtype=np.uint64, size=10) assert bgf.state == split_mix.state_getter() old_state = bgf.state.copy() old_state["state"] = 1 @@ -175,7 +175,7 @@ def test_cfunc_smoke(split_mix): assert bgf.state == split_mix.state_getter() gen.standard_normal(dtype=np.float32) assert bgf.state == split_mix.state_getter() - gen.integers(0, 2 ** 63, dtype=np.uint64, size=10) + gen.integers(0, 2**63, dtype=np.uint64, size=10) assert bgf.state == split_mix.state_getter() old_state = bgf.state.copy() old_state["state"] = 1 @@ -194,7 +194,7 @@ def test_no_setter_getter(split_mix): gen = Generator(bgf) gen.standard_normal(size=10) gen.standard_normal(size=10, dtype=np.float32) - gen.integers(0, 2 ** 63, dtype=np.uint64, size=10) + gen.integers(0, 2**63, dtype=np.uint64, size=10) with pytest.raises(NotImplementedError): bgf.state with pytest.raises(NotImplementedError): diff --git a/requirements-dev.txt b/requirements-dev.txt index 9360def19..34df16d98 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -black==21.4b1 +black==22.3.0 pytest>=6 pytest-cov -scipy>=1.3.2 \ No newline at end of file +scipy>=1.3.2 diff --git a/setup.cfg b/setup.cfg index a50898bc6..32268189d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,14 +6,6 @@ license_file = LICENSE.md max-line-length = 99 ignore = E203,W503,BLK100 -[versioneer] -VCS = git -style = pep440 -versionfile_source = randomgen/_version.py -versionfile_build = randomgen/_version.py -tag_prefix = v -parentdir_prefix = randomgen- - [isort] sections=FUTURE,COMPAT,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER known_first_party=randomgen diff --git a/setup.py b/setup.py index d894fdaa8..7ba905354 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,6 @@ import Cython.Compiler.Options import numpy as np -import versioneer - try: from Cython import Tempita as tempita except ImportError: @@ -340,9 +338,7 @@ def is_pure(self): setup( name="randomgen", - version=versioneer.get_version(), classifiers=classifiers, - cmdclass=versioneer.get_cmdclass(), ext_modules=cythonize( extensions, compiler_directives={"language_level": "3", "linetrace": CYTHON_COVERAGE}, diff --git a/versioneer.py b/versioneer.py deleted file mode 100644 index dad0f5b47..000000000 --- a/versioneer.py +++ /dev/null @@ -1,1886 +0,0 @@ -# Version: 0.18 - -"""The Versioneer - like a rocketeer, but for versions. - -The Versioneer -============== - -* like a rocketeer, but for versions! -* https://github.com/warner/python-versioneer -* Brian Warner -* License: Public Domain -* Compatible With: python2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, and pypy -* [![Latest Version] -(https://pypip.in/version/versioneer/badge.svg?style=flat) -](https://pypi.python.org/pypi/versioneer/) -* [![Build Status] -(https://travis-ci.org/warner/python-versioneer.png?branch=master) -](https://travis-ci.org/warner/python-versioneer) - -This is a tool for managing a recorded version number in distutils-based -python projects. The goal is to remove the tedious and error-prone "update -the embedded version string" step from your release process. Making a new -release should be as easy as recording a new tag in your version-control -system, and maybe making new tarballs. - - -## Quick Install - -* `pip install versioneer` to somewhere to your $PATH -* add a `[versioneer]` section to your setup.cfg (see below) -* run `versioneer install` in your source tree, commit the results - -## Version Identifiers - -Source trees come from a variety of places: - -* a version-control system checkout (mostly used by developers) -* a nightly tarball, produced by build automation -* a snapshot tarball, produced by a web-based VCS browser, like github's - "tarball from tag" feature -* a release tarball, produced by "setup.py sdist", distributed through PyPI - -Within each source tree, the version identifier (either a string or a number, -this tool is format-agnostic) can come from a variety of places: - -* ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows - about recent "tags" and an absolute revision-id -* the name of the directory into which the tarball was unpacked -* an expanded VCS keyword ($Id$, etc) -* a `_version.py` created by some earlier build step - -For released software, the version identifier is closely related to a VCS -tag. Some projects use tag names that include more than just the version -string (e.g. "myproject-1.2" instead of just "1.2"), in which case the tool -needs to strip the tag prefix to extract the version identifier. For -unreleased software (between tags), the version identifier should provide -enough information to help developers recreate the same tree, while also -giving them an idea of roughly how old the tree is (after version 1.2, before -version 1.3). Many VCS systems can report a description that captures this, -for example `git describe --tags --dirty --always` reports things like -"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the -0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has -uncommitted changes. - -The version identifier is used for multiple purposes: - -* to allow the module to self-identify its version: `myproject.__version__` -* to choose a name and prefix for a 'setup.py sdist' tarball - -## Theory of Operation - -Versioneer works by adding a special `_version.py` file into your source -tree, where your `__init__.py` can import it. This `_version.py` knows how to -dynamically ask the VCS tool for version information at import time. - -`_version.py` also contains `$Revision$` markers, and the installation -process marks `_version.py` to have this marker rewritten with a tag name -during the `git archive` command. As a result, generated tarballs will -contain enough information to get the proper version. - -To allow `setup.py` to compute a version too, a `versioneer.py` is added to -the top level of your source tree, next to `setup.py` and the `setup.cfg` -that configures it. This overrides several distutils/setuptools commands to -compute the version when invoked, and changes `setup.py build` and `setup.py -sdist` to replace `_version.py` with a small static file that contains just -the generated version data. - -## Installation - -See [INSTALL.md](./INSTALL.md) for detailed installation instructions. - -## Version-String Flavors - -Code which uses Versioneer can learn about its version string at runtime by -importing `_version` from your main `__init__.py` file and running the -`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can -import the top-level `versioneer.py` and run `get_versions()`. - -Both functions return a dictionary with different flavors of version -information: - -* `['version']`: A condensed version string, rendered using the selected - style. This is the most commonly used value for the project's version - string. The default "pep440" style yields strings like `0.11`, - `0.11+2.g1076c97`, or `0.11+2.g1076c97.dirty`. See the "Styles" section - below for alternative styles. - -* `['full-revisionid']`: detailed revision identifier. For Git, this is the - full SHA1 commit id, e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac". - -* `['date']`: Date and time of the latest `HEAD` commit. For Git, it is the - commit date in ISO 8601 format. This will be None if the date is not - available. - -* `['dirty']`: a boolean, True if the tree has uncommitted changes. Note that - this is only accurate if run in a VCS checkout, otherwise it is likely to - be False or None - -* `['error']`: if the version string could not be computed, this will be set - to a string describing the problem, otherwise it will be None. It may be - useful to throw an exception in setup.py if this is set, to avoid e.g. - creating tarballs with a version string of "unknown". - -Some variants are more useful than others. Including `full-revisionid` in a -bug report should allow developers to reconstruct the exact code being tested -(or indicate the presence of local changes that should be shared with the -developers). `version` is suitable for display in an "about" box or a CLI -`--version` output: it can be easily compared against release notes and lists -of bugs fixed in various releases. - -The installer adds the following text to your `__init__.py` to place a basic -version in `YOURPROJECT.__version__`: - - from ._version import get_versions - __version__ = get_versions()['version'] - del get_versions - -## Styles - -The setup.cfg `style=` configuration controls how the VCS information is -rendered into a version string. - -The default style, "pep440", produces a PEP440-compliant string, equal to the -un-prefixed tag name for actual releases, and containing an additional "local -version" section with more detail for in-between builds. For Git, this is -TAG[+DISTANCE.gHEX[.dirty]] , using information from `git describe --tags ---dirty --always`. For example "0.11+2.g1076c97.dirty" indicates that the -tree is like the "1076c97" commit but has uncommitted changes (".dirty"), and -that this commit is two revisions ("+2") beyond the "0.11" tag. For released -software (exactly equal to a known tag), the identifier will only contain the -stripped tag, e.g. "0.11". - -Other styles are available. See [details.md](details.md) in the Versioneer -source tree for descriptions. - -## Debugging - -Versioneer tries to avoid fatal errors: if something goes wrong, it will tend -to return a version of "0+unknown". To investigate the problem, run `setup.py -version`, which will run the version-lookup code in a verbose mode, and will -display the full contents of `get_versions()` (including the `error` string, -which may help identify what went wrong). - -## Known Limitations - -Some situations are known to cause problems for Versioneer. This details the -most significant ones. More can be found on Github -[issues page](https://github.com/warner/python-versioneer/issues). - -### Subprojects - -Versioneer has limited support for source trees in which `setup.py` is not in -the root directory (e.g. `setup.py` and `.git/` are *not* siblings). The are -two common reasons why `setup.py` might not be in the root: - -* Source trees which contain multiple subprojects, such as - [Buildbot](https://github.com/buildbot/buildbot), which contains both - "master" and "slave" subprojects, each with their own `setup.py`, - `setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI - distributions (and upload multiple independently-installable tarballs). -* Source trees whose main purpose is to contain a C library, but which also - provide bindings to Python (and perhaps other langauges) in subdirectories. - -Versioneer will look for `.git` in parent directories, and most operations -should get the right version string. However `pip` and `setuptools` have bugs -and implementation details which frequently cause `pip install .` from a -subproject directory to fail to find a correct version string (so it usually -defaults to `0+unknown`). - -`pip install --editable .` should work correctly. `setup.py install` might -work too. - -Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in -some later version. - -[Bug #38](https://github.com/warner/python-versioneer/issues/38) is tracking -this issue. The discussion in -[PR #61](https://github.com/warner/python-versioneer/pull/61) describes the -issue from the Versioneer side in more detail. -[pip PR#3176](https://github.com/pypa/pip/pull/3176) and -[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve -pip to let Versioneer work correctly. - -Versioneer-0.16 and earlier only looked for a `.git` directory next to the -`setup.cfg`, so subprojects were completely unsupported with those releases. - -### Editable installs with setuptools <= 18.5 - -`setup.py develop` and `pip install --editable .` allow you to install a -project into a virtualenv once, then continue editing the source code (and -test) without re-installing after every change. - -"Entry-point scripts" (`setup(entry_points={"console_scripts": ..})`) are a -convenient way to specify executable scripts that should be installed along -with the python package. - -These both work as expected when using modern setuptools. When using -setuptools-18.5 or earlier, however, certain operations will cause -`pkg_resources.DistributionNotFound` errors when running the entrypoint -script, which must be resolved by re-installing the package. This happens -when the install happens with one version, then the egg_info data is -regenerated while a different version is checked out. Many setup.py commands -cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into -a different virtualenv), so this can be surprising. - -[Bug #83](https://github.com/warner/python-versioneer/issues/83) describes -this one, but upgrading to a newer version of setuptools should probably -resolve it. - -### Unicode version strings - -While Versioneer works (and is continually tested) with both Python 2 and -Python 3, it is not entirely consistent with bytes-vs-unicode distinctions. -Newer releases probably generate unicode version strings on py2. It's not -clear that this is wrong, but it may be surprising for applications when then -write these strings to a network connection or include them in bytes-oriented -APIs like cryptographic checksums. - -[Bug #71](https://github.com/warner/python-versioneer/issues/71) investigates -this question. - - -## Updating Versioneer - -To upgrade your project to a new release of Versioneer, do the following: - -* install the new Versioneer (`pip install -U versioneer` or equivalent) -* edit `setup.cfg`, if necessary, to include any new configuration settings - indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details. -* re-run `versioneer install` in your source tree, to replace - `SRC/_version.py` -* commit any changed files - -## Future Directions - -This tool is designed to make it easily extended to other version-control -systems: all VCS-specific components are in separate directories like -src/git/ . The top-level `versioneer.py` script is assembled from these -components by running make-versioneer.py . In the future, make-versioneer.py -will take a VCS name as an argument, and will construct a version of -`versioneer.py` that is specific to the given VCS. It might also take the -configuration arguments that are currently provided manually during -installation by editing setup.py . Alternatively, it might go the other -direction and include code from all supported VCS systems, reducing the -number of intermediate scripts. - - -## License - -To make Versioneer easier to embed, all its code is dedicated to the public -domain. The `_version.py` that it creates is also in the public domain. -Specifically, both are released under the Creative Commons "Public Domain -Dedication" license (CC0-1.0), as described in -https://creativecommons.org/publicdomain/zero/1.0/ . - -""" - -from __future__ import print_function - -import errno -import json -import os -import re -import subprocess -import sys - -try: - import configparser -except ImportError: - import ConfigParser as configparser - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_root(): - """Get the project root directory. - - We require that all commands are run from the project root, i.e. the - directory that contains setup.py, setup.cfg, and versioneer.py . - """ - root = os.path.realpath(os.path.abspath(os.getcwd())) - setup_py = os.path.join(root, "setup.py") - versioneer_py = os.path.join(root, "versioneer.py") - if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): - # allow 'python path/to/setup.py COMMAND' - root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) - setup_py = os.path.join(root, "setup.py") - versioneer_py = os.path.join(root, "versioneer.py") - if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): - err = ( - "Versioneer was unable to run the project root directory. " - "Versioneer requires setup.py to be executed from " - "its immediate directory (like 'python setup.py COMMAND'), " - "or in a way that lets it use sys.argv[0] to find the root " - "(like 'python path/to/setup.py COMMAND')." - ) - raise VersioneerBadRootError(err) - try: - # Certain runtime workflows (setup.py install/develop in a setuptools - # tree) execute all dependencies in a single python process, so - # "versioneer" may be imported multiple times, and python's shared - # module-import table will cache the first one. So we can't use - # os.path.dirname(__file__), as that will find whichever - # versioneer.py was first imported, even in later projects. - me = os.path.realpath(os.path.abspath(__file__)) - me_dir = os.path.normcase(os.path.splitext(me)[0]) - vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) - if me_dir != vsr_dir: - print( - "Warning: build in %s is using versioneer.py from %s" - % (os.path.dirname(me), versioneer_py) - ) - except NameError: - pass - return root - - -def get_config_from_root(root): - """Read the project setup.cfg file to determine Versioneer config.""" - # This might raise EnvironmentError (if setup.cfg is missing), or - # configparser.NoSectionError (if it lacks a [versioneer] section), or - # configparser.NoOptionError (if it lacks "VCS="). See the docstring at - # the top of versioneer.py for instructions on writing your setup.cfg . - setup_cfg = os.path.join(root, "setup.cfg") - parser = configparser.SafeConfigParser() - with open(setup_cfg, "r") as f: - parser.readfp(f) - VCS = parser.get("versioneer", "VCS") # mandatory - - def get(parser, name): - if parser.has_option("versioneer", name): - return parser.get("versioneer", name) - return None - - cfg = VersioneerConfig() - cfg.VCS = VCS - cfg.style = get(parser, "style") or "" - cfg.versionfile_source = get(parser, "versionfile_source") - cfg.versionfile_build = get(parser, "versionfile_build") - cfg.tag_prefix = get(parser, "tag_prefix") - if cfg.tag_prefix in ("''", '""'): - cfg.tag_prefix = "" - cfg.parentdir_prefix = get(parser, "parentdir_prefix") - cfg.verbose = get(parser, "verbose") - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -# these dictionaries contain VCS-specific tools -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - - return decorate - - -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=None): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen( - [c] + args, - cwd=cwd, - env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr else None), - ) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode - - -LONG_VERSION_PY[ - "git" -] = r''' -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys - - -def get_keywords(): - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" - git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s" - git_date = "%(DOLLAR)sFormat:%%ci%(DOLLAR)s" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_config(): - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "%(STYLE)s" - cfg.tag_prefix = "%(TAG_PREFIX)s" - cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s" - cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - return decorate - - -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, - env=None): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen([c] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None)) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %%s" %% dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %%s" %% (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %%s (error)" %% dispcmd) - print("stdout was %%s" %% stdout) - return None, p.returncode - return stdout, p.returncode - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return {"version": dirname[len(parentdir_prefix):], - "full-revisionid": None, - "dirty": False, "error": None, "date": None} - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print("Tried directories %%s but none started with prefix %%s" %% - (str(rootdirs), parentdir_prefix)) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %%d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) - if verbose: - print("discarding '%%s', no digits" %% ",".join(refs - tags)) - if verbose: - print("likely tags: %%s" %% ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix):] - if verbose: - print("picking %%s" %% r) - return {"version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": None, - "date": date} - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return {"version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": "no suitable tags", "date": None} - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=True) - if rc != 0: - if verbose: - print("Directory %%s not under git control" %% root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty", - "--always", "--long", - "--match", "%%s*" %% tag_prefix], - cwd=root) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[:git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = ("unable to parse git-describe output: '%%s'" - %% describe_out) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%%s' doesn't start with prefix '%%s'" - print(fmt %% (full_tag, tag_prefix)) - pieces["error"] = ("tag '%%s' doesn't start with prefix '%%s'" - %% (full_tag, tag_prefix)) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix):] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], - cwd=root) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%%ci", "HEAD"], - cwd=root)[0].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%%d.g%%s" %% (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%%d" %% pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%%d" %% pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%%s" %% pieces["short"] - else: - # exception #1 - rendered = "0.post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%%s" %% pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return {"version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None} - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%%s'" %% style) - - return {"version": rendered, "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], "error": None, - "date": pieces.get("date")} - - -def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, - verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): - root = os.path.dirname(root) - except NameError: - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None} - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", "date": None} -''' - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r"\d", r)]) - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix) :] - if verbose: - print("picking %s" % r) - return { - "version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": None, - "date": date, - } - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return { - "version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": "no suitable tags", - "date": None, - } - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command( - GITS, - [ - "describe", - "--tags", - "--dirty", - "--always", - "--long", - "--match", - "%s*" % tag_prefix, - ], - cwd=root, - ) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[: git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( - full_tag, - tag_prefix, - ) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix) :] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], cwd=root) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ - 0 - ].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def do_vcs_install(manifest_in, versionfile_source, ipy): - """Git-specific installation logic for Versioneer. - - For Git, this means creating/changing .gitattributes to mark _version.py - for export-subst keyword substitution. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - files = [manifest_in, versionfile_source] - if ipy: - files.append(ipy) - try: - me = __file__ - if me.endswith(".pyc") or me.endswith(".pyo"): - me = os.path.splitext(me)[0] + ".py" - versioneer_file = os.path.relpath(me) - except NameError: - versioneer_file = "versioneer.py" - files.append(versioneer_file) - present = False - try: - f = open(".gitattributes", "r") - for line in f.readlines(): - if line.strip().startswith(versionfile_source): - if "export-subst" in line.strip().split()[1:]: - present = True - f.close() - except EnvironmentError: - pass - if not present: - f = open(".gitattributes", "a+") - f.write("%s export-subst\n" % versionfile_source) - f.close() - files.append(".gitattributes") - run_command(GITS, ["add", "--"] + files) - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return { - "version": dirname[len(parentdir_prefix) :], - "full-revisionid": None, - "dirty": False, - "error": None, - "date": None, - } - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -SHORT_VERSION_PY = """ -# This file was generated by 'versioneer.py' (0.18) from -# revision-control system data, or from the parent directory name of an -# unpacked source archive. Distribution tarballs contain a pre-generated copy -# of this file. - -import json - -version_json = ''' -%s -''' # END VERSION_JSON - - -def get_versions(): - return json.loads(version_json) -""" - - -def versions_from_file(filename): - """Try to determine the version from _version.py if present.""" - try: - with open(filename) as f: - contents = f.read() - except EnvironmentError: - raise NotThisMethod("unable to read _version.py") - mo = re.search( - r"version_json = '''\n(.*)''' # END VERSION_JSON", contents, re.M | re.S - ) - if not mo: - mo = re.search( - r"version_json = '''\r\n(.*)''' # END VERSION_JSON", contents, re.M | re.S - ) - if not mo: - raise NotThisMethod("no version_json in _version.py") - return json.loads(mo.group(1)) - - -def write_to_version_file(filename, versions): - """Write the given version number to the given _version.py file.""" - os.unlink(filename) - contents = json.dumps(versions, sort_keys=True, indent=1, separators=(",", ": ")) - with open(filename, "w") as f: - f.write(SHORT_VERSION_PY % contents) - - print("set %s to '%s'" % (filename, versions["version"])) - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return { - "version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None, - } - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return { - "version": rendered, - "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], - "error": None, - "date": pieces.get("date"), - } - - -class VersioneerBadRootError(Exception): - """The project root directory is unknown or missing key files.""" - - -def get_versions(verbose=False): - """Get the project version from whatever source is available. - - Returns dict with two keys: 'version' and 'full'. - """ - if "versioneer" in sys.modules: - # see the discussion in cmdclass.py:get_cmdclass() - del sys.modules["versioneer"] - - root = get_root() - cfg = get_config_from_root(root) - - assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" - handlers = HANDLERS.get(cfg.VCS) - assert handlers, "unrecognized VCS '%s'" % cfg.VCS - verbose = verbose or cfg.verbose - assert ( - cfg.versionfile_source is not None - ), "please set versioneer.versionfile_source" - assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" - - versionfile_abs = os.path.join(root, cfg.versionfile_source) - - # extract version from first of: _version.py, VCS command (e.g. 'git - # describe'), parentdir. This is meant to work for developers using a - # source checkout, for users of a tarball created by 'setup.py sdist', - # and for users of a tarball/zipball created by 'git archive' or github's - # download-from-tag feature or the equivalent in other VCSes. - - get_keywords_f = handlers.get("get_keywords") - from_keywords_f = handlers.get("keywords") - if get_keywords_f and from_keywords_f: - try: - keywords = get_keywords_f(versionfile_abs) - ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) - if verbose: - print("got version from expanded keyword %s" % ver) - return ver - except NotThisMethod: - pass - - try: - ver = versions_from_file(versionfile_abs) - if verbose: - print("got version from file %s %s" % (versionfile_abs, ver)) - return ver - except NotThisMethod: - pass - - from_vcs_f = handlers.get("pieces_from_vcs") - if from_vcs_f: - try: - pieces = from_vcs_f(cfg.tag_prefix, root, verbose) - ver = render(pieces, cfg.style) - if verbose: - print("got version from VCS %s" % ver) - return ver - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - if verbose: - print("got version from parentdir %s" % ver) - return ver - except NotThisMethod: - pass - - if verbose: - print("unable to compute version") - - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", - "date": None, - } - - -def get_version(): - """Get the short version string for this project.""" - return get_versions()["version"] - - -def get_cmdclass(): - """Get the custom setuptools/distutils subclasses used by Versioneer.""" - if "versioneer" in sys.modules: - del sys.modules["versioneer"] - # this fixes the "python setup.py develop" case (also 'install' and - # 'easy_install .'), in which subdependencies of the main project are - # built (using setup.py bdist_egg) in the same python process. Assume - # a main project A and a dependency B, which use different versions - # of Versioneer. A's setup.py imports A's Versioneer, leaving it in - # sys.modules by the time B's setup.py is executed, causing B to run - # with the wrong versioneer. Setuptools wraps the sub-dep builds in a - # sandbox that restores sys.modules to it's pre-build state, so the - # parent is protected against the child's "import versioneer". By - # removing ourselves from sys.modules here, before the child build - # happens, we protect the child from the parent's versioneer too. - # Also see https://github.com/warner/python-versioneer/issues/52 - - cmds = {} - - # we add "version" to both distutils and setuptools - from distutils.core import Command - - class cmd_version(Command): - description = "report generated version string" - user_options = [] - boolean_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - vers = get_versions(verbose=True) - print("Version: %s" % vers["version"]) - print(" full-revisionid: %s" % vers.get("full-revisionid")) - print(" dirty: %s" % vers.get("dirty")) - print(" date: %s" % vers.get("date")) - if vers["error"]: - print(" error: %s" % vers["error"]) - - cmds["version"] = cmd_version - - # we override "build_py" in both distutils and setuptools - # - # most invocation pathways end up running build_py: - # distutils/build -> build_py - # distutils/install -> distutils/build ->.. - # setuptools/bdist_wheel -> distutils/install ->.. - # setuptools/bdist_egg -> distutils/install_lib -> build_py - # setuptools/install -> bdist_egg ->.. - # setuptools/develop -> ? - # pip install: - # copies source tree to a tempdir before running egg_info/etc - # if .git isn't copied too, 'git describe' will fail - # then does setup.py bdist_wheel, or sometimes setup.py install - # setup.py egg_info -> ? - - # we override different "build_py" commands for both environments - if "setuptools" in sys.modules: - from setuptools.command.build_py import build_py as _build_py - else: - from distutils.command.build_py import build_py as _build_py - - class cmd_build_py(_build_py): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - _build_py.run(self) - # now locate _version.py in the new build/ directory and replace - # it with an updated value - if cfg.versionfile_build: - target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build) - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - cmds["build_py"] = cmd_build_py - - if "cx_Freeze" in sys.modules: # cx_freeze enabled? - from cx_Freeze.dist import build_exe as _build_exe - - # nczeczulin reports that py2exe won't like the pep440-style string - # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. - # setup(console=[{ - # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION - # "product_version": versioneer.get_version(), - # ... - - class cmd_build_exe(_build_exe): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - target_versionfile = cfg.versionfile_source - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - _build_exe.run(self) - os.unlink(target_versionfile) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - cmds["build_exe"] = cmd_build_exe - del cmds["build_py"] - - if "py2exe" in sys.modules: # py2exe enabled? - try: - from py2exe.distutils_buildexe import py2exe as _py2exe # py3 - except ImportError: - from py2exe.build_exe import py2exe as _py2exe # py2 - - class cmd_py2exe(_py2exe): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - target_versionfile = cfg.versionfile_source - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - _py2exe.run(self) - os.unlink(target_versionfile) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - cmds["py2exe"] = cmd_py2exe - - # we override different "sdist" commands for both environments - if "setuptools" in sys.modules: - from setuptools.command.sdist import sdist as _sdist - else: - from distutils.command.sdist import sdist as _sdist - - class cmd_sdist(_sdist): - def run(self): - versions = get_versions() - self._versioneer_generated_versions = versions - # unless we update this, the command will keep using the old - # version - self.distribution.metadata.version = versions["version"] - return _sdist.run(self) - - def make_release_tree(self, base_dir, files): - root = get_root() - cfg = get_config_from_root(root) - _sdist.make_release_tree(self, base_dir, files) - # now locate _version.py in the new base_dir directory - # (remembering that it may be a hardlink) and replace it with an - # updated value - target_versionfile = os.path.join(base_dir, cfg.versionfile_source) - print("UPDATING %s" % target_versionfile) - write_to_version_file( - target_versionfile, self._versioneer_generated_versions - ) - - cmds["sdist"] = cmd_sdist - - return cmds - - -CONFIG_ERROR = """ -setup.cfg is missing the necessary Versioneer configuration. You need -a section like: - - [versioneer] - VCS = git - style = pep440 - versionfile_source = src/myproject/_version.py - versionfile_build = myproject/_version.py - tag_prefix = - parentdir_prefix = myproject- - -You will also need to edit your setup.py to use the results: - - import versioneer - setup(version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), ...) - -Please read the docstring in ./versioneer.py for configuration instructions, -edit setup.cfg, and re-run the installer or 'python versioneer.py setup'. -""" - -SAMPLE_CONFIG = """ -# See the docstring in versioneer.py for instructions. Note that you must -# re-run 'versioneer.py setup' after changing this section, and commit the -# resulting files. - -[versioneer] -#VCS = git -#style = pep440 -#versionfile_source = -#versionfile_build = -#tag_prefix = -#parentdir_prefix = - -""" - -INIT_PY_SNIPPET = """ -from ._version import get_versions -__version__ = get_versions()['version'] -del get_versions -""" - - -def do_setup(): - """Main VCS-independent setup function for installing Versioneer.""" - root = get_root() - try: - cfg = get_config_from_root(root) - except ( - EnvironmentError, - configparser.NoSectionError, - configparser.NoOptionError, - ) as e: - if isinstance(e, (EnvironmentError, configparser.NoSectionError)): - print("Adding sample versioneer config to setup.cfg", file=sys.stderr) - with open(os.path.join(root, "setup.cfg"), "a") as f: - f.write(SAMPLE_CONFIG) - print(CONFIG_ERROR, file=sys.stderr) - return 1 - - print(" creating %s" % cfg.versionfile_source) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") - if os.path.exists(ipy): - try: - with open(ipy, "r") as f: - old = f.read() - except EnvironmentError: - old = "" - if INIT_PY_SNIPPET not in old: - print(" appending to %s" % ipy) - with open(ipy, "a") as f: - f.write(INIT_PY_SNIPPET) - else: - print(" %s unmodified" % ipy) - else: - print(" %s doesn't exist, ok" % ipy) - ipy = None - - # Make sure both the top-level "versioneer.py" and versionfile_source - # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so - # they'll be copied into source distributions. Pip won't be able to - # install the package without this. - manifest_in = os.path.join(root, "MANIFEST.in") - simple_includes = set() - try: - with open(manifest_in, "r") as f: - for line in f: - if line.startswith("include "): - for include in line.split()[1:]: - simple_includes.add(include) - except EnvironmentError: - pass - # That doesn't cover everything MANIFEST.in can do - # (https://docs.python.org/2/distutils/sourcedist.html#commands), so - # it might give some false negatives. Appending redundant 'include' - # lines is safe, though. - if "versioneer.py" not in simple_includes: - print(" appending 'versioneer.py' to MANIFEST.in") - with open(manifest_in, "a") as f: - f.write("include versioneer.py\n") - else: - print(" 'versioneer.py' already in MANIFEST.in") - if cfg.versionfile_source not in simple_includes: - print( - " appending versionfile_source ('%s') to MANIFEST.in" - % cfg.versionfile_source - ) - with open(manifest_in, "a") as f: - f.write("include %s\n" % cfg.versionfile_source) - else: - print(" versionfile_source already in MANIFEST.in") - - # Make VCS-specific changes. For git, this means creating/changing - # .gitattributes to mark _version.py for export-subst keyword - # substitution. - do_vcs_install(manifest_in, cfg.versionfile_source, ipy) - return 0 - - -def scan_setup_py(): - """Validate the contents of setup.py against Versioneer's expectations.""" - found = set() - setters = False - errors = 0 - with open("setup.py", "r") as f: - for line in f.readlines(): - if "import versioneer" in line: - found.add("import") - if "versioneer.get_cmdclass()" in line: - found.add("cmdclass") - if "versioneer.get_version()" in line: - found.add("get_version") - if "versioneer.VCS" in line: - setters = True - if "versioneer.versionfile_source" in line: - setters = True - if len(found) != 3: - print("") - print("Your setup.py appears to be missing some important items") - print("(but I might be wrong). Please make sure it has something") - print("roughly like the following:") - print("") - print(" import versioneer") - print(" setup( version=versioneer.get_version(),") - print(" cmdclass=versioneer.get_cmdclass(), ...)") - print("") - errors += 1 - if setters: - print("You should remove lines like 'versioneer.VCS = ' and") - print("'versioneer.versionfile_source = ' . This configuration") - print("now lives in setup.cfg, and should be removed from setup.py") - print("") - errors += 1 - return errors - - -if __name__ == "__main__": - cmd = sys.argv[1] - if cmd == "setup": - errors = do_setup() - errors += scan_setup_py() - if errors: - sys.exit(1) From 51705dd39dbf7b1e1ddb0e7ad873df69ef32f3ae Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 11:37:01 +0100 Subject: [PATCH 02/33] MAINT: Update drone Update with type --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index c1b8ec9c5..66cc58cce 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,11 +1,13 @@ --- kind: pipeline +type: exec name: test-on-arm64 platform: os: linux arch: arm64 + steps: - name: test image: ubuntu:latest From 498e8f1cb0bc8b71aa006402ffe2b865bf8a8abe Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 11:47:15 +0100 Subject: [PATCH 03/33] MAINT: Update cirrus --- .cirrus.yml | 2 +- ci/cirrus-install.sh | 8 ++++++-- randomgen/__init__.py | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index f7de2a288..e2731c629 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,5 +1,5 @@ freebsd_instance: - image_family: freebsd-12-2 + image_family: freebsd-12-3 task: install_script: . ./ci/cirrus-install.sh diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 28bdacfbd..01f303c1b 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash -pkg install -y python38 py38-pip py38-numpy py38-cython py38-pytest -python3.8 setup.py develop +freebsd-update fetch +freebsd-update install + +pkg install -y python39 py39-pip py39-numpy py39-cython py39-pytest +python3.9 -m pip install -e . --no-build-isolation + diff --git a/randomgen/__init__.py b/randomgen/__init__.py index 1d360c5c1..cdb02e71e 100644 --- a/randomgen/__init__.py +++ b/randomgen/__init__.py @@ -67,6 +67,8 @@ "Xoshiro256", "Xoshiro512", "random_entropy", + "__version__", + "__version_info__", ] From 8faa033347b4434b1f9c877055d0236d0100aeee Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 11:54:49 +0100 Subject: [PATCH 04/33] MAINT: Improve azure --- ci/azure/azure_template_posix.yml | 2 +- ci/azure/install-posix.sh | 2 +- ci/cirrus-install.sh | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index d6ebef712..447dec1cb 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -93,7 +93,7 @@ jobs: - script: | echo "Installing to site packages" - python setup.py bdist_wheel + python -m pip wheel . WHL=$(ls -t dist) pip install ./dist/${WHL} displayName: 'Install randomgen (site-packages)' diff --git a/ci/azure/install-posix.sh b/ci/azure/install-posix.sh index f84a8ecb1..8b89a529e 100644 --- a/ci/azure/install-posix.sh +++ b/ci/azure/install-posix.sh @@ -13,7 +13,7 @@ else fi # Not all available in conda -python -m pip install setuptools wheel pip black==20.8b1 isort flake8 --upgrade +python -m pip install setuptools "setuptools_scm[toml]<7" "oldest-supported-numpy" wheel pip black==22.3.0 isort flake8 --upgrade EXTRA="pytest pytest-xdist coverage pytest-cov" diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 01f303c1b..20f71c57a 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -4,5 +4,6 @@ freebsd-update fetch freebsd-update install pkg install -y python39 py39-pip py39-numpy py39-cython py39-pytest -python3.9 -m pip install -e . --no-build-isolation +python3.9 -m pip install -e . --no-build-isolation --user + From 836f65086b95e730a9159ae497d65b65aad38f51 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 11:56:06 +0100 Subject: [PATCH 05/33] MAINT: Update cirrus --- ci/cirrus-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 20f71c57a..98f372f3f 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -freebsd-update fetch -freebsd-update install - pkg install -y python39 py39-pip py39-numpy py39-cython py39-pytest python3.9 -m pip install -e . --no-build-isolation --user From 827b36ba6543758e1ac09f3ec9bcbc0b6490033a Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:17:17 +0100 Subject: [PATCH 06/33] MAINT: COntinue to improve CI --- ci/azure/azure_template_posix.yml | 8 ++++---- requirements-dev.txt | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index 447dec1cb..133d9f092 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -36,7 +36,7 @@ jobs: python.version: '3.8' use.conda: true NUMPY: 1.18.5 - CYTHON: 0.29.22 + CYTHON: 0.29.24 USE_SCIPY: "true" USE_NUMBA: "true" python_38_coverage: @@ -93,9 +93,9 @@ jobs: - script: | echo "Installing to site packages" - python -m pip wheel . - WHL=$(ls -t dist) - pip install ./dist/${WHL} + python -m pip wheel . -w wheelhouse/ + WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) + pip install ./wheelhouse/${WHL} displayName: 'Install randomgen (site-packages)' condition: eq(variables['test.install'], 'true') diff --git a/requirements-dev.txt b/requirements-dev.txt index 34df16d98..e4c0f0256 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,3 +2,5 @@ black==22.3.0 pytest>=6 pytest-cov scipy>=1.3.2 +setuptools_scm[toml]>=6.4.2,<7.0.0 +oldest_supported_numpy From bba40bed59561409786cdbbb12a92015395675b0 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:21:52 +0100 Subject: [PATCH 07/33] MAINT: Switch to environ var --- README.md | 9 +++++---- appveyor.yml | 2 +- setup.py | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d202edd97..939aabce0 100644 --- a/README.md +++ b/README.md @@ -153,19 +153,19 @@ test suite where still relevant. Either install from PyPi using ```bash -pip install randomgen +python -m pip install randomgen ``` or, if you want the latest version, ```bash -pip install git+https://github.com/bashtage/randomgen.git +python -m pip install git+https://github.com/bashtage/randomgen.git ``` or from a cloned repo, ```bash -python setup.py install +python -m pip install . ``` If you use conda, you can install using conda forge @@ -180,7 +180,8 @@ conda install -c conda-forge randomgen or are building on non-x86, you can install using: ```bash -python setup.py install --no-sse2 +export RANDOMGEN_NO_SSE2=1 +python -m pip install . ``` ### Windows diff --git a/appveyor.yml b/appveyor.yml index 9632f525f..f47e0fe13 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,7 +23,7 @@ build_script: - conda update conda --quiet - conda install numpy cython nose pandas pytest scipy --quiet - conda install -c numba numba --quiet - - python setup.py develop + - python -m pip install -e . - set "GIT_DIR=%cd%" test_script: diff --git a/setup.py b/setup.py index 7ba905354..b8ecb59e8 100644 --- a/setup.py +++ b/setup.py @@ -54,8 +54,11 @@ print("Processor appears to be ARM") USE_SSE2 = INTEL_LIKE print("Building with SSE?: {0}".format(USE_SSE2)) -if "--no-sse2" in sys.argv: +NO_SSE2 = os.environ.get("RANDOMGEN_NO_SSE2", False) in (1, "1", "True", "true") +NO_SSE2 = NO_SSE2 or "--no-sse2" in sys.argv +if NO_SSE2: USE_SSE2 = False +if "--no-sse2" in sys.argv: sys.argv.remove("--no-sse2") MOD_DIR = "./randomgen" From 3b9512aa9f3676474cd37e6ddb17296e9a1f6759 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:28:19 +0100 Subject: [PATCH 08/33] MAINT: Update cirrus --- ci/cirrus-install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 98f372f3f..2ba8c50f0 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -pkg install -y python39 py39-pip py39-numpy py39-cython py39-pytest -python3.9 -m pip install -e . --no-build-isolation --user - +pkg install -y python39 py39-numpy py39-cython wget +python -m ensurepip --upgrade +# wget https://bootstrap.pypa.io/get-pip.py +# python get-pip.py +python3.9 -m pip install pytest --user +python3.9 -m pip install -e . --no-build-isolation --user From 9bf4450a63e1ca5ae67ed396045b9e0de01219e4 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:31:08 +0100 Subject: [PATCH 09/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 66cc58cce..4883687fa 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ --- kind: pipeline -type: exec +type: docker name: test-on-arm64 platform: From cd0e30292ac82c17932406c85e3ff6e303ec387a Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:33:56 +0100 Subject: [PATCH 10/33] MAINT: Improve drone --- .drone.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4883687fa..85954ec4f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,11 +13,12 @@ steps: image: ubuntu:latest commands: - uname -a - - apt-get update + - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C + - sudo apt-get update - export DEBIAN_FRONTEND=noninteractive - apt-get install libatlas-base-dev build-essential cython3 python3-numpy python3 python3-dev python3-pip libxml2-dev libxslt-dev python3-lxml -y - gcc tools/long_double_sizes.c -o long_double_sizes && ./long_double_sizes - - pip3 install -r requirements.txt --upgrade - - pip3 install -r requirements-dev.txt - - pip3 install -e . --no-build-isolation + - python3 -m pip install -r requirements.txt --upgrade + - python3 -m pip install -r requirements-dev.txt + - python3 -m pip install -e . --no-build-isolation - pytest -r a randomgen From d1ccbeb3f20a3e808847fecbd92993905880a569 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:34:41 +0100 Subject: [PATCH 11/33] MAINT: Improve drone --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 85954ec4f..d0571b2ca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,8 +13,8 @@ steps: image: ubuntu:latest commands: - uname -a - - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - - sudo apt-get update + - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C + - apt-get update - export DEBIAN_FRONTEND=noninteractive - apt-get install libatlas-base-dev build-essential cython3 python3-numpy python3 python3-dev python3-pip libxml2-dev libxslt-dev python3-lxml -y - gcc tools/long_double_sizes.c -o long_double_sizes && ./long_double_sizes From 6c610ffdd33a17030bcc2c0a32d7004a94b5c6d3 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:36:38 +0100 Subject: [PATCH 12/33] MAINT: Improve drone --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index d0571b2ca..bf70260a8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,6 +13,7 @@ steps: image: ubuntu:latest commands: - uname -a + - apt-get install gnupg - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive From 9d49d53d7be70d33924a6bdd9303df402f9b1b54 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:37:19 +0100 Subject: [PATCH 13/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bf70260a8..eb7ca0416 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: image: ubuntu:latest commands: - uname -a - - apt-get install gnupg + - apt-get install gnupg2 - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive From bef3904b295a56d78f4130241f78cbb33c45ee2d Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:39:26 +0100 Subject: [PATCH 14/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index eb7ca0416..71246104d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,7 +10,7 @@ platform: steps: - name: test - image: ubuntu:latest + image: ubuntu:focal commands: - uname -a - apt-get install gnupg2 From 5de1d0e754435e92e2dfdfafb8487ad466b12c08 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:40:20 +0100 Subject: [PATCH 15/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 71246104d..3baea1ea4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: image: ubuntu:focal commands: - uname -a - - apt-get install gnupg2 + - apt-get install gpgv - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive From 894486a02242423270a8a2f48781b3639a5a89bf Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:41:34 +0100 Subject: [PATCH 16/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3baea1ea4..860a54820 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: image: ubuntu:focal commands: - uname -a - - apt-get install gpgv + - ln -s /usr/bin/gpgv /usr/bin/gnupg2 - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive From b009ef4b1c1def7a3d67fb93e730002d85796d9c Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:42:51 +0100 Subject: [PATCH 17/33] MAINT: Improve drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 860a54820..406b2a8c0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: commands: - uname -a - ln -s /usr/bin/gpgv /usr/bin/gnupg2 - - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C + # - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive - apt-get install libatlas-base-dev build-essential cython3 python3-numpy python3 python3-dev python3-pip libxml2-dev libxslt-dev python3-lxml -y From 7b183cc26c9985365d7315f2fc5e6c48cc61caf1 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:47:34 +0100 Subject: [PATCH 18/33] MAINT: Update cirrus --- ci/cirrus-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 2ba8c50f0..68f470673 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -2,7 +2,7 @@ pkg install -y python39 py39-numpy py39-cython wget -python -m ensurepip --upgrade +python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py python3.9 -m pip install pytest --user From d08b1361995915b36a5694bb27804169418cc32b Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 12:51:11 +0100 Subject: [PATCH 19/33] MAINT: Update CI --- ci/azure/azure_template_posix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index 133d9f092..34fb69cb6 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -95,7 +95,7 @@ jobs: echo "Installing to site packages" python -m pip wheel . -w wheelhouse/ WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) - pip install ./wheelhouse/${WHL} + pip install ${WHL} displayName: 'Install randomgen (site-packages)' condition: eq(variables['test.install'], 'true') From dc56a052a0903e602fa59ab2b20154cfd75fe2bb Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 14:19:03 +0100 Subject: [PATCH 20/33] MAINT: Update drone and cirrus --- .drone.yml | 2 +- ci/cirrus-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 406b2a8c0..8c5f776bd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,7 @@ steps: # - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C - apt-get update - export DEBIAN_FRONTEND=noninteractive - - apt-get install libatlas-base-dev build-essential cython3 python3-numpy python3 python3-dev python3-pip libxml2-dev libxslt-dev python3-lxml -y + - apt-get install libatlas-base-dev build-essential cython3 python3-numpy python3 python3-dev python3-pip libxml2-dev libxslt-dev python3-lxml git -y - gcc tools/long_double_sizes.c -o long_double_sizes && ./long_double_sizes - python3 -m pip install -r requirements.txt --upgrade - python3 -m pip install -r requirements-dev.txt diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 68f470673..50a261f7b 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -5,5 +5,5 @@ pkg install -y python39 py39-numpy py39-cython wget python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py -python3.9 -m pip install pytest --user +python3.9 -m pip install pytest wheel --user python3.9 -m pip install -e . --no-build-isolation --user From 9bca9779c5b85197115fa5c9cc46f30c9e38aa39 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 14:24:18 +0100 Subject: [PATCH 21/33] MAINT: Update azure --- ci/azure/azure_template_posix.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index 34fb69cb6..9bf5c8dc0 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -50,7 +50,6 @@ jobs: python.version: '3.7' use.conda: true coverage: false - NUMPY: 1.17.4 TEST_INSTALL: true ${{ if eq(parameters.name, 'macOS') }}: python39_latest_macos: From 35db271ffa78fbe3d844bdb0522c39eb680066b1 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 14:24:59 +0100 Subject: [PATCH 22/33] MAINT: Update azure --- ci/azure/azure_template_posix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/azure/azure_template_posix.yml b/ci/azure/azure_template_posix.yml index 9bf5c8dc0..cd5067bd1 100644 --- a/ci/azure/azure_template_posix.yml +++ b/ci/azure/azure_template_posix.yml @@ -50,7 +50,7 @@ jobs: python.version: '3.7' use.conda: true coverage: false - TEST_INSTALL: true + test.install: true ${{ if eq(parameters.name, 'macOS') }}: python39_latest_macos: python.version: '3.9' From e79b7a8eaad3ca635a106f30aa9a04ba6bf25f7f Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 23:10:59 +0100 Subject: [PATCH 23/33] MAINT: Improve cirrus --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index e2731c629..b6b4372b6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,4 +3,4 @@ freebsd_instance: task: install_script: . ./ci/cirrus-install.sh - script: pytest-3.8 randomgen + script: python3.9 -m pytest randomgen From 86559278fbd69a027a88de74510f434da828379f Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 23:21:46 +0100 Subject: [PATCH 24/33] MAINT: Improve cirrus --- ci/cirrus-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 50a261f7b..5204188ca 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -6,4 +6,4 @@ python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py python3.9 -m pip install pytest wheel --user -python3.9 -m pip install -e . --no-build-isolation --user +python3.9 -m pip install -e . --user From a2775750934727cbaca0ee92bb93bd1fc847886d Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 23:33:01 +0100 Subject: [PATCH 25/33] MAINT: Improve cirrus --- ci/cirrus-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 5204188ca..6897d8847 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -pkg install -y python39 py39-numpy py39-cython wget +pkg install -y python39 py39-numpy py39-cython wget git python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py From 9cf18ee81279899a2ea93aeeb8fe54a4e7c4102f Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Tue, 17 May 2022 23:51:58 +0100 Subject: [PATCH 26/33] MAINT: Improve cirrus --- ci/cirrus-install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 6897d8847..dd0fe5cf9 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -6,4 +6,7 @@ python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py python3.9 -m pip install pytest wheel --user -python3.9 -m pip install -e . --user +python3.9 -m pip install . --user +# python3.9 -m pip wheel . -w wheelhouse/ +# WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) +# python3.9 -m pip install install ${WHL} --user From 4f713b2552c324a962eacf68fb12640e77601576 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 00:04:20 +0100 Subject: [PATCH 27/33] MAINT: Improve cirrus --- ci/cirrus-install.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index dd0fe5cf9..8294e8013 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -6,7 +6,6 @@ python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py python3.9 -m pip install pytest wheel --user -python3.9 -m pip install . --user -# python3.9 -m pip wheel . -w wheelhouse/ -# WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) -# python3.9 -m pip install install ${WHL} --user +python3.9 -m pip wheel . -w wheelhouse/ +WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) +python3.9 -m pip install install ${WHL} --user From 5c61d9f6a70c9a3b8aad817c7a8f95b7891b6fec Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 00:05:06 +0100 Subject: [PATCH 28/33] MAINT: Improve cirrus --- ci/cirrus-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 8294e8013..78c9a4a68 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -5,7 +5,7 @@ pkg install -y python39 py39-numpy py39-cython wget git python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py -python3.9 -m pip install pytest wheel --user +python3.9 -m pip install pytest wheel python3.9 -m pip wheel . -w wheelhouse/ WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) -python3.9 -m pip install install ${WHL} --user +python3.9 -m pip install install ${WHL} From 6185be805c68fba84f50e38c458823328accef64 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 00:20:05 +0100 Subject: [PATCH 29/33] MAINT: Improve cirrus --- .cirrus.yml | 2 +- ci/cirrus-install.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index b6b4372b6..314d1cfd2 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,4 +3,4 @@ freebsd_instance: task: install_script: . ./ci/cirrus-install.sh - script: python3.9 -m pytest randomgen + script: python3.9 -m pytest randomgen/tests diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 78c9a4a68..57ec00c67 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -6,6 +6,7 @@ python3.9 -m ensurepip --upgrade # wget https://bootstrap.pypa.io/get-pip.py # python get-pip.py python3.9 -m pip install pytest wheel -python3.9 -m pip wheel . -w wheelhouse/ +python3.9 -m pip wheel . -w wheelhouse/ --no-build-isolation +ls -t wheelhouse/* WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) python3.9 -m pip install install ${WHL} From 1f76865c3fed24a41ec8a5c0f1acc8dc58989ddf Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 08:51:40 +0100 Subject: [PATCH 30/33] MAINT: Update CI --- .cirrus.yml | 3 ++- ci/cirrus-install.sh | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 314d1cfd2..bcd60d9a7 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,4 +3,5 @@ freebsd_instance: task: install_script: . ./ci/cirrus-install.sh - script: python3.9 -m pytest randomgen/tests + script: echo $PWD && python -c "import randomgen; randomgen.test()" + diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 57ec00c67..f3e7822bb 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -3,10 +3,9 @@ pkg install -y python39 py39-numpy py39-cython wget git python3.9 -m ensurepip --upgrade -# wget https://bootstrap.pypa.io/get-pip.py -# python get-pip.py -python3.9 -m pip install pytest wheel -python3.9 -m pip wheel . -w wheelhouse/ --no-build-isolation -ls -t wheelhouse/* -WHL=$(ls -t wheelhouse/randomgen-*.whl | head -n1) -python3.9 -m pip install install ${WHL} +python3.9 -m pip install wheel setuptools_scm[toml] pytest +python3.9 -m pip list +python3.9 -m pip install -e . --no-build-isolation +mkdir test-dir +pushd test-dir +echo $PWD From 7176c032cf028cd42c5f7bc33e190ada983fbf08 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 08:57:52 +0100 Subject: [PATCH 31/33] MAINT: Update CI --- .cirrus.yml | 3 ++- ci/cirrus-install.sh | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index bcd60d9a7..587d81b5f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,5 +3,6 @@ freebsd_instance: task: install_script: . ./ci/cirrus-install.sh - script: echo $PWD && python -c "import randomgen; randomgen.test()" + script: mkdir test_dir && cd test_dir && echo $PWD && python -c "import randomgen; randomgen.test()" + diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index f3e7822bb..95a454149 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -5,7 +5,5 @@ pkg install -y python39 py39-numpy py39-cython wget git python3.9 -m ensurepip --upgrade python3.9 -m pip install wheel setuptools_scm[toml] pytest python3.9 -m pip list +git fetch --tags python3.9 -m pip install -e . --no-build-isolation -mkdir test-dir -pushd test-dir -echo $PWD From 452eadeee44eb1cfb4085c83f64c0c43ccb65b0a Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 09:10:14 +0100 Subject: [PATCH 32/33] MAINT: Update CI --- ci/cirrus-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/cirrus-install.sh b/ci/cirrus-install.sh index 95a454149..7902c0b1e 100644 --- a/ci/cirrus-install.sh +++ b/ci/cirrus-install.sh @@ -6,4 +6,5 @@ python3.9 -m ensurepip --upgrade python3.9 -m pip install wheel setuptools_scm[toml] pytest python3.9 -m pip list git fetch --tags -python3.9 -m pip install -e . --no-build-isolation +python3.9 -m pip install . --no-build-isolation + From bce30b7bcc1596438d4f441881dcfab3a0468395 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Wed, 18 May 2022 09:17:15 +0100 Subject: [PATCH 33/33] MAINT: Update CI --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 587d81b5f..2c76ba460 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,6 +3,6 @@ freebsd_instance: task: install_script: . ./ci/cirrus-install.sh - script: mkdir test_dir && cd test_dir && echo $PWD && python -c "import randomgen; randomgen.test()" + script: mkdir test_dir && cd test_dir && echo $PWD && python3.9 -c "import randomgen; randomgen.test()"