Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
hgtools: Autospec creation for version 8.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fenrus75 authored and clrpackages committed Mar 2, 2020
1 parent 9c021b6 commit 4ca9e6c
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 17 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.*~
*~
*.info
*.mod
*.swp
.repo-index
*.log
build.log.round*
*.tar.*
*.tgz
!*.tar.*.*
*.zip
*.jar
*.pom
*.xml
commitmsg
results/
rpms/
for-review.txt
3 changes: 3 additions & 0 deletions buildreq_cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
8.1.1
setuptools
setuptools_scm-python
224 changes: 209 additions & 15 deletions hgtools.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,214 @@
#
Name : hgtools
Version : 8.1.1
Release : 39
Release : 40
URL : http://pypi.debian.net/hgtools/hgtools-8.1.1.tar.gz
Source0 : http://pypi.debian.net/hgtools/hgtools-8.1.1.tar.gz
Summary : Classes and setuptools plugin for Mercurial and Git repositories
Group : Development/Tools
License : MIT
Requires: hgtools-python3
Requires: hgtools-python
Requires: Pygments
BuildRequires : pbr
BuildRequires : pip
Requires: hgtools-license = %{version}-%{release}
Requires: hgtools-python = %{version}-%{release}
Requires: hgtools-python3 = %{version}-%{release}
BuildRequires : buildreq-distutils3
BuildRequires : pluggy
BuildRequires : py-python
BuildRequires : pytest

BuildRequires : python3-dev
BuildRequires : setuptools
BuildRequires : setuptools_scm
BuildRequires : setuptools_scm-python
BuildRequires : tox
BuildRequires : virtualenv

%description
.. image:: https://img.shields.io/pypi/v/hgtools.svg
:target: https://pypi.org/project/hgtools
:target: https://pypi.org/project/hgtools

.. image:: https://img.shields.io/pypi/pyversions/hgtools.svg

.. image:: https://img.shields.io/pypi/dm/hgtools.svg

.. .. image:: https://img.shields.io/appveyor/ci/jaraco/skeleton/master.svg
.. :target: https://ci.appveyor.com/project/jaraco/skeleton/branch/master

.. image:: https://img.shields.io/travis/jaraco/hgtools/master.svg
:target: https://travis-ci.org/jaraco/hgtools

.. warning:: hgtools is defunct. It has been largely superseded by the
`setuptools_scm <https://pypi.python.org/pypi/setuptools_scm>`_
project.

Usage
=====

hgtools builds on the setuptools_hg plugin for setuptools. hgtools
provides classes for inspecting and working with repositories in the
Mercurial and Git version control systems (VCS).

hgtools provides a plugin for setuptools that enables setuptools to find
files managed by the VCS (currently only Mercurial support is implemented).

The classes provided by hgtools are designed to use subprocess invocation to
leverage the command-line interfaces of the VCS tools ``hg`` and ``git``. An
in-process RepoManager for Mercurial exists but has been disabled due to
issues that arise when run in certain environments (namely setuptools
sandboxing).

.. note:: The setuptools feature

You can read about the setuptools plugin provided by hgtools in the
`setuptools documentation`_. It basically returns a list of files that are
under VCS when running the ``setup`` function, e.g. if
you create a source and binary distribution. It's a simple yet effective way
of not having to define package data (non-Python files) manually in MANIFEST
templates (``MANIFEST.in``).

.. _setuptools documentation: http://pythonhosted.org/setuptools/setuptools.html#adding-support-for-other-revision-control-systems

Usage
*****

Here's a simple example of a setup.py that uses hgtools:

.. code-block:: python

from setuptools import setup, find_packages
setup(
name="HelloWorld",
version="0.1",
packages=find_packages(),
setup_requires=["hgtools"],
)

If you run the setup.py above, setuptools will automatically download
hgtools to the directory where the setup.py is located at (and won't
install it anywhere else) to get all package data files from the
sourec code repository.

You should not need to, and I recommend you don't, install hgtools in
your site-packages directory. Let setuptools grab it on demand. Also,
try not to specify an upper bound for the requirement. Usually, simply
specifying 'hgtools' will get the latest version, which is likely to
remain compatible (as a plugin) for the life of the project. Specifying
an upper bound (i.e. `hgtools<1.1`) will only prevent you from getting
bug fixes. Only specify an upper bound if you require support for older
versions of Python.

Auto Version Numbering
**********************

With the 0.4 release, hgtools adds support for automatically generating
project version numbers from the repository in which the
project is developed.

To use this feature, your project must follow the following assumptions:

- Repo tags are used to indicate released versions.
- Tag names are specified as the version only (i.e. 0.1 and not
v0.1 or release-0.1)
- Released versions currently must conform to the StrictVersion in
distutils. Any tags that don't match this scheme will be ignored.
Future releases may relax this restriction.

Thereafter, you may use the RepoManager.get_current_version to
determine the version of your product. If the current revision is tagged
with a valid version, that version will be used. Otherwise, the tags in
the repo will be searched, the latest release will be found, and hgtools
will infer the upcoming release version.

For example, if the repo contains the tags 0.1, 0.2, and 0.3 and the
repo is not on any of those tags, get_current_version will return
'0.3.1dev' and get_current_version(increment='0.1') will return
'0.4dev'.

A distutils hook has been created to hack setuptools to use this version
information automatically. To use this functionality, just use the
``use_vcs_version`` parameter to setup.
For example:

.. code-block:: python

from setuptools import setup, find_packages
setup(
name="HelloWorld",
use_vcs_version=True,
packages=find_packages(),
setup_requires=["hgtools"],
)

