Code Monkey home page Code Monkey logo

incremental's Introduction

Incremental

gha pypi coverage

Incremental is a small library that versions your Python projects.

API documentation can be found here.

Quick Start

Add this to your setup.py's setup() call, removing any other versioning arguments:

setup(
    use_incremental=True,
    setup_requires=['incremental'],
    install_requires=['incremental'], # along with any other install dependencies
    ...
}

Install Incremental to your local environment with pip install incremental[scripts]. Then run python -m incremental.update <projectname> --create. It will create a file in your package named _version.py and look like this:

from incremental import Version

__version__ = Version("widgetbox", 17, 1, 0)
__all__ = ["__version__"]

Then, so users of your project can find your version, in your root package's __init__.py add:

from ._version import __version__

Subsequent installations of your project will then use Incremental for versioning.

Incremental Versions

incremental.Version is a class that represents a version of a given project. It is made up of the following elements (which are given during instantiation):

  • package (required), the name of the package this Version represents.
  • major, minor, micro (all required), the X.Y.Z of your project's Version.
  • release_candidate (optional), set to 0 or higher to mark this Version being of a release candidate (also sometimes called a "prerelease").
  • post (optional), set to 0 or higher to mark this Version as a postrelease.
  • dev (optional), set to 0 or higher to mark this Version as a development release.

You can extract a PEP-440 compatible version string by using the .public() method, which returns a str containing the full version. This is the version you should provide to users, or publicly use. An example output would be "13.2.0", "17.1.2dev1", or "18.8.0rc2".

Calling repr() with a Version will give a Python-source-code representation of it, and calling str() with a Version will provide a string similar to '[Incremental, version 16.10.1]'.

Updating

Incremental includes a tool to automate updating your Incremental-using project's version called incremental.update. It updates the _version.py file and automatically updates some uses of Incremental versions from an indeterminate version to the current one. It requires click from PyPI.

python -m incremental.update <projectname> will perform updates on that package. The commands that can be given after that will determine what the next version is.

  • --newversion=<version>, to set the project version to a fully-specified version (like 1.2.3, or 17.1.0dev1).
  • --rc, to set the project version to <year-2000>.<month>.0rc1 if the current version is not a release candidate, or bump the release candidate number by 1 if it is.
  • --dev, to set the project development release number to 0 if it is not a development release, or bump the development release number by 1 if it is.
  • --patch, to increment the patch number of the release. This will also reset the release candidate number, pass --rc at the same time to increment the patch number and make it a release candidate.
  • --post, to set the project postrelease number to 0 if it is not a postrelease, or bump the postrelease number by 1 if it is. This will also reset the release candidate and development release numbers.

If you give no arguments, it will strip the release candidate number, making it a "full release".

Incremental supports "indeterminate" versions, as a stand-in for the next "full" version. This can be used when the version which will be displayed to the end-user is unknown (for example "introduced in" or "deprecated in"). Incremental supports the following indeterminate versions:

  • Version("<projectname>", "NEXT", 0, 0)
  • <projectname> NEXT

When you run python -m incremental.update <projectname> --rc, these will be updated to real versions (assuming the target final version is 17.1.0):

  • Version("<projectname>", 17, 1, 0, release_candidate=1)
  • <projectname> 17.1.0rc1

Once the final version is made, it will become:

  • Version("<projectname>", 17, 1, 0)
  • <projectname> 17.1.0

incremental's People

Contributors

adiroiban avatar cjwatson avatar glyph avatar graingert avatar hawkowl avatar hugovk avatar mthuurne avatar rodrigc avatar sbraz avatar tdsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

incremental's Issues

Cannot make the incremental to run on Python 3.7.6 and Ubuntu 18.04.4

Trying to use incremental in my own project, but it failed.

