Skip to content
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

--force-buildsystem default value #42

Closed
wants to merge 4 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
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ To pass these commands to sdist_dsc when calling bdist_deb, do this::
Python version, working around Debian
bug 548392 of debhelper.
(Default=False).
--force-buildsystem If True (the default), set 'DH_OPTIONS=
--force-buildsystem If True, set 'DH_OPTIONS=
--buildsystem=python_distutils'
--no-backwards-compatibility This option has no effect, is here for
backwards compatibility, and may be
Expand Down
113 changes: 113 additions & 0 deletions scripts/dpkg-stdeb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/python

"""Command-line convenience wrapper
"""

import shutil

from mercurial import hg, commands, node
from mercurial.ui import ui as _ui

import os, sys
import tempfile

import subprocess

def dpkg_stdeb(repouri, rev=None, name=None, branch=None, deb_ver=1, keep=False, stdebcfg=None, dist_dir=None, install=False):
tmpdir = os.path.abspath(tempfile.mkdtemp())
cwd = os.getcwd()
os.chdir(tmpdir)

rtype, repouri = repouri.split('+') if '+' in repouri else (repouri, os.path.abspath(cwd))

if 'git' == rtype:
subprocess.check_call('git clone %s %s' % (repouri, tmpdir), shell=True)

if branch:
subprocess.check_call('git checkout %s' % branch, shell=True)

if rev:
subprocess.check_call('git reset %s' % rev, shell=True)
rev = ('%s+git' % rev[:8]) if rev else 'master+git'
repouri = repouri[:-4]
elif 'svn' == rtype:
os.chdir('..')
os.rmdir(tmpdir)
subprocess.check_call('svn export %s %s' % (repouri, tmpdir), shell=True)
os.chdir(tmpdir)
rev = ('r%s+svn' % rev[:8]) if rev else 'HEAD+svn'
elif 'hg' == rtype:
ui = _ui()
commands.clone(ui, repouri + (('#' + rev) if rev else ''), tmpdir)
repo = hg.repository(ui, tmpdir)

rev = ('%s+hg' % rev[:8]) if rev else 'tip+hg'
elif 'pypi' == rtype:
subprocess.check_call('pip install --upgrade --no-install %s --download-cache %s' % (repouri, tmpdir), shell=True)

os.chdir(os.path.join('build', repouri.split('==')[0]))
else:
raise SystemExit('Unknown VCS: %s' % rtype)

try:
if stdebcfg:
print >>open('stdeb.cfg', 'w'), open(os.path.join(cwd, stdebcfg), 'r').read(),

if not os.path.exists('setup.py'):
pname = name or os.path.basename(repouri)
print >>open('setup.py', 'w'), """
import os
from setuptools import setup, find_packages

setup(
name='%(pname)s',
version='%(rev)s',
py_modules=[x.replace('.py', '') for x in os.listdir('.') if x.endswith('.py') and x != 'setup.py'],
packages=find_packages()
)
""" % locals()

from time import time
cmd = ('%s setup.py --command-packages=stdeb.command sdist_dsc --debian-version=0ubuntu1~stdeb.%s --guess-conflicts-provides-replaces=True bdist_deb' % (sys.executable, int(time())))
subprocess.check_call(cmd, shell=True)

os.chdir( 'deb_dist' )

if install:
cmd = 'sudo dpkg -i *.deb'
subprocess.check_call(cmd, shell=True)

if dist_dir:
dist_dir = os.path.join(cwd, dist_dir)

if not os.path.exists(dist_dir):
os.makedirs(dist_dir)

for p in [x for x in os.listdir(os.getcwd()) if not os.path.isdir(x)]:
shutil.copy(p, dist_dir)
finally:
os.chdir(cwd)

if not keep:
shutil.rmtree(tmpdir)

if __name__ == '__main__':
from argparse import ArgumentParser

p = ArgumentParser("""usage: %(name)s [options] <repository URI>

Packages a python module for Debian/Ubuntu using stdeb.
""")

p.add_argument('repo', help='The URI for the repo. This should always start with the VCS name (e.g. svn+http://myproj.com/svn/trunk or hg+http://bitbucket.org/me/someproj). Valid VCS are hg, git and svn.')
p.add_argument('-n', '--name', default=None, help='The name for the package; defaults to the last element of the URI')
p.add_argument('-r', '--rev', default=None, help='Package a specific revision')
p.add_argument('-i', '--install', action='store_true', help='Install the built package')
p.add_argument('-k', '--keep', action='store_true', help='Keep the intermediate build directory after the install completes')
p.add_argument('-d', '--dist-dir', default='dist', help='Copy built files here')
p.add_argument('--extra-cfg-file')

args = p.parse_args()

dpkg_stdeb(repouri=args.repo, rev=args.rev, name=args.name, keep=args.keep, stdebcfg=args.extra_cfg_file, dist_dir=args.dist_dir, install=args.install)

1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
packages=['stdeb','stdeb.command'],
scripts=['scripts/py2dsc',
'scripts/pypi-install',
'scripts/dpkg-stdeb'
],
)
2 changes: 1 addition & 1 deletion stdeb/command/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def str_to_bool(mystr):
self.workaround_548392=False

if self.force_buildsystem is None:
self.force_buildsystem = True
self.force_buildsystem = False

if self.pycentral_backwards_compatibility is None:
self.pycentral_backwards_compatibility=False
Expand Down
2 changes: 1 addition & 1 deletion stdeb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def check_call(*popenargs, **kwargs):
'If True, limit binary package to single Python version, '
'working around Debian bug 548392 of debhelper. (Default=False).'),
('force-buildsystem=',None,
"If True (the default), set 'DH_OPTIONS=--buildsystem=python_distutils'"),
"If True, set 'DH_OPTIONS=--buildsystem=python_distutils'"),
('no-backwards-compatibility',None,
'This option has no effect, is here for backwards compatibility, and may '
'be removed someday.'),
Expand Down