Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Changed

* Moved to src/ based layout for generated packages
* Moved from setup.cfg/.py to pyproject.toml [#351](https://github.com/NLeSC/python-template/issues/351)
* Moved from prospector to ruff [#336](https://github.com/NLeSC/python-template/issues/336)
* Renamed `project_name` to `directory_name` in cookiecutter questionnaire
Expand Down
44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ Good job! You have now generated the skeleton for your package:

```text
my-python-project/
├── CHANGELOG.md
├── CITATION.cff
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── docs
│ ├── conf.py
│ ├── index.rst
│ ├── make.bat
│ ├── Makefile
│ ├── _static
│ │ └── theme_overrides.css
│ └── _templates
│ └── .gitignore
├── .editorconfig
├── .githooks
│ └── pre-commit
Expand All @@ -115,26 +102,37 @@ my-python-project/
│ └── workflows
│ ├── build.yml
│ ├── cffconvert.yml
│ ├── lint.yml
│ ├── documentation.yml
│ ├── markdown-link-check.yml
│ ├── next_steps.yml
│ └── sonarcloud.yml
├── .gitignore
├── .mlc-config.json
├── .readthedocs.yaml
├── CHANGELOG.md
├── CITATION.cff
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── MANIFEST.in
├── .mlc-config.json
├── my_python_package
│ ├── __init__.py
│ ├── my_module.py
│ └── __version__.py
├── next_steps.md
├── NOTICE
├── project_setup.md
├── .pylintrc
├── pyproject.toml
├── README.dev.md
├── README.md
├── docs
│ ├── Makefile
│ ├── _templates
│ │ └── .gitignore
│ ├── conf.py
│ ├── index.rst
│ └── make.bat
├── next_steps.md
├── project_setup.md
├── pyproject.toml
├── sonar-project.properties
├── src
│ └── my_python_package
│ ├── __init__.py
│ └── my_module.py
└── tests
├── __init__.py
└── test_my_module.py
Expand Down
8 changes: 4 additions & 4 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir):
"""Test if subpackages end up in (wheel) distributions"""
project_dir = baked_with_development_dependencies
bin_dir = project_env_bin_dir
subpackage = (project_dir / 'my_python_package' / 'mysub')
subpackage = (project_dir / 'src' / 'my_python_package' / 'mysub')
subpackage.mkdir()
(subpackage / '__init__.py').write_text('FOO = "bar"\n', encoding="utf-8")

subsubpackage = (project_dir / 'my_python_package' / 'mysub' / 'mysub2')
subsubpackage = (project_dir / 'src' / 'my_python_package' / 'mysub' / 'mysub2')
subsubpackage.mkdir()
(subsubpackage / '__init__.py').write_text('FOO = "bar"\n', encoding="utf-8")

Expand Down Expand Up @@ -179,7 +179,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir):
original_version = '0.1.0'
assert original_version in (project_dir / 'pyproject.toml').read_text('utf-8')
assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8')
assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8')
assert original_version in (project_dir / 'src' / 'my_python_package' / '__init__.py').read_text('utf-8')
assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8')

result = run([f'{bin_dir}bump-my-version', 'major'], project_dir)
Expand All @@ -188,5 +188,5 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir):
expected_version = '1.0.0'
assert expected_version in (project_dir / 'pyproject.toml').read_text('utf-8')
assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8')
assert expected_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8')
assert expected_version in (project_dir / 'src' / 'my_python_package' / '__init__.py').read_text('utf-8')
assert expected_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8')
2 changes: 1 addition & 1 deletion {{cookiecutter.directory_name}}/.githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo "Script $0 triggered ..."
echo "Starting ruff analysis..."

# quietly run ruff
ruff . --fix
ruff check . --fix

# use return code to abort commit if necessary
if [ $? != "0" ]; then
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.directory_name}}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

# -- Use autoapi.extension to run sphinx-apidoc -------

autoapi_dirs = ['../{{ cookiecutter.package_name }}']
autoapi_dirs = ['../src/{{ cookiecutter.package_name }}']

# -- Options for HTML output ----------------------------------------------

Expand Down
67 changes: 33 additions & 34 deletions {{cookiecutter.directory_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,17 @@ testpaths = ["tests"]

[tool.coverage.run]
branch = true
source = ["{{ cookiecutter.package_name }}"]
source = ["src/{{ cookiecutter.package_name }}"]
command_line = "-m pytest"

[tool.isort]
lines_after_imports = 2
force_single_line = 1
no_lines_before = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
known_first_party = "{{ cookiecutter.package_name }}"
src_paths = ["{{ cookiecutter.package_name }}", "tests"]
src_paths = ["src/{{ cookiecutter.package_name }}", "tests"]
line_length = 120

# For completeness, until we move to an src-based layout
[tool.setuptools.packages.find]
include = ["{{ cookiecutter.package_name }}*"]
exclude = ["tests*"]

[tool.tox]
legacy_tox_ini = """
[tox]
Expand All @@ -99,6 +94,35 @@ extras = dev
"""

[tool.ruff]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".venv",
"scripts",
]

target-version = "py39"
line-length = 120


[tool.ruff.lint]
# Enable Pyflakes `E` and `F` codes by default.
select = [
"F", # Pyflakes
Expand Down Expand Up @@ -136,39 +160,14 @@ ignore = [
fixable = ["A", "B", "C", "D", "E", "F", "I"]
unfixable = []

exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
".venv",
"scripts",
]
per-file-ignores = {}


# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

target-version = "py39"
line-length = 120

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["{{ cookiecutter.package_name }}"]
force-single-line = true
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]
Expand All @@ -177,7 +176,7 @@ no-lines-before = ["future","standard-library","third-party","first-party","loca
current_version = "{{ cookiecutter.version }}"

[[tool.bumpversion.files]]
filename = "{{ cookiecutter.package_name }}/__init__.py"
filename = "src/{{ cookiecutter.package_name }}/__init__.py"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.directory_name}}/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.organization={{ cookiecutter.github_organization }}
sonar.projectKey={{ cookiecutter.github_organization }}_{{ cookiecutter.directory_name }}
sonar.host.url=https://sonarcloud.io
sonar.sources={{ cookiecutter.package_name }}/
sonar.sources=src/{{ cookiecutter.package_name }}/
sonar.tests=tests/
sonar.links.homepage={{ cookiecutter.repository_url }}
sonar.links.scm={{ cookiecutter.repository }}
Expand Down