Skip to content

Commit

Permalink
Merge pull request #43 from toabctl/improv
Browse files Browse the repository at this point in the history
[WIP] travis: Use matrix to execute tox jobs
  • Loading branch information
toabctl committed Jun 28, 2016
2 parents 5cf0b0d + b1d1489 commit 54e5358
Show file tree
Hide file tree
Showing 11 changed files with 1,039 additions and 881 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ nosetests.xml
*.egg-info
.venv*
.tox
.eggs
25 changes: 14 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
sudo: false

language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
matrix:
include:
- python: 2.7
env: TOX_ENV=pep8
- python: 2.7
env: TOX_ENV=py27
- python: 3.3
env: TOX_ENV=py34
- python: 3.4
env: TOX_ENV=py34
- python: 3.5
env: TOX_ENV=py34
install:
- pip install -r test-requirements.txt
- pip install coveralls
- pip install tox
script:
- flake8 py2pack
- coverage run --source=py2pack setup.py test
after_success:
coveralls
- tox -e $TOX_ENV
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ configurations (py27, py33, pep8), you can also use `tox`_:
$ tox
To run a single test class via `tox`_, use i.e.:

.. code-block:: bash
$ tox -epy27 test.test_py2pack:Py2packTestCase
:copyright: (c) 2013 Sascha Peilicke.
:license: GPLv2, see LICENSE for more details.
Expand Down
31 changes: 6 additions & 25 deletions py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import jinja2

import py2pack.proxy
import py2pack.requires


TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') # absolute template path
Expand Down Expand Up @@ -95,28 +96,8 @@ def fetch(args):


def _parse_setup_py(file, data):
contents = file.read().decode('utf-8')
match = re.search("ext_modules", contents)
if match:
data["is_extension"] = True
match = re.search("[(,]\s*scripts\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["scripts"] = eval(match.group(1))
match = re.search("test_suite\s*=\s*(.*)", contents)
if match:
data["test_suite"] = eval(match.group(1))
match = re.search("install_requires\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["install_requires"] = eval(match.group(1))
match = re.search("extras_require\s*=\s*(\{.*?\})", contents, flags=re.DOTALL)
if match:
data["extras_require"] = eval(match.group(1))
match = re.search("data_files\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["data_files"] = eval(match.group(1))
match = re.search('entry_points\s*=\s*(\{.*?\}|""".*?"""|".*?")', contents, flags=re.DOTALL)
if match:
data["entry_points"] = eval(match.group(1))
d = py2pack.requires._requires_from_setup_py(file)
data.update(d)


def _run_setup_py(tarfile, setup_filename, data):
Expand Down Expand Up @@ -192,9 +173,9 @@ def _sanitize_requirements(req):
for (dir, files) in data["data_files"]]

if "entry_points" in data:
# entry_points may be a string with .ini-style sections, convert to a dict:
if isinstance(data["entry_points"], str):
data["entry_points"] = pkg_resources.EntryPoint.parse_map(data["entry_points"])
# entry_points may be a string with .ini-style sections or a dict.
# convert to a dict and parse it
data["entry_points"] = pkg_resources.EntryPoint.parse_map(data["entry_points"])
if "console_scripts" in data["entry_points"]:
data["console_scripts"] = data["entry_points"]["console_scripts"].keys()

Expand Down
51 changes: 51 additions & 0 deletions py2pack/requires.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016, Thomas Bechtold <tbechtold@suse.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA

from __future__ import absolute_import
from __future__ import print_function

import re
import six


def _requires_from_setup_py(file):
"""read requirements from the setup.py file"""
data = {}
contents = six.u(file.read())
match = re.search("ext_modules", contents)
if match:
data["is_extension"] = True
match = re.search("[(,]\s*scripts\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["scripts"] = eval(match.group(1))
match = re.search("test_suite\s*=\s*(.*)", contents)
if match:
data["test_suite"] = eval(match.group(1))
match = re.search("install_requires\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["install_requires"] = eval(match.group(1))
match = re.search("extras_require\s*=\s*(\{.*?\})", contents, flags=re.DOTALL)
if match:
data["extras_require"] = eval(match.group(1))
match = re.search("data_files\s*=\s*(\[.*?\])", contents, flags=re.DOTALL)
if match:
data["data_files"] = eval(match.group(1))
match = re.search('entry_points\s*=\s*(\{.*?\}|""".*?"""|".*?")', contents, flags=re.DOTALL)
if match:
data["entry_points"] = eval(match.group(1))
return data
14 changes: 6 additions & 8 deletions py2pack/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2013 Sascha Peilicke
# Copyright 2016 Thomas Bechtold
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,6 @@
import re
import shutil
import subprocess
import sys
from distutils.core import Command


Expand Down Expand Up @@ -78,11 +78,13 @@ def run(self):
response = requests.get('https://docs.google.com/spreadsheet/pub?key=0AqPp4y2wyQsbdGQ1V3pRRDg5NEpGVWpubzdRZ0tjUWc')
html = lxml.html.fromstring(response.text)
licenses = {}
for i, tr in enumerate(html.cssselect('table#tblMain > tr[class!="rShim"]')):
if i == 0:
continue # Skip the first tr, only contains row descriptions
for i, tr in enumerate(html.cssselect('table.waffle > tbody > tr')):
_, td_new, td_old = tr.getchildren()
licenses[td_old.text] = td_new.text
# also add the spdx license as key (i.e. key/value "Apache-2.0"->"Apache-2.0")
# Otherwise licenses for packages which already have a SPDX compatible license
# are not correctly recognized
licenses[td_new.text] = td_new.text
pickle.dump(licenses, open(SPDXUpdateCommand.LICENSE_FILE, 'wb'))


Expand Down Expand Up @@ -115,10 +117,6 @@ def parse_requirements(requirements_file='requirements.txt'):
# -r lines are for including other files, and don't get used here
elif re.match(r'\s*-r\s+', line):
pass
# argparse is part of the standard library starting with 2.7
# adding it to the requirements list screws distro installs
elif line == 'argparse' and sys.version_info >= (2, 7):
pass
else:
requirements.append(line.strip())
return requirements

0 comments on commit 54e5358

Please sign in to comment.