Skip to content

Commit f6cddd6

Browse files
Merge pull request #1 from pytest-dev/rel-eng
prepare automated release process and ci
2 parents 0e4f1cc + 117ff2a commit f6cddd6

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src/apipkg/version.py
2+
__pycache__
3+
*.egg-info
4+
.cache/
5+
.eggs/

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: python
2+
python:
3+
- "2.6"
4+
- "2.7"
5+
- "3.3"
6+
- "3.4"
7+
- "3.5"
8+
- "3.5-dev" # 3.5 development branch
9+
- "3.6"
10+
- "3.6-dev" # 3.6 development branch
11+
- "3.7-dev" # 3.7 development branch
12+
- "nightly" # currently points to 3.7-dev
13+
# command to install dependencies
14+
env:
15+
- EDITABLE=-e
16+
- EDITABLE=
17+
install:
18+
- pip install -U setuptools pip setuptools_scm pytest
19+
- pip install $EDITABLE .
20+
# command to run tests
21+
script: pytest

conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import py
2+
import apipkg
3+
LOCAL_APIPKG = py.path.local(__file__).dirpath().join('src/apipkg/__init__.py')
4+
INSTALL_TYPE = 'editable' if apipkg.__file__ == LOCAL_APIPKG else 'full'
5+
6+
7+
def pytest_report_header(startdir):
8+
return "apipkg {install_type} install version={version}".format(
9+
install_type=INSTALL_TYPE, version=apipkg.__version__)

setup.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
import re
2-
from setuptools import setup
2+
from setuptools import setup, find_packages
33

44

5-
def get_version():
6-
VERSION_RE = re.compile("__version__ = \'(.*)\'", re.M)
7-
with open('apipkg.py') as fp:
8-
return VERSION_RE.search(fp.read()).group(1)
5+
def readme():
6+
with open('README.txt') as fp:
7+
return fp.read()
98

109

1110
def main():
1211
setup(
1312
name='apipkg',
1413
description='apipkg: namespace control and lazy-import mechanism',
15-
long_description=open('README.txt').read(),
16-
version=get_version(),
17-
url='http://bitbucket.org/hpk42/apipkg',
14+
long_description=readme(),
15+
setup_requires=[
16+
'setuptools_scm',
17+
'setuptools>=30.3.0', # introduced setup.cfg metadata
18+
],
19+
use_scm_version={
20+
'write_to': 'src/apipkg/version.py'
21+
},
22+
url='http://github.com/pytest-dev/apipkg',
1823
license='MIT License',
1924
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
2025
author='holger krekel',
2126
author_email='holger at merlinux.eu',
27+
maintainer="Ronny Pfannschmidt",
28+
maintainer_email="[email protected]",
2229
classifiers=[
2330
'Development Status :: 4 - Beta',
2431
'Intended Audience :: Developers',
@@ -28,7 +35,8 @@ def main():
2835
'Operating System :: MacOS :: MacOS X',
2936
'Topic :: Software Development :: Libraries',
3037
'Programming Language :: Python'],
31-
py_modules=['apipkg'],
38+
packages=find_packages('src'),
39+
package_dir={'': 'src'},
3240
)
3341

3442
if __name__ == '__main__':

apipkg.py renamed to src/apipkg/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import sys
1010
from types import ModuleType
1111

12-
13-
__version__ = '1.5.dev1'
14-
12+
from .version import version as __version__
1513

1614
def _py_abspath(path):
1715
"""
@@ -37,8 +35,9 @@ def distribution_version(name):
3735
return dist.version
3836

3937

40-
def initpkg(pkgname, exportdefs, attr=dict(), eager=False):
38+
def initpkg(pkgname, exportdefs, attr=None, eager=False):
4139
""" initialize given package from the export definitions. """
40+
attr = attr or {}
4241
oldmod = sys.modules.get(pkgname)
4342
d = {}
4443
f = getattr(oldmod, '__file__', None)
@@ -66,6 +65,7 @@ def initpkg(pkgname, exportdefs, attr=dict(), eager=False):
6665

6766

6867
def importobj(modpath, attrname):
68+
"""imports a module, then resolves the attrname on it"""
6969
module = __import__(modpath, None, None, ['__doc__'])
7070
if not attrname:
7171
return module
@@ -78,6 +78,7 @@ def importobj(modpath, attrname):
7878

7979

8080
class ApiModule(ModuleType):
81+
"""the magical lazy-loading module standing"""
8182
def __docget(self):
8283
try:
8384
return self.__doc

test_apipkg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ def patchgetattr(self, name):
383383
assert 'abspath' in d
384384

385385

386-
def test_chdir_with_relative_imports_shouldnt_break_lazy_loading(tmpdir):
387-
tmpdir.join('apipkg.py').write(py.code.Source(apipkg))
386+
def test_chdir_with_relative_imports_support_lazy_loading(tmpdir, monkeypatch):
387+
monkeypatch.syspath_prepend(py.path.local('src'))
388388
pkg = tmpdir.mkdir('pkg')
389389
tmpdir.mkdir('messy')
390390
pkg.join('__init__.py').write(py.code.Source("""

0 commit comments

Comments
 (0)