Skip to content

Commit 7c69b7d

Browse files
committed
Improved loading performance (lazy objects)
1 parent 393ec14 commit 7c69b7d

30 files changed

Lines changed: 5111 additions & 5043 deletions

.coveragerc

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
[run]
2-
cover_pylib = false
3-
source = tinyscript
4-
omit =
5-
/home/travis/virtualenv/*
6-
*/site-packages/*
7-
tinyscript/__main__.py
8-
tinyscript/hotkeys.py
9-
tinyscript/warnings.py
10-
tinyscript/helpers/termsize.py
11-
tests/*
12-
13-
[report]
14-
exclude_lines =
15-
pragma: no cover
16-
# Python2/3 incompatibilities if/elif/else blocks
17-
(?m)(?P<indent>(?:\s+))if.*?PY(?:THON)?3.*?\:((?P=indent)\s+.*?)+(((?P=indent)else|elif).*?\:((?P=indent)\s+.*?)+)*$
18-
(if|and) (?:not )?PY(?:THON)?3:?
19-
if sys\.version_info \< \(3\,\)\:
20-
if pdf_generation:
21-
pdf_generation
22-
# __main__ logics
23-
if\s+__name__\s+==\s+(?P<q>(?:[\'\"]))__main__(?P=q)\s+:
24-
import ConfigParser
25-
except ImportError:
26-
except NameError:
27-
# sudo when using 'initialize'
28-
if sudo and not is_admin():
29-
# 'interact' module - remote interaction
30-
class ConsoleSocket
31-
class RemoteInteractiveConsole
32-
# exit tasks
33-
def __at_exit\(\)\:
34-
if DARWIN:
35-
if WINDOWS:
36-
raise NotImplementedError
37-
except NotImplementedError:
38-
# virtualenv package install
39-
elif line.startswith\(\"Successfully installed\"\):
40-
for top_level in __install
41-
def __deprecated
42-
def hotkeys(hotkeys, silent=True):
43-
super\(NewClass\, self\)\.__init__
44-
# optional packages not installed or different platform or cumbersome to test
45-
if not hotkeys_enabled:
46-
try: # Windows
47-
def stdin_pipe\(\):
48-
Xlib.error.DisplayConnectionError
49-
def send_mail
50-
except KeyboardInterrupt:
1+
[run]
2+
cover_pylib = false
3+
source = tinyscript
4+
omit =
5+
/home/travis/virtualenv/*
6+
*/site-packages/*
7+
src/tinyscript/__main__.py
8+
src/tinyscript/hotkeys.py
9+
src/tinyscript/warnings.py
10+
src/tinyscript/helpers/termsize.py
11+
tests/*
12+
13+
[report]
14+
exclude_lines =
15+
pragma: no cover
16+
# Python2/3 incompatibilities if/elif/else blocks
17+
(?m)(?P<indent>(?:\s+))if.*?PY(?:THON)?3.*?\:((?P=indent)\s+.*?)+(((?P=indent)else|elif).*?\:((?P=indent)\s+.*?)+)*$
18+
(if|and) (?:not )?PY(?:THON)?3:?
19+
if sys\.version_info \< \(3\,\)\:
20+
if pdf_generation:
21+
pdf_generation
22+
# __main__ logics
23+
if\s+__name__\s+==\s+(?P<q>(?:[\'\"]))__main__(?P=q)\s+:
24+
import ConfigParser
25+
except ImportError:
26+
except NameError:
27+
# sudo when using 'initialize'
28+
if sudo and not is_admin():
29+
# 'interact' module - remote interaction
30+
class ConsoleSocket
31+
class RemoteInteractiveConsole
32+
# exit tasks
33+
def __at_exit\(\)\:
34+
if DARWIN:
35+
if WINDOWS:
36+
raise NotImplementedError
37+
except NotImplementedError:
38+
# virtualenv package install
39+
elif line.startswith\(\"Successfully installed\"\):
40+
for top_level in __install
41+
def __deprecated
42+
def hotkeys(hotkeys, silent=True):
43+
super\(NewClass\, self\)\.__init__
44+
# optional packages not installed or different platform or cumbersome to test
45+
if not hotkeys_enabled:
46+
try: # Windows
47+
def stdin_pipe\(\):
48+
Xlib.error.DisplayConnectionError
49+
def send_mail
50+
except KeyboardInterrupt:

.github/workflows/python-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ jobs:
4747
- name: Set up Python ${{ matrix.python-version }}
4848
uses: actions/setup-python@v4
4949
with:
50-
python-version: 3.11
50+
python-version: "3.10"
5151
- name: Install pandoc
5252
run: sudo apt-get install -y pandoc notification-daemon
5353
- name: Install ${{ env.package }}
5454
run: |
5555
python -m pip install --upgrade pip
56-
python -m pip install pytest pytest-cov
56+
python -m pip install pytest pytest-cov pytest-pythonpath
5757
pip install -r requirements.txt
5858
pip install .
5959
- name: Make coverage badge for ${{ env.package }}

pyproject.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ authors = [
2222
description = "Devkit for quickly building CLI tools with Python"
2323
license = {file = "LICENSE"}
2424
keywords = ["python", "development", "programming", "cli", "devkit"]
25-
requires-python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4"
25+
requires-python = ">=3.7,<4"
2626
classifiers = [
2727
"Development Status :: 5 - Production/Stable",
2828
"Environment :: Console",
2929
"Intended Audience :: Developers",
3030
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
31-
"Programming Language :: Python :: 2",
32-
"Programming Language :: Python :: 2.7",
3331
"Programming Language :: Python :: 3",
34-
"Programming Language :: Python :: 3.6",
35-
"Programming Language :: Python :: 3.7",
3632
"Programming Language :: Python :: 3.8",
3733
"Programming Language :: Python :: 3.9",
3834
"Programming Language :: Python :: 3.10",
@@ -49,6 +45,7 @@ dependencies = [
4945
"dicttoxml",
5046
"ipaddress>=1.0.23",
5147
"json2html",
48+
"lazy_object_proxy>=1.9.0",
5249
"markdown<3.4",
5350
"markdown2>=2.3.10; python_version=='2.7'",
5451
"markdown2>=2.4.0; python_version>='3.6'",

requirements.txt

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
1-
asciistuff>=1.2.3
2-
bitstring
3-
codext>=1.8.2
4-
coloredlogs
5-
colorful
6-
dicttoxml
7-
ipaddress>=1.0.23
8-
json2html
9-
markdown2>=2.4.0
10-
mdv; python_version<'3.9'
11-
mdv3; python_version>='3.9'
12-
netaddr
13-
netifaces
14-
patchy
15-
pathlib2
16-
pillow>=8.2.0
17-
pip>=20.0
18-
plyer>=2.0.0; python_version>='3.5'
19-
pygments>=2.8.1
20-
pyminizip
21-
pynput
22-
pypandoc
23-
pypiwin32; sys_platform=='windows'
24-
python-magic
25-
python-slugify
26-
pyyaml>=5.3.1
27-
six
28-
terminaltables
29-
toml
30-
tqdm
31-
virtualenv>=20.8.1; python_version>='3.5'
32-
weasyprint; python_version>='3.5'
33-
xmltodict
1+
asciistuff>=1.2.3
2+
bitstring
3+
codext>=1.8.2
4+
coloredlogs
5+
colorful
6+
dicttoxml
7+
ipaddress>=1.0.23
8+
json2html
9+
lazy_object_proxy>=1.9.0
10+
markdown2>=2.4.0
11+
mdv; python_version<'3.9'
12+
mdv3; python_version>='3.9'
13+
netaddr
14+
netifaces
15+
patchy
16+
pathlib2
17+
pillow>=8.2.0
18+
pip>=20.0
19+
plyer>=2.0.0; python_version>='3.5'
20+
pygments>=2.8.1
21+
pyminizip
22+
pynput
23+
pypandoc
24+
pypiwin32; sys_platform=='windows'
25+
python-magic
26+
python-slugify
27+
pyyaml>=5.3.1
28+
six
29+
terminaltables
30+
toml
31+
tqdm
32+
virtualenv>=20.8.1; python_version>='3.5'
33+
weasyprint; python_version>='3.5'
34+
xmltodict

src/tinyscript/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.26.22
1+
1.27.0

src/tinyscript/__init__.py

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
#!/usr/bin/env python
2-
# -*- coding: UTF-8 -*-
3-
"""Initialization of Tinyscript package.
4-
5-
"""
6-
# this avoids an AssertionError due to pip being loaded before setuptools ;
7-
# see https://github.com/pypa/setuptools/issues/3044
8-
import setuptools
9-
10-
from warnings import filterwarnings
11-
filterwarnings("ignore", "Setuptools is replacing distutils.")
12-
13-
14-
from .__info__ import __author__, __copyright__, __license__, __version__
15-
16-
from .deprecation import *
17-
from .features import *
18-
from .helpers import *
19-
from .parser import *
20-
from .preimports import *
21-
22-
from .deprecation import __features__ as _deprecation
23-
from .features import __features__ as _features
24-
from .helpers import __features__ as _helpers
25-
from .parser import __features__ as _parser
26-
from .preimports import __features__ as _preimports
27-
28-
29-
ts.__author__ = __author__
30-
ts.__copyright__ = __copyright__
31-
ts.__license__ = __license__
32-
ts.__version__ = __version__
33-
34-
35-
__all__ = _deprecation + _features + _helpers + _parser + _preimports
36-
1+
#!/usr/bin/env python
2+
# -*- coding: UTF-8 -*-
3+
"""Initialization of Tinyscript package.
4+
5+
"""
6+
# NB: disabled as too expensive to load while almost not used ; if the error mentioned hereafter appears again, this
7+
# will be addressed in a different way
8+
# this avoids an AssertionError due to pip being loaded before setuptools ;
9+
# see https://github.com/pypa/setuptools/issues/3044
10+
#import setuptools
11+
12+
from warnings import filterwarnings
13+
filterwarnings("ignore", "Setuptools is replacing distutils.")
14+
15+
16+
from .__info__ import __author__, __copyright__, __license__, __version__
17+
18+
from .deprecation import *
19+
from .features import *
20+
from .helpers import *
21+
from .parser import *
22+
from .preimports import *
23+
24+
from .deprecation import __features__ as _deprecation
25+
from .features import __features__ as _features
26+
from .helpers import __features__ as _helpers
27+
from .parser import __features__ as _parser
28+
from .preimports import __features__ as _preimports
29+
30+
31+
ts.__author__ = __author__
32+
ts.__copyright__ = __copyright__
33+
ts.__license__ = __license__
34+
ts.__version__ = __version__
35+
36+
37+
__all__ = _deprecation + _features + _helpers + _parser + _preimports
38+

0 commit comments

Comments
 (0)