Skip to content

Commit 066c9c5

Browse files
committed
move package to src dir
1 parent 773f78e commit 066c9c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+69
-68
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,39 @@ on:
1111
- cron: "0 0 * * *"
1212

1313
jobs:
14-
test-linux:
14+
coverage:
1515
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
python-version: [3.7, 3.8, 3.9]
1916
steps:
2017
- uses: actions/checkout@v2
2118
- uses: nanasess/setup-chromedriver@master
2219
- uses: actions/setup-node@v2-beta
2320
with:
2421
node-version: "12"
25-
- name: Use Python ${{ matrix.python-version }}
22+
- name: Use Latest Python
2623
uses: actions/setup-python@v2
2724
with:
28-
python-version: ${{ matrix.python-version }}
25+
python-version: 3.9
2926
- name: Install Python Dependencies
3027
run: pip install -r requirements/test-run.txt
3128
- name: Run Tests
3229
run: |
3330
nox -s test -- pytest[--headless]
34-
test-other-systems:
31+
matrix:
3532
runs-on: ${{ matrix.os }}
3633
strategy:
37-
fail-fast: false
3834
matrix:
39-
os: [ macos-latest, windows-latest ]
35+
python-version: [3.7, 3.8, 3.9]
36+
os: [ubuntu-latest, macos-latest, windows-latest]
4037
steps:
4138
- uses: actions/checkout@v2
4239
- uses: nanasess/setup-chromedriver@master
4340
- uses: actions/setup-node@v2-beta
4441
with:
4542
node-version: "12"
46-
- name: Use Python 3.9
43+
- name: Use Python ${{ matrix.python-version }}
4744
uses: actions/setup-python@v2
4845
with:
49-
python-version: 3.9
46+
python-version: ${{ matrix.python-version }}
5047
- name: Install Python Dependencies
5148
run: pip install -r requirements/test-run.txt
5249
- name: Run Tests

MANIFEST.in

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
recursive-include idom/client/app *
2-
recursive-exclude idom/client/app/node_modules *
3-
recursive-exclude idom/client/app/web_modules *
4-
recursive-exclude idom/client/build *
5-
include idom/py.typed
6-
include LICENSE
1+
recursive-include src/idom *
2+
recursive-exclude src/idom/client/app/node_modules *
3+
recursive-exclude src/idom/client/app/web_modules *
4+
recursive-exclude src/idom/client/build *
75
include requirements/prod.txt
86
include requirements/extras.txt
9-
include README.md
10-
include scripts/build.sh

noxfile.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ def test_python(session: Session) -> None:
8787
"""Run the Python-based test suite"""
8888
session.env["IDOM_DEBUG_MODE"] = "1"
8989
session.install("-r", "requirements/test-env.txt")
90-
session.install(".[all]")
91-
args = ["pytest", "tests"] + get_posargs("pytest", session)
92-
session.run(*args)
90+
91+
pytest_args = get_posargs("pytest", session)
92+
if "--no-cov" in pytest_args:
93+
session.install(".[all]")
94+
else:
95+
session.install("-e", ".[all]")
96+
97+
session.run("pytest", "tests", *pytest_args)
9398

9499

95100
@nox.session
@@ -98,14 +103,14 @@ def test_types(session: Session) -> None:
98103
session.install("-r", "requirements/check-types.txt")
99104
session.install("-r", "requirements/pkg-deps.txt")
100105
session.install("-r", "requirements/pkg-extras.txt")
101-
session.run("mypy", "--strict", "idom")
106+
session.run("mypy", "--strict", "src/idom")
102107

103108

