more stuff :D

This commit is contained in:
Amber Brown (HawkOwl) 2015-11-29 23:09:05 +08:00
parent cfe78709ac
commit df177b96c1
7 changed files with 117 additions and 3 deletions

View File

@ -1,3 +1,6 @@
Incremental
-----------
This project includes code from the Twisted Project, which is licensed as below.
Copyright (c) 2001-2015

View File

@ -1,4 +1,66 @@
Incremental
===========
Incremental is a small library that versions your projects.
Incremental is a small library that versions your Python projects.
Quick Start
-----------
Add this to the top of your ``setup.py``, assuming your code is called ``widgetbox``:
.. code::
my_project = 'widgetbox'
import os, importlib
def install_incremental():
import importlib
try:
importlib.import_module('incremental')
except ImportError:
import pip
pip.main(['install', 'incremental>=0.1.0'])
finally:
globals()['incremental'] = importlib.import_module('incremental')
install_incremental()
# PICK ONE OF:
# If you have a src/ dir
base_dir = os.path.dirname(__file__)
src_dir = os.path.join(base_dir, "src")
# If you do not
src_dir = os.path.dirname(__file__)
version = incremental.get_version_from_project(my_project, src_dir)
And in the ``setup`` call, add:
.. code::
setup(
name=my_project,
version=version.base(),
...
}
Then in your project add a ``_version.py`` that contains:
.. code::
from incremental import Version
__version__ = Version("widgetbox", 1, 2, 3)
__all__ = ["__version__"]
Then in your project's ``__init__.py`` add:
.. code::
from ._version import __version__
Subsequent installations of your project will use incremental for versioning.

30
examplesetup.py Normal file
View File

@ -0,0 +1,30 @@
my_project = 'exampleproj'
import os, importlib
def install_incremental():
import importlib
try:
importlib.import_module('incremental')
except ImportError:
import pip
pip.main(['install', 'incremental>=15.0.0'])
finally:
globals()['incremental'] = importlib.import_module('incremental')
install_incremental()
# PICK ONE OF:
# If you have a src/ dir
base_dir = os.path.dirname(__file__)
src_dir = os.path.join(base_dir, "src")
version = incremental.get_version_from_project(my_project, src_dir)
# Install the package
from setuptools import setup
setup(
name=my_project,
version=version.base()
)

View File

@ -17,6 +17,8 @@ import incremental
setup(
name='incremental',
version=incremental.__version__.base(),
maintainer='Amber Brown',
maintainer_email='hawkowl@twistedmatrix.com',
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",

View File

@ -0,0 +1 @@
from ._version import __version__

View File

@ -0,0 +1,4 @@
from incremental import Version
__version__ = Version("exampleproj", 1, 2, 3)
__all__ = ["__version__"]

View File

@ -403,6 +403,18 @@ def getVersionString(version):
return result
__version__ = Version("incremental", 0, 1, 0)
def get_version_from_project(project, src_dir):
"""
Get a L{Version} object from a flat source directory.
"""
version_file = {}
__all__ = ["__version__", "Version"]
with open(os.path.join(src_dir, project, "_version.py")) as f:
exec(f.read(), version_file)
return version_file["__version__"]
__version__ = Version("incremental", 15, 0, 0)
__all__ = ["__version__", "Version", "get_version_from_project"]