Skip to content

Commit 9ed04d0

Browse files
authored
Merge pull request #30 from jayvdb/pkgdata
Replace `__file__` with pkgutil.get_data
2 parents cc3e191 + 267fd1c commit 9ed04d0

File tree

17 files changed

+8185
-14
lines changed

17 files changed

+8185
-14
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ python:
1010
- 3.7
1111
- 3.8
1212

13-
before_install:
14-
- pip install -r requirements-dev.txt
15-
1613
install:
1714
- python setup.py sdist && version=$(python setup.py --version) && pushd dist && pip install stdlib-list-${version}.tar.gz && popd
1815

1916
script:
20-
# FIXME: add some real test.
21-
- python -c "import stdlib_list; print(stdlib_list.stdlib_list('$TRAVIS_PYTHON_VERSION'))"
17+
- python -m tests
2218

2319
deploy:
2420
skip_cleanup: true

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include README.rst
33
include LICENSE
44
include versioneer.py
55
include stdlib_list/_version.py
6+
recursive-include tests *.py

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ def read(*parts):
2424
long_description="{}".format(read("README.md")),
2525
long_description_content_type="text/markdown",
2626
include_package_data=True,
27-
packages=find_packages(),
27+
packages=find_packages(exclude=["tests", "tests.*"]),
2828
cmdclass=versioneer.get_cmdclass(),
2929
)

stdlib_list/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
from ._version import get_versions
2+
23
__version__ = get_versions()['version']
34
del get_versions
45

56
# Import all the things that used to be in here for backwards-compatibility reasons
6-
from .base import stdlib_list, in_stdlib, get_canonical_version, short_versions, long_versions, base_dir, list_dir
7+
from .base import (
8+
stdlib_list,
9+
in_stdlib,
10+
get_canonical_version,
11+
short_versions,
12+
long_versions,
13+
)

stdlib_list/base.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
from __future__ import print_function, absolute_import
22

33
import os
4+
import pkgutil
45
import sys
56

67
try:
78
from functools import lru_cache
89
except ImportError:
910
from functools32 import lru_cache
1011

11-
base_dir = os.path.dirname(os.path.realpath(__file__))
12-
13-
list_dir = os.path.join(base_dir, "lists")
14-
1512
long_versions = ["2.6.9", "2.7.9", "3.2.6", "3.3.6", "3.4.3", "3.5", "3.6",
1613
"3.7", "3.8"]
1714

@@ -45,10 +42,11 @@ def stdlib_list(version=None):
4542
version = get_canonical_version(version) if version is not None else '.'.join(
4643
str(x) for x in sys.version_info[:2])
4744

48-
module_list_file = os.path.join(list_dir, "{}.txt".format(version))
45+
module_list_file = os.path.join("lists", "{}.txt".format(version))
46+
47+
data = pkgutil.get_data("stdlib_list", module_list_file).decode()
4948

50-
with open(module_list_file) as f:
51-
result = [y for y in [x.strip() for x in f.readlines()] if y]
49+
result = [y for y in [x.strip() for x in data.splitlines()] if y]
5250

5351
return result
5452

0 commit comments

Comments
 (0)