Skip to content

Prepare semver 3 #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ script: tox -v

matrix:
include:
- python: "2.7"
env: TOXENV=py27

- python: "3.4"
env: TOXENV=py34

- python: "3.6"
env: TOXENV=checks
Expand All @@ -32,5 +27,13 @@ matrix:
dist: xenial
env: TOXENV=py37

- python: "pypy"
- python: "3.8"
dist: bionic
env: TOXENV=py38

- python: "nightly"
dist: bionic
env: TOXENV=py39

- python: "pypy3"
env: TOXENV=pypy
22 changes: 22 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ All notable changes to this code base will be documented in this file,
in every released version.


Version 3.0.0-dev.1
===================

Features
--------


Bug Fixes
---------


Additions
---------


Removals
--------



Version 2.10.1
==============

Expand All @@ -23,6 +43,7 @@ Features
* :pr:`256`: Made docstrings consistent



Bug Fixes
---------

Expand All @@ -38,6 +59,7 @@ Removals
--------



Version 2.10.0
==============

Expand Down
18 changes: 6 additions & 12 deletions semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import warnings


__version__ = "2.10.1"
__version__ = "3.0.0-dev.1"
__author__ = "Kostiantyn Rybnikov"
__author_email__ = "k-bx@k-bx.com"
__maintainer__ = ["Sebastien Celles", "Tom Schraitle"]
Expand Down Expand Up @@ -53,11 +53,9 @@
SEMVER_SPEC_VERSION = "2.0.0"


if not hasattr(__builtins__, "cmp"):

def cmp(a, b):
"""Return negative if a<b, zero if a==b, positive if a>b."""
return (a > b) - (a < b)
def cmp(a, b):
"""Return negative if a<b, zero if a==b, positive if a>b."""
return (a > b) - (a < b)


def deprecated(func=None, replace=None, version=None, category=DeprecationWarning):
Expand Down Expand Up @@ -88,10 +86,8 @@ def wrapper(*args, **kwargs):
else:
msg.append("Use the respective 'semver.VersionInfo.{r}' instead.")

# hasattr is needed for Python2 compatibility:
f = func.__qualname__ if hasattr(func, "__qualname__") else func.__name__
f = func.__qualname__
r = replace or f

frame = inspect.currentframe().f_back

msg = " ".join(msg)
Expand Down Expand Up @@ -300,9 +296,7 @@ def _asdict(self):

def __iter__(self):
"""Implement iter(self)."""
# As long as we support Py2.7, we can't use the "yield from" syntax
for v in self.to_tuple():
yield v
yield from self.to_tuple()

@staticmethod
def _increment_string(string):
Expand Down
74 changes: 11 additions & 63 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,17 @@
#!/usr/bin/env python
import semver as package
from glob import glob
from os import remove
from os.path import dirname, join
from setuptools import setup
from setuptools.command.test import test as TestCommand

try:
from setuptools.command.clean import clean as CleanCommand
except ImportError:
from distutils.command.clean import clean as CleanCommand
from shlex import split
from shutil import rmtree


class Tox(TestCommand):
user_options = [("tox-args=", "a", "Arguments to pass to tox")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
from tox import cmdline

args = self.tox_args
if args:
args = split(self.tox_args)
errno = cmdline(args=args)
exit(errno)


class Clean(CleanCommand):
def run(self):
CleanCommand.run(self)
delete_in_root = ["build", ".cache", "dist", ".eggs", "*.egg-info", ".tox"]
delete_everywhere = ["__pycache__", "*.pyc"]
for candidate in delete_in_root:
rmtree_glob(candidate)
for visible_dir in glob("[A-Za-z0-9]*"):
for candidate in delete_everywhere:
rmtree_glob(join(visible_dir, candidate))
rmtree_glob(join(visible_dir, "*", candidate))


def rmtree_glob(file_glob):
for fobj in glob(file_glob):
try:
rmtree(fobj)
print("%s/ removed ..." % fobj)
except OSError:
try:
remove(fobj)
print("%s removed ..." % fobj)
except OSError:
pass
import semver as package


def read_file(filename):
"""
Read RST file and return content

:param filename: the RST file
:return: content of the RST file
"""
with open(join(dirname(__file__), filename)) as f:
return f.read()

Expand Down Expand Up @@ -92,17 +41,16 @@ def read_file(filename):
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
python_requires=">=3.5.*",
tests_require=["tox", "virtualenv"],
cmdclass={"clean": Clean, "test": Tox},
entry_points={"console_scripts": ["pysemver = semver:main"]},
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
flake8
py{27,34,35,36,37}
py{35,36,37,38,39}
pypy

[testenv]
Expand Down