If the value supplied to use_vcs_version resolves to True, hgtools will
use the tagged version to determine the version of the
package (based on get_current_version). If an sdist is created, hgtools
will store the calculated version in the tag_build of the setup.cfg and
will use that version when deploying remotely. Therefore, if you are
using auto-versioning, you should not use setuptools tags explicitly.

See the jaraco.util setup.py for an example of this technique.

Versioning Parameters
~~~~~~~~~~~~~~~~~~~~~

It's also possible to pass keyword parameters to use_vcs_version to
tweak how it generates version numbers. To pass parameters, instead of
setting `use_vcs_version = True`, set it to a non-empty dictionary with
one or more of the following parameters:

- `increment`:
A string indicating the default version increment for the project.
By default, this value is '0.1', meaning hgtools will use the version
'1.1dev' for builds following the 1.0 release and '1.10dev' for builds
following a 1.9.3 release. Set this value to '1.0' or '0.0.1' for the
current tree to help hgtools guess the target version.

- `version_handler`:
A Python function with the following signature:

.. code-block:: python

def calc_version(mgr, options):
return str('1.0')

hgtools will use this function instead of its default implementation
to customize the version number calculation. The `mgr` object is the
`hgtools.managers.base.RepoManager` object referencing the local repo
and the `options` is the dictionary passed to use_vcs_version.

Use this option, for example, to include the commit hash or local
revision ID in the version:

.. code-block:: python

def id_as_version(mgr, options):
"Always return the Mercurial revision ID as the version"
id_n = mgr._invoke(['id', '-n']).strip()
return id_n

setup(
#...
use_vcs_version={'version_handler': id_as_version},
)

The first thing to note is the mgr does not yet provide a nice
interface for getting anything but the tags for a revision, so the
example digs into the underlying API to extract the ID. hgtools should
provide better support in the HGRepoManager classes in future releases.

Use this feature with caution. If you have not already read the
`setuptools documentation on specifying a project version
<http://packages.python.org/distribute/setuptools.html#specifying-your-project-s-version>`_,
the author recommends you do read that.

%package license
Summary: license components for the hgtools package.
Group: Default

%description license
license components for the hgtools package.


%package python
Summary: python components for the hgtools package.
Group: Default
Requires: hgtools-python3
Requires: hgtools-python3 = %{version}-%{release}

%description python
python components for the hgtools package.
Expand All @@ -43,32 +221,48 @@ python components for the hgtools package.
Summary: python3 components for the hgtools package.
Group: Default
Requires: python3-core
Provides: pypi(hgtools)

%description python3
python3 components for the hgtools package.


%prep
%setup -q -n hgtools-8.1.1
cd %{_builddir}/hgtools-8.1.1

%build
export http_proxy=http://127.0.0.1:9/
export https_proxy=http://127.0.0.1:9/
export no_proxy=localhost,127.0.0.1,0.0.0.0
export LANG=C
export SOURCE_DATE_EPOCH=1528566183
python3 setup.py build -b py3
export LANG=C.UTF-8
export SOURCE_DATE_EPOCH=1582934835
# -Werror is for werrorists
export GCC_IGNORE_WERROR=1
export CFLAGS="$CFLAGS -fno-lto "
export FCFLAGS="$CFLAGS -fno-lto "
export FFLAGS="$CFLAGS -fno-lto "
export CXXFLAGS="$CXXFLAGS -fno-lto "
export MAKEFLAGS=%{?_smp_mflags}
python3 setup.py build

%install
export MAKEFLAGS=%{?_smp_mflags}
rm -rf %{buildroot}
python3 -tt setup.py build -b py3 install --root=%{buildroot}
mkdir -p %{buildroot}/usr/share/package-licenses/hgtools
cp %{_builddir}/hgtools-8.1.1/LICENSE %{buildroot}/usr/share/package-licenses/hgtools/a1474494d96f6ddb3a9a0d767a09871ffc388faf
python3 -tt setup.py build install --root=%{buildroot}
echo ----[ mark ]----
cat %{buildroot}/usr/lib/python3*/site-packages/*/requires.txt || :
echo ----[ mark ]----

%files
%defattr(-,root,root,-)

%files license
%defattr(0644,root,root,0755)
/usr/share/package-licenses/hgtools/a1474494d96f6ddb3a9a0d767a09871ffc388faf

%files python
%defattr(-,root,root,-)

Expand Down
7 changes: 6 additions & 1 deletion options.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = hgtools
url = http://pypi.debian.net/hgtools/hgtools-8.1.1.tar.gz
archives =
giturl = https://github.com/jaraco/hgtools.git
domain =

[autospec]
# build 32 bit libraries
Expand All @@ -17,10 +18,12 @@ autoupdate = false
broken_c++ = false
# disable parallelization during build
broken_parallel_build = false
# this package is a library compatability package and only ships versioned library files
# this package is a library compatibility package and only ships versioned library files
compat = false
# set conservative build flags
conservative_flags = false
# dev package requires the extras to be installed
dev_requires_extras = false
# pass -ffast-math to compiler
fast-math = false
# optimize build for speed over size
Expand All @@ -31,6 +34,8 @@ insecure_build = false
keepstatic = false
# do not require autostart subpackage
no_autostart = false
# do not generate debuginfo for this package
nodebug = false
# disable stripping binaries
nostrip = false
# optimize build for size over speed
Expand Down
2 changes: 1 addition & 1 deletion release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39
40
1 change: 1 addition & 0 deletions versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.1.1

0 comments on commit 4ca9e6c

Please sign in to comment.