Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to src layout #921

Merged
merged 12 commits into from
Mar 9, 2023
Merged
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ follow_imports = "skip"
follow_imports_for_stubs = true


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# PYTEST CONFIGURATION #
Comment on lines +76 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the changes to this file related to switching to src layout or is this something separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's separate, but would be good to have. VSCode would automatically detect the tests

[tool.pytest.ini_options]
addopts = [
"--strict-markers",
"--strict-config",
"--showlocals",
"-ra",
]
testpaths = "tests"


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# COVERAGE CONFIGURATION #
[tool.coverage.report]
Expand All @@ -84,6 +96,11 @@ exclude_lines = [
"raise ValueError",
]

[tool.coverage.paths]
source = [
"src",
".tox/*/site-packages",
]

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# NBQA CONFIGURATION #
Expand Down
4 changes: 4 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pre-commit
pytest
pytest-cov
pytest-sugar
pytest-xdist
coverage[toml]
tox
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from setuptools import find_packages, setup


def load_module(name: str = "anomalib/__init__.py") -> ModuleType:
def load_module(name: str = "src/anomalib/__init__.py") -> ModuleType:
"""Load Python Module.

Args:
Expand Down Expand Up @@ -45,7 +45,7 @@ def get_version() -> str:
Returns:
str: `anomalib` version.
"""
anomalib = load_module(name="anomalib/__init__.py")
anomalib = load_module(name="src/anomalib/__init__.py")
version = anomalib.__version__
return version

Expand Down Expand Up @@ -102,7 +102,8 @@ def get_required_packages(requirement_files: list[str]) -> list[str]:
'Licensed under the Apache License, Version 2.0 (the "License")'
"See LICENSE file for more details.",
python_requires=">=3.7",
packages=find_packages(exclude=("tests",)),
package_dir={"": "src"},
packages=find_packages(where="src", include=["anomalib", "anomalib.*"]),
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
package_data={"": ["config.yaml"]},
Expand Down
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.
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.
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.
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.
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ deps =
commands =
; 1. Run Coverage First.
coverage erase
coverage run --include=anomalib/* -m pytest {posargs:tests/pre_merge/} -ra --showlocals
coverage run --include=anomalib/* -m pytest {posargs:tests/pre_merge/}
; https://github.com/openvinotoolkit/anomalib/issues/94
coverage report -m --fail-under=85
coverage xml -o {toxworkdir}/coverage.xml
Expand All @@ -57,7 +57,7 @@ deps =
-r{toxinidir}/requirements/extras.txt
commands =
coverage erase
coverage run --include=anomalib/* -m pytest tests/nightly/ -ra --showlocals
coverage run --include=anomalib/* -m pytest tests/nightly/
coverage report -m --fail-under=33
coverage xml -o {toxworkdir}/coverage.xml

Expand Down