$ pip install -e mypkg
    ERROR: Command errored out with exit status 1:
     command: /home/adam/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/adam/mypkg/setup.py'"'"'; __file__='"'"'/home/adam/mypkg/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: /home/adam/mypkg/
    Complete output (19 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/adam/mypkg/setup.py", line 16, in <module>
        ''')
      File "/home/adam/venv/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/home/adam/spack/opt/spack/linux-linuxmint19-skylake/gcc-7.4.0/python-3.7.6-hf457cjp5qzyqa4avicanq2s5gs7tiyu/lib/python3.7/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/adam/venv/lib/python3.7/site-packages/setuptools/dist.py", line 448, in __init__
        k: v for k, v in attrs.items()
      File "/home/adam/spack/opt/spack/linux-linuxmint19-skylake/gcc-7.4.0/python-3.7.6-hf457cjp5qzyqa4avicanq2s5gs7tiyu/lib/python3.7/distutils/dist.py", line 292, in __init__
        self.finalize_options()
      File "/home/adam/venv/lib/python3.7/site-packages/setuptools/dist.py", line 740, in finalize_options
        ep.load()(self)
      File "/home/adam/venv/lib/python3.7/site-packages/setuptools/dist.py", line 747, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File "/home/adam/venv/lib/python3.7/site-packages/incremental/__init__.py", line 344, in _get_version
        dist.metadata.version = version_file["__version__"].public()
    AttributeError: 'str' object has no attribute 'public'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

setup.py:

from setuptools import setup, find_packages
setup(name='loginspottercli',
      use_incremental=True,
      author="Adam Ryczkowski",
      packages=find_packages(),
      include_package_data=True,
      install_requires=[
      'requests',
      'click',
      'url_normalize',
      'tabulate'
      ],
      entry_points='''
      [console_scripts]
      mypkg=mypkg.mypkg:main
    ''')

and _version.py:

from incremental import Version

__version__ = Version("mypkg", 0, 9, 3)
__all__ = ["__version__"]

git lookup fails against packed-refs, in a downstream project

I noticed a strange test failure in my magic-wormhole project yesterday. The exact message was:

[ERROR]
Traceback (most recent call last):
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 508, in loadPackage
    module = modinfo.load()
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/modules.py", line 392, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/reflect.py", line 301, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/reflect.py", line 240, in _importAndCheckStack
    return __import__(importName)
  File "/home/warner/stuff/tahoe/magic-wormhole/src/wormhole/test/test_tor_manager.py", line 8, in <module>
    from ..tor_manager import TorManager, DEFAULT_VALUE
  File "/home/warner/stuff/tahoe/magic-wormhole/src/wormhole/tor_manager.py", line 9, in <module>
    from txtorcon import (TorConfig, launch_tor, build_tor_connection,
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/txtorcon/__init__.py", line 16, in <module>
    from txtorcon.controller import connect
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/txtorcon/controller.py", line 34, in <module>
    from txtorcon.torconfig import TorConfig
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/txtorcon/torconfig.py", line 34, in <module>
    stdout=None, stderr=None):
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/deprecate.py", line 293, in deprecationDecorator
    function, version, None, replacement)
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/deprecate.py", line 238, in getDeprecationWarningString
    _fullyQualifiedName(callableThing), version, format, replacement)
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/twisted/python/deprecate.py", line 198, in _getDeprecationWarningString
    'version': getVersionString(version)}
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/incremental/__init__.py", line 518, in getVersionString
    result = '%s %s' % (version.package, version.short())
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/incremental/__init__.py", line 221, in short
    gitver = self._getGitVersion()
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/incremental/__init__.py", line 422, in _getGitVersion
    return self._parseGitDir(os.path.join(upOneMore, '.git'))
  File "/home/warner/stuff/tahoe/magic-wormhole/.tox/py27/local/lib/python2.7/site-packages/incremental/__init__.py", line 395, in _parseGitDir
    headContent.split(" ")[1]))) as f:
exceptions.IOError: [Errno 2] No such file or directory: '/home/warner/stuff/tahoe/magic-wormhole/.git/refs/heads/master'

wormhole.test.test_tor_manager
===============================================================================

magic-wormhole uses @meejah's txtorcon, which has a (twisted.python.deprecate.)@deprecated wrapper around one function that we call. This wrapper uses an incremental.Version object. When Twisted pulls the version string out of the Version object, it calls an Incremental function which then uses _getGitVersion() to find the exact SHA1 string.

Incremental is assuming that Git repositories always store their references in discrete files, in .git/refs/heads/$NAME. But if you have several branches, and then do a git gc, Git may decide to combine everything under .git/refs/heads/* into a single file (with one ref per line) in .git/packed-refs. The Incremental function fails here.

It's also not clear to me that Incremental should be touching Git at all, in most situations. The @deprecate(Version(..)) wrapper that txtorcon uses is referring to a txtorcon version, but the git tree that is being scanned here is for magic-wormhole (my Tox run is using whatever txtorcon release is most current and meets my setup.py requirements, in this case 0.19.1, installed from a tarball or wheel that tox/pip downloaded from pypi). The txtorcon git tree is long gone.

Versioneer deals with this by modifying _version.py when the project is "built", which includes (among other things) creating a wheel or sdist tarball, so the version string is frozen at the same time the code is frozen. The only time Git is touched is when you're running or testing from the git checkout (for the top-level project), or when you build a sdist/wheel from a checkout. And Versioneer runs git directly, to avoid making assumptions about the internal layout of a .git directory (which might not even be in the same directory as the source tree, if the right environment variables are set).

I'm not sure what the best fix for this would be.. at the very least, the search for .git/refs/heads/NAME needs to be enhanced to read .git/packed-refs too. But I suspect that the entire notion of reading a version from Git needs to be revisited.

Auto generated file is not compatible with black

Is it possible to either make it compatible or have a --black-compatible explicit flag?

(I redacted the name of the internal project below, everything else is copy/paste.)

$ black src/
reformatted /Users/mzadka/src/<REDACTED>/src/<REDACTED>/_version.py
All done! ✨ 🍰 ✨
1 file reformatted, 12 files left unchanged.
$ git diff
diff --git a/src/<REDACTED>/_version.py b/src/<REDACTED>/_version.py
index a4efef1..1cc8fa1 100644
--- a/src/<REDACTED>/_version.py
+++ b/src/<REDACTED>/_version.py
@@ -7,5 +7,5 @@ Provides <REDACTED> version information.
 
 from incremental import Version
 
-__version__ = Version('<REDACTED>', 20, 7, 1)
+__version__ = Version("<REDACTED>", 20, 7, 1)
 __all__ = ["__version__"]

Bump major or minor number

Have we any way to bump major/minor number incremental? I dont find solution in incremental.update - only last number.

_getGitVersion failure when installs with pip from a branch

I get this on both python2 and python3 on Ubuntu 16/04

Here are the steps to reproduce:

virtualenv --python=python3 9083-twisted-dev/
cd 9083-twisted-dev/
. bin/activate
pip install "git+https://github.com/buildbot/[email protected]#subdirectory=pkg"
pip install "git+https://github.com/buildbot/[email protected]#subdirectory=master"
pip install "git+https://github.com/buildbot/[email protected]#subdirectory=worker"
pip install --upgrade "git+https://github.com/twisted/twisted"
pip install --upgrade "git+https://github.com/twisted/twisted@9083-rodrigc-version"

I end up with this traceback

$ buildbot create-master
Traceback (most recent call last):
  File "/home/adi/tmp/9083-twisted-dev/bin/buildbot", line 11, in <module>
    load_entry_point('buildbot==0.9.5', 'console_scripts', 'buildbot')()
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/scripts/runner.py", line 757, in run
    subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/twisted/python/reflect.py", line 166, in namedObject
    module = namedModule('.'.join(classSplit[:-1]))
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/twisted/python/reflect.py", line 152, in namedModule
    topLevel = __import__(name)
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/scripts/create_master.py", line 30, in <module>
    from buildbot.master import BuildMaster
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/master.py", line 39, in <module>
    from buildbot.buildbot_net_usage_data import sendBuildbotNetUsageData
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/buildbot_net_usage_data.py", line 36, in <module>
    from buildbot.process.buildstep import _BuildStepFactory
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/process/buildstep.py", line 261, in <module>
    util.ComparableMixin):
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/buildbot/process/buildstep.py", line 380, in BuildStep
    @deprecate.deprecated(versions.Version("buildbot", 0, 9, 0))
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/twisted/python/deprecate.py", line 293, in deprecationDecorator
    function, version, None, replacement)
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/twisted/python/deprecate.py", line 238, in getDeprecationWarningString
    _fullyQualifiedName(callableThing), version, format, replacement)
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/twisted/python/deprecate.py", line 198, in _getDeprecationWarningString
    'version': getVersionString(version)}
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/incremental/__init__.py", line 518, in getVersionString
    result = '%s %s' % (version.package, version.short())
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/incremental/__init__.py", line 221, in short
    gitver = self._getGitVersion()
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/incremental/__init__.py", line 422, in _getGitVersion
    return self._parseGitDir(os.path.join(upOneMore, '.git'))
  File "/home/adi/tmp/9083-twisted-dev/lib/python3.5/site-packages/incremental/__init__.py", line 389, in _parseGitDir
    with open(headFile, "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/adi/.git/HEAD'

CI is broken on master

because Travis has upgraded its default Python to 2.7 and pydoctor doesn't work with py3 yet

A proper way to reference version number in setup.cfg/setup.py?

As per README, one can import the version number from __init__.py, which makes it accessible after all packages have been installed. However, a problem arises when referencing my package's version number in my setup.cfg like so:

[metadata]
name = mypackage
version = attr: mypackage.__version__

Setuptools complains that my package's dependencies are not installed. This is because __init__.py contains import statements for other packages like numpy.

One workaround is to create a submodule within mypackage/ called "versioning":

cd mypackage
python -m incremental.update versioning --rc

Next, define mypackage/versioning/__init__.py like this:

# needed for setuptools to resolve appropriate version
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__)))

from ._version import __version__
# the default package name will be "versioning", so override with this file's grandparent directory
__version__.package = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# need a method that renders the package name
def _setuptools_version():  # type: () -> str
    return __version__.public()

Now you can reference the version number in setup.cfg/setup.py without importing your project's dependencies:

[metadata]
name = mypackage
version = attr: mypackage.versioning._setuptools_version

Ignore .pyc files

It doesn't seem like incremental should mangle bytecode files:

❯ .tox/twine/bin/python -m incremental.update --rc treq
Updating codebase to 20.9.0rc1
Updating /home/twm/dev/treq/src/treq/__pycache__/api.cpython-37.pyc
Updating /home/twm/dev/treq/src/treq/__pycache__/api.cpython-36.pyc

Observed with incremental 17.5.0

License not included in install from PyPi

image

I was going through the libraries I use to collect licenses since I distribute my application using pyqtdeploy on Windows and noticed that incremental did not seem to include it's own license when installed from PyPi.

sdist is missing tests

The sdist at PyPI is missing tests. Namely, there are missing both examplesetup.py and tests/test_exampleproj.py files, but tox.ini is included in the sdist. Please add missing files for testing support to the sdist. Thank you.

Have PEP440 normalized release candidate

This change was introduced here https://github.com/twisted/incremental/pull/62/files#diff-37e20d1852a6db96a5d77c800f2007c0265b65a30a62649dbb7c0fd1228eef72R207

From PEP440 https://peps.python.org/pep-0440/#pre-release-separators

Pre-releases should allow a ., -, or _ separator between the release segment and the pre-release segment. The normal form for this is without a separator. This allows versions such as 1.1.a1 or 1.1-a1 which would be normalized to 1.1a1. It should also allow a separator to be used between the pre-release signifier and the numeral. This allows versions such as 1.0a.1 which would be normalized to 1.0a1.


I am reporting this issue as in Towncrier there is a test that checks that towncrier version is the same as the importlib version ... but for a release candidate, the test fails.


I am not sure if this is a valid bug report, as in theory the current format is still valid PEP440, is just that it is not normalized.

`exampleproj` package gets installed

incremental 17.5.0 installs the exampleproj package:

$ wget https://files.pythonhosted.org/packages/f5/1d/c98a587dc06e107115cf4a58b49de20b19222c83d75335a192052af4c4b7/incremental-17.5.0-py2.py3-none-any.whl
$ unzip -l incremental-17.5.0-py2.py3-none-any.whl
Archive:  incremental-17.5.0-py2.py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
      229  2017-05-19 18:48   exampleproj/__init__.py
      220  2017-05-19 18:48   exampleproj/_version.py
     9213  2017-05-20 17:48   incremental/__init__.py
      272  2017-05-20 17:59   incremental/_version.py
     6150  2017-05-19 18:48   incremental/update.py
        0  2017-05-19 18:48   incremental/tests/__init__.py
    23630  2017-05-19 18:48   incremental/tests/test_update.py
    14700  2017-05-20 17:48   incremental/tests/test_version.py
     4818  2017-05-23 17:16   incremental-17.5.0.dist-info/DESCRIPTION.rst
       83  2017-05-23 17:16   incremental-17.5.0.dist-info/entry_points.txt
     1032  2017-05-23 17:16   incremental-17.5.0.dist-info/metadata.json
       12  2017-05-23 17:16   incremental-17.5.0.dist-info/top_level.txt
      110  2017-05-23 17:16   incremental-17.5.0.dist-info/WHEEL
     5651  2017-05-23 17:16   incremental-17.5.0.dist-info/METADATA
     1293  2017-05-23 17:16   incremental-17.5.0.dist-info/RECORD
---------                     -------
    67413                     15 files

This problem existed before, see #20. I don't know if the fix didn't work or it got broken again later.

Support local version identifiers

PEP 440 defines local version identifiers which can be used when applying local patches to upstream projects. For example, in Launchpad we occasionally have to backport fixes from later releases that we can't upgrade to wholesale yet, or apply patches that haven't been integrated yet upstream; we do this by making distributions with local version identifiers that we commit to a git repository containing our dependencies.

This works fine with most Python projects, but it's awkward for ones that use incremental because incremental doesn't directly support local version identifiers: there's a Version.local, but it's just equal to Version.public. Let's say we're making a fork of Twisted 20.3.0, which has:

__version__ = Version('Twisted', 20, 3, 0)

Ideally we'd just be able to change that to something like:

__version__ = Version('Twisted', 20, 3, 0, local='lp1')

... and have that generate 20.3.0+lp1. However, since incremental doesn't support local version identifiers and since Twisted uses __version__.short(), I guess we end up doing something like this (obviously incomplete, but just for the purpose of getting distribution files with the right version number in them):

class LocalVersion(Version):
    def __init__(self, *args, **kwargs):
        self._local = kwargs.pop('local')
        super(LocalVersion, self).__init__(*args, **kwargs)

    def public(self):
        public = super(LocalVersion, self).public()
        if self._local:
            public += '+%s' % self._local
        return public

__version__ = LocalVersion('Twisted', 20, 3, 0, local='lp1')

Or alternatively I suppose that we could make src/twisted/__init__.py say:

__version__ = version.short() + '+lp1'

Either way, this seems like a lot of awkwardness just to make a temporary local backport distribution! I think incremental could usefully help to make this easier.

Add support for NEXT placeholder in docstrings.

For example, we want to document that a module/package was introduced or deprecated in certain version.

It would be nice to have a docstring like

"""
This module does awesome things and brings peace.

Introduced in Twisted NEXT.
"""

We can keep PROJECT_NAME close to NEXT marker to reduce the probability of expanding NEXT in other cases.

--rc not honoring existing version number

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --newversion=0.6.0 --path hex_game burdenofcommand
Updating codebase to 0.6.0
Updating W:\BurdenOfCommand\hex_game/_version.py

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --rc --path hex_game burdenofcommand
Updating codebase to 20.1.0rc1
Updating W:\BurdenOfCommand\hex_game/_version.py

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --newversion=0.6.0 --path hex_game burdenofcommand
Updating codebase to 0.6.0
Updating W:\BurdenOfCommand\hex_game\_version.py
Updating W:\BurdenOfCommand\hex_game/_version.py

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --dev --path hex_game burdenofcommand
Updating codebase to 0.6.0dev0
Updating W:\BurdenOfCommand\hex_game/_version.py

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --dev --path hex_game burdenofcommand
Updating codebase to 0.6.0dev1
Updating W:\BurdenOfCommand\hex_game/_version.py

(BurdenOfCommand) W:\BurdenOfCommand>python -m incremental.update --rc --path hex_game burdenofcommand
Updating codebase to 20.1.0rc1
Updating W:\BurdenOfCommand\hex_game/_version.py

Using Python 3.7.6 and incremental 17.5.0

2022 release

Twisted is pinned to incremental trunk for type checking. I think we were stuck doing a release because nobody had the keys for a little bit, but that has long since been remedied. Let's have a new release?

Make PEP440 Compatible

Incremental handles prereleases with the "pre" tag, not the "rc" tag like PEP440 wants, and how setuptools has started normalising to. We should support "rc" (and output "rc" always, since Setuptools now normalises it whether you want it or not) and allow the pre=X kwarg for backwards compatibility.

Make it clear that 'use_incremental' is a custom setup extension

When used in external projects, at first I was confused about the use_incremental argument for setup as I thought it was a standard setuptools argument,

maybe it can be renamed x_use_incremental or some other name to suggest that if people want to know more about that argument they should search in hawkowl/incremental and not in setuptools

incremental dev version doesn't work with setuptools

I tried the following with buildbot in a Python 3 virtual environment:

pip install "git+https://github.com/buildbot/buildbot#subdirectory=pkg"
pip install "git+https://github.com/buildbot/buildbot#subdirectory=master"
pip install "git+https://github.com/buildbot/buildbot#subdirectory=worker"
pip install --upgrade "git+https://github.com/twisted/twisted"

I then ran this command:

buildbot create master

and got this error:

Traceback (most recent call last):
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 654, in _build_master
    ws.require(__requires__)
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 968, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 859, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (Twisted 17.1.0.dev0 (/Users/crodrigues/my_venv/lib/python3.6/site-packages), Requirement.parse('Twisted>=17.1.0'), {'buildbot'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/crodrigues/my_venv/bin/buildbot", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3036, in <module>
    @_call_aside
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3020, in _call_aside
    f(*args, **kwargs)
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3049, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 656, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 669, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/Users/crodrigues/my_venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 854, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Twisted>=17.1.0' distribution was not found and is required by buildbot

Downgrading to Twisted 17.1.0 then worked.

It looks like the versioning used by incremental doesn't work too well with setuptools.

It is nice to be able to test a trunk version of Twisted against third party code.

Incremental fails to get version from egg package

I am not aware of the current status of the egg-wheel transition thing and how relevant this issue is, but incremental fails to get the version of a package's egg because it did not expect it to be an .egg (or is not supposed to be used for that?). One of the consequences is that it won't allow any package (or its dependencies) to use Twisted's @deprecated if the Version provided is from an egg package.

unMessage is a package that depends on txtorcon and it is not possible to install it with python setup.py install (reported in AnemoneLabs/unmessage#29) because txtorcon uses @deprecated and is installed as an egg.

I think the easiest way to reproduce this is installing txtorcon with easy_install:

$ sudo easy_install txtorcon
$ python
>>> import txtorcon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/txtorcon/__init__.py", line 16, in <module>
  File "build/bdist.linux-x86_64/egg/txtorcon/controller.py", line 34, in <module>
  File "build/bdist.linux-x86_64/egg/txtorcon/torconfig.py", line 34, in <module>
  File "/usr/local/lib/python2.7/dist-packages/Twisted-17.1.0-py2.7-linux-x86_64.egg/twisted/python/deprecate.py", line 293, in deprecationDecorator
    function, version, None, replacement)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-17.1.0-py2.7-linux-x86_64.egg/twisted/python/deprecate.py", line 238, in getDeprecationWarningString
    _fullyQualifiedName(callableThing), version, format, replacement)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-17.1.0-py2.7-linux-x86_64.egg/twisted/python/deprecate.py", line 198, in _getDeprecationWarningString
    'version': getVersionString(version)}
  File "/usr/local/lib/python2.7/dist-packages/incremental-16.10.1-py2.7.egg/incremental/__init__.py", line 518, in getVersionString
    result = '%s %s' % (version.package, version.short())
  File "/usr/local/lib/python2.7/dist-packages/incremental-16.10.1-py2.7.egg/incremental/__init__.py", line 221, in short
    gitver = self._getGitVersion()
  File "/usr/local/lib/python2.7/dist-packages/incremental-16.10.1-py2.7.egg/incremental/__init__.py", line 411, in _getGitVersion
    if ".git" in os.listdir(upOne):
OSError: [Errno 20] Not a directory: '/usr/local/lib/python2.7/dist-packages/txtorcon-0.19.1-py2.7.egg'

This was reproduced on a Debian jessie with the following installed:

build-essential/stable,now 11.7 amd64 [installed]
libffi-dev/stable,now 3.1-2+b2 amd64 [installed]
libssl-dev/stable,now 1.0.1t-1+deb8u6 amd64 [installed]
python/stable,now 2.7.9-1 amd64 [installed]
python-dev/stable,now 2.7.9-1 amd64 [installed]
python-pyasn1/jessie-backports,now 0.1.9-1~bpo8+1 all [installed]
python-setuptools/jessie-backports,now 33.1.1-1~bpo8+1 all [installed]

Thanks!

21.3.0: pytest is failing

Just normal build, install and test cycle used on building package from non-root account:

  • "setup.py build"
  • "setup.py install --root </install/prefix>"
  • "pytest with PYTHONPATH pointing to setearch and sitelib inside </install/prefix>
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/incremental-incremental-21.3.0
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, hypothesis-6.14.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, Faker-8.10.0
collected 3 items / 2 errors / 1 selected

================================================================================== ERRORS ==================================================================================
__________________________________________________________ ERROR collecting src/incremental/tests/test_update.py ___________________________________________________________
import file mismatch:
imported module 'incremental.tests.test_update' has this __file__ attribute:
  /home/tkloczko/rpmbuild/BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib/python3.8/site-packages/incremental/tests/test_update.py
which is not the same as the test file we want to collect:
  /home/tkloczko/rpmbuild/BUILD/incremental-incremental-21.3.0/src/incremental/tests/test_update.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
__________________________________________________________ ERROR collecting src/incremental/tests/test_version.py __________________________________________________________
import file mismatch:
imported module 'incremental.tests.test_version' has this __file__ attribute:
  /home/tkloczko/rpmbuild/BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib/python3.8/site-packages/incremental/tests/test_version.py
which is not the same as the test file we want to collect:
  /home/tkloczko/rpmbuild/BUILD/incremental-incremental-21.3.0/src/incremental/tests/test_version.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
============================================================================= warnings summary =============================================================================
../../BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib/python3.8/site-packages/incremental/tests/test_update.py:15
  /home/tkloczko/rpmbuild/BUILDROOT/python-incremental-21.3.0-2.1.fc35.x86_64/usr/lib/python3.8/site-packages/incremental/tests/test_update.py:15: DeprecationWarning: twisted.python.compat.NativeStringIO was deprecated in Twisted 21.2.0: Use io.StringIO directly
    from twisted.python.compat import NativeStringIO

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
ERROR src/incremental/tests/test_update.py
ERROR src/incremental/tests/test_version.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================= 1 warning, 2 errors in 0.44s =======================================================================

Undeclared dependency: twisted

Undeclared dependency twisted. This causes python -m incremental.update ver_test1 --patch to fail, which feels wrong because I wasn't uploading to pypi.

± |master S:4 U:8 ✗| → python -m incremental.update ver_test1 --patch
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/martinmat/.virtualenvs/ver_test1/lib/python3.6/site-packages/incremental/update.py", line 11, in <module>
    from twisted.python.filepath import FilePath
ModuleNotFoundError: No module named 'twisted'

Circular dependency with Twisted

There's a circular dependency with Twisted. It'd be nice to get rid of that (cleaner and conceptually simpler dependency graph, and also less issues when packaging for Linux distributions).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.