104109
@nox.session
105110
def test_style(session: Session) -> None:
106111
"""Check that style guidelines are being followed"""
107112
session.install("-r", "requirements/check-style.txt")
108-
session.run("flake8", "idom", "tests", "docs")
113+
session.run("flake8", "src/idom", "tests", "docs")
109114
black_default_exclude = r"\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist"
110115
session.run(
111116
"black",

scripts/__init__.py

Whitespace-only changes.

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ max-line-length = 88
1313
max-complexity = 18
1414
select = B,C,E,F,W,T4,B9,N,ROH
1515
exclude =
16-
idom/client/app/node_modules/*
16+
src/idom/client/app/node_modules/*
1717
.eggs/*
1818
.tox/*
1919

2020
[tool:pytest]
2121
testpaths = tests
2222
xfail_strict = True
23-
addopts = --cov=idom --cov-report term
23+
addopts = --cov=src/idom --cov-report term
2424
markers =
2525
slow: marks tests as slow (deselect with '-m "not slow"')
2626

@@ -30,11 +30,11 @@ show_missing = True
3030
skip_covered = True
3131
sort = Name
3232
exclude_lines =
33-
pragma: no cover
33+
coverage: skip
3434
\.\.\.
3535
raise NotImplementedError
3636
omit =
37-
idom/__main__.py
37+
src/idom/__main__.py
3838

3939
[build_sphinx]
4040
all-files = true

setup.py

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

3-
import os
43
import pipes
54
import shutil
65
import subprocess
@@ -9,6 +8,7 @@
98
from distutils import log
109
from distutils.command.build import build # type: ignore
1110
from distutils.command.sdist import sdist # type: ignore
11+
from pathlib import Path
1212

1313
from setuptools import find_packages, setup
1414
from setuptools.command.develop import develop
@@ -25,8 +25,9 @@ def list2cmdline(cmd_list):
2525
name = "idom"
2626

2727
# basic paths used to gather files
28-
here = os.path.abspath(os.path.dirname(__file__))
29-
root = os.path.join(here, name)
28+
root_dir = Path(__file__).parent
29+
src_dir = root_dir / "src"
30+
package_dir = src_dir / name
3031

3132

3233
# -----------------------------------------------------------------------------
@@ -37,7 +38,8 @@ def list2cmdline(cmd_list):
3738
package = {
3839
"name": name,
3940
"python_requires": ">=3.7",
40-
"packages": find_packages(exclude=["tests*"]),
41+
"packages": find_packages(str(src_dir)),
42+
"package_dir": {"": "src"},
4143
"description": "Control the web with Python",
4244
"author": "Ryan Morshead",
4345
"author_email": "[email protected]",
@@ -76,16 +78,16 @@ def list2cmdline(cmd_list):
7678

7779

7880
requirements = []
79-
with open(os.path.join(here, "requirements", "pkg-deps.txt"), "r") as f:
81+
with (root_dir / "requirements" / "pkg-deps.txt").open() as f:
8082
for line in map(str.strip, f):
8183
if not line.startswith("#"):
8284
requirements.append(line)
8385
package["install_requires"] = requirements
8486

8587
_current_extras = []
8688
extra_requirements = {"all": []} # type: ignore
87-
extra_requirements_path = os.path.join(here, "requirements", "pkg-extras.txt")
88-
with open(extra_requirements_path, "r") as f:
89+
extra_requirements_path = root_dir / "requirements" / "pkg-extras.txt"
90+
with extra_requirements_path.open() as f:
8991
for line in map(str.strip, f):
9092
if line.startswith("#") and line[1:].strip().startswith("extra="):
9193
_current_extras = [e.strip() for e in line.split("=", 1)[1].split(",")]
@@ -98,8 +100,9 @@ def list2cmdline(cmd_list):
98100
extra_requirements[e].append(line)
99101
extra_requirements["all"].append(line)
100102
elif line:
101-
msg = "No '# extra=<name>' header before requirements in %r"
102-
raise ValueError(msg % extra_requirements_path)
103+
raise ValueError(
104+
f"No '# extra=<name>' header before requirements in {extra_requirements_path}"
105+
)
103106
package["extras_require"] = extra_requirements
104107

105108

@@ -108,7 +111,7 @@ def list2cmdline(cmd_list):
108111
# -----------------------------------------------------------------------------
109112

110113

111-
with open(os.path.join(here, "README.md")) as f:
114+
with (root_dir / "README.md").open() as f:
112115
long_description = f.read()
113116

114117
package["long_description"] = long_description
@@ -125,7 +128,7 @@ class Command(cls):
125128
def run(self):
126129
log.info("Installing Javascript...")
127130
try:
128-
js_dir = os.path.join(root, "client", "app")
131+
js_dir = str(package_dir / "client" / "app")
129132
for cmd, *args in map(str.split, ["npm install", "npm run build"]):
130133
which_cmd = shutil.which(cmd)
131134
if which_cmd is None:

idom/__init__.py renamed to src/idom/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
try:
55
__version__: str = _get_distribution(__name__).version
6-
except _DistributionNotFound: # pragma: no cover
6+
except _DistributionNotFound: # coverage: skip
77
# package is not installed
88
__version__ = "0.0.0"
99

@@ -24,7 +24,7 @@
2424
import htm
2525
import pyalect
2626
import tagged
27-
except ImportError: # pragma: no cover
27+
except ImportError: # coverage: skip
2828
pass
2929
else:
3030
from . import dialect
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

idom/client/manage.py renamed to src/idom/client/manage.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _copy_to_build_dir(source: Path) -> None:
2727
shutil.copytree(source, BUILD_DIR, symlinks=True)
2828

2929

30-
if not BUILD_DIR.exists(): # pragma: no cover
30+
if not BUILD_DIR.exists(): # coverage: skip
3131
_copy_to_build_dir(BACKUP_BUILD_DIR)
3232

3333

@@ -129,7 +129,7 @@ def build(packages_to_install: Sequence[str], clean_build: bool = False) -> None
129129

130130
not_discovered = package_names_to_install.difference(web_module_names())
131131
if not_discovered:
132-
raise RuntimeError( # pragma: no cover
132+
raise RuntimeError( # coverage: skip
133133
f"Successfuly installed {list(package_names_to_install)} but "
134134
f"failed to discover {list(not_discovered)} post-install."
135135
)
@@ -147,7 +147,7 @@ def _run_subprocess(args: List[str], cwd: Path) -> None:
147147
cmd, *args = args
148148
which_cmd = shutil.which(cmd)
149149
if which_cmd is None:
150-
raise RuntimeError( # pragma: no cover
150+
raise RuntimeError( # coverage: skip
151151
f"Failed to run command - {cmd!r} is not installed."
152152
)
153153
try:
@@ -158,6 +158,6 @@ def _run_subprocess(args: List[str], cwd: Path) -> None:
158158
stdout=subprocess.PIPE,
159159
stderr=subprocess.PIPE,
160160
)
161-
except subprocess.CalledProcessError as error: # pragma: no cover
161+
except subprocess.CalledProcessError as error: # coverage: skip
162162
raise subprocess.SubprocessError(error.stderr.decode()) from error
163163
return None
File renamed without changes.
File renamed without changes.
File renamed without changes.

idom/core/component.py renamed to src/idom/core/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from functools import wraps
44
from typing import TYPE_CHECKING, Any, Callable, Dict, Tuple, Union
55

6-
if TYPE_CHECKING: # pragma: no cover
6+
if TYPE_CHECKING: # coverage: skip
77
from .vdom import VdomDict # noqa
88

99

File renamed without changes.

idom/core/events.py renamed to src/idom/core/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __iter__(self) -> Iterator[str]:
134134
def __getitem__(self, key: str) -> "EventHandler":
135135
return self._handlers[key]
136136

137-
def __repr__(self) -> str: # pragma: no cover
137+
def __repr__(self) -> str: # coverage: skip
138138
return repr(self._handlers)
139139

140140

@@ -229,5 +229,5 @@ def __contains__(self, function: Any) -> bool:
229229
else:
230230
return function in self._func_handlers
231231

232-
def __repr__(self) -> str: # pragma: no cover
232+
def __repr__(self) -> str: # coverage: skip
233233
return f"{type(self).__name__}({self.serialize()})"
File renamed without changes.

idom/core/layout.py renamed to src/idom/core/layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Layout(HasAsyncResources):
6767

6868
__slots__ = ["root", "_event_handlers"]
6969

70-
if not hasattr(abc.ABC, "__weakref__"): # pragma: no cover
70+
if not hasattr(abc.ABC, "__weakref__"): # coverage: skip
7171
__slots__.append("__weakref__")
7272

7373
def __init__(self, root: "AbstractComponent") -> None:

idom/core/utils.py renamed to src/idom/core/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
overload,
1515
)
1616

17-
if sys.version_info >= (3, 7): # pragma: no cover
17+
if sys.version_info >= (3, 7): # coverage: skip
1818
from contextlib import AsyncExitStack, asynccontextmanager # noqa
19-
else: # pragma: no cover
19+
else: # coverage: skip
2020
from async_exit_stack import AsyncExitStack
2121
from async_generator import asynccontextmanager
2222

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

idom/server/base.py renamed to src/idom/server/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def run(self, host: str, port: int, *args: Any, **kwargs: Any) -> None:
4444
if self._app is None:
4545
app = self._default_application(self._config)
4646
self.register(app)
47-
else: # pragma: no cover
47+
else: # coverage: skip
4848
app = self._app
49-
if not self._daemonized: # pragma: no cover
49+
if not self._daemonized: # coverage: skip
5050
return self._run_application(self._config, app, host, port, args, kwargs)
5151
else:
5252
return self._run_application_in_thread(
@@ -76,7 +76,7 @@ def register(self: _Self, app: Optional[_App]) -> _Self:
7676
def wait_until_server_start(self, timeout: float = 3.0) -> None:
7777
"""Block until the underlying application has started"""
7878
if not self._server_did_start.wait(timeout=timeout):
79-
raise RuntimeError( # pragma: no cover
79+
raise RuntimeError( # coverage: skip
8080
f"Server did not start within {timeout} seconds"
8181
)
8282

idom/server/flask.py renamed to src/idom/server/flask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FlaskRenderServer(AbstractRenderServer[Flask, Config]):
4343
def stop(self, timeout: Optional[float] = None) -> None:
4444
try:
4545
server = self._wsgi_server
46-
except AttributeError: # pragma: no cover
46+
except AttributeError: # coverage: skip
4747
raise RuntimeError(
4848
f"Application is not running or was not started by {self}"
4949
)
@@ -70,7 +70,7 @@ def _setup_application(self, config: Config, app: Flask) -> None:
7070
self._setup_blueprint_routes(config, bp)
7171

7272
cors_config = config["cors"]
73-
if cors_config: # pragma: no cover
73+
if cors_config: # coverage: skip
7474
cors_params = cors_config if isinstance(cors_config, dict) else {}
7575
CORS(bp, **cors_params)
7676

@@ -162,7 +162,7 @@ def _generic_run_application(
162162
**kwargs: Any,
163163
) -> None:
164164
if debug:
165-
logging.basicConfig(level=logging.DEBUG) # pragma: no cover
165+
logging.basicConfig(level=logging.DEBUG) # coverage: skip
166166
logging.debug("Starting server...")
167167
self._wsgi_server = _StartCallbackWSGIServer(
168168
self._server_did_start.set,
@@ -272,7 +272,7 @@ def update_environ(self) -> None:
272272
"""
273273
super().update_environ()
274274
# BUG: for some reason coverage doesn't seem to think this line is covered
275-
self._before_first_request_callback() # pragma: no cover
275+
self._before_first_request_callback() # coverage: skip
276276

277277

278278
def _join_url_paths(*args: str) -> str:

idom/server/prefab.py renamed to src/idom/server/prefab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def run(
4444
The server instance. This isn't really useful unless the server is spawned
4545
as a daemon. Otherwise this function blocks until the server has stopped.
4646
"""
47-
if server_type is None: # pragma: no cover
47+
if server_type is None: # coverage: skip
4848
raise ValueError("No default server available.")
49-
if port is None: # pragma: no cover
49+
if port is None: # coverage: skip
5050
port = find_available_port(host)
5151

5252
server = server_type(component, server_config)
5353

54-
if app is not None: # pragma: no cover
54+
if app is not None: # coverage: skip
5555
server.register(app)
5656

5757
run_server = server.run if not daemon else server.daemon

0 commit comments

Comments
 (0)