ldaptools/setup.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2.5 KiB
Python
Raw Permalink Normal View History

2016-02-02 16:59:12 +01:00
#! /usr/bin/env python
import os
2024-02-03 14:53:38 +01:00
import subprocess
2016-02-02 16:59:12 +01:00
2024-02-03 14:53:38 +01:00
from setuptools import setup
2016-02-02 16:59:12 +01:00
from setuptools.command.sdist import sdist
class eo_sdist(sdist):
def run(self):
2024-02-03 14:53:38 +01:00
print('creating VERSION file')
2016-02-02 16:59:12 +01:00
if os.path.exists('VERSION'):
os.remove('VERSION')
version = get_version()
version_file = open('VERSION', 'w')
version_file.write(version)
version_file.close()
sdist.run(self)
2024-02-03 14:53:38 +01:00
print('removing VERSION file')
2016-02-02 16:59:12 +01:00
if os.path.exists('VERSION'):
os.remove('VERSION')
def get_version():
2024-02-03 14:53:38 +01:00
"""Use the VERSION, if absent generates a version with git describe, if not
tag exists, take 0.0- and add the length of the commit log.
"""
2016-02-02 16:59:12 +01:00
if os.path.exists('VERSION'):
2024-02-03 14:53:38 +01:00
with open('VERSION') as v:
2016-02-02 16:59:12 +01:00
return v.read()
if os.path.exists('.git'):
2019-10-01 11:54:56 +02:00
p = subprocess.Popen(
['git', 'describe', '--dirty=.dirty', '--match=v*'],
2024-02-03 14:53:38 +01:00
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
2019-10-01 11:54:56 +02:00
)
2016-02-02 16:59:12 +01:00
result = p.communicate()[0]
if p.returncode == 0:
2019-10-01 11:54:56 +02:00
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
if '-' in result: # not a tagged version
real_number, commit_count, commit_hash = result.split('-', 2)
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
else:
2024-02-07 12:55:05 +01:00
version = result.replace('.dirty', '+dirty')
2019-10-01 11:54:56 +02:00
return version
2016-02-02 16:59:12 +01:00
else:
2024-02-03 14:53:38 +01:00
return '0.0.post%s' % len(
subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines()
)
2019-10-01 11:54:56 +02:00
return '0.0'
2016-02-02 16:59:12 +01:00
2024-02-03 14:53:38 +01:00
setup(
name='ldaptools',
version=get_version(),
license='AGPLv3+',
description='ldaptools',
long_description=open('README.rst').read(),
url='http://dev.entrouvert.org/projects/ldaptools/',
author="Entr'ouvert",
author_email='authentic@listes.entrouvert.com',
maintainer='Benjamin Dauvergne',
maintainer_email='bdauvergne@entrouvert.com',
packages=['ldaptools'],
package_dir={'': 'src'},
package_data={'ldaptools': ['schemas/*.ldif']},
2024-02-03 15:07:29 +01:00
install_requires=['python-ldap>2', 'six'],
2024-02-03 14:53:38 +01:00
entry_points={
'console_scripts': ['ldapsync=ldaptools.ldapsync.cmd:main'],
},
zip_safe=False,
classifiers=[
'License :: OSI Approved :: MIT License',
'Topic :: System :: Systems Administration :: Authentication/Directory',
'Programming Language :: Python',
],
cmdclass={'sdist': eo_sdist},
)