Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-hatch_vcs for openSUSE:Factory checked in at 2022-12-08 16:50:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-hatch_vcs (Old) and /work/SRC/openSUSE:Factory/.python-hatch_vcs.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-hatch_vcs" Thu Dec 8 16:50:14 2022 rev:3 rq:1040885 version:0.2.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-hatch_vcs/python-hatch_vcs.changes 2022-11-12 17:40:25.677903244 +0100 +++ /work/SRC/openSUSE:Factory/.python-hatch_vcs.new.1835/python-hatch_vcs.changes 2022-12-08 16:50:16.599204000 +0100 @@ -1,0 +2,8 @@ +Wed Dec 7 06:34:23 UTC 2022 - Johannes Kastl <ka...@b1-systems.de> + +- update to 0.2.1: + * Fixed: + - Allow root in raw-options +- drop patch fix-tests-setuptools-scm7.patch + +------------------------------------------------------------------- Old: ---- fix-tests-setuptools-scm7.patch hatch_vcs-0.2.0.tar.gz New: ---- _service hatch_vcs-0.2.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-hatch_vcs.spec ++++++ --- /var/tmp/diff_new_pack.K6c2Qb/_old 2022-12-08 16:50:17.051206313 +0100 +++ /var/tmp/diff_new_pack.K6c2Qb/_new 2022-12-08 16:50:17.055206333 +0100 @@ -19,14 +19,12 @@ %{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 Name: python-hatch_vcs -Version: 0.2.0 +Version: 0.2.1 Release: 0 Summary: Hatch plugin for versioning with your preferred VCS License: MIT URL: https://github.com/ofek/hatch-vcs Source: https://files.pythonhosted.org/packages/source/h/hatch_vcs/hatch_vcs-%{version}.tar.gz -# PATCH-FIX-UPSTREAM fix-tests-setuptools-scm7.patch gh#ofek/hatch-vcs#9 -Patch0: fix-tests-setuptools-scm7.patch BuildRequires: fdupes BuildRequires: python-rpm-macros >= 20210929 Requires: python-hatchling >= 0.21.0 @@ -49,7 +47,7 @@ This provides a plugin for Hatch that uses your preferred version control system (like Git) to determine project versions. %prep -%autosetup -p1 -n hatch_vcs-%{version} +%autosetup -n hatch_vcs-%{version} %build %pyproject_wheel ++++++ _service ++++++ <services> <service name="download_files" mode="disabled"> </service> </services> ++++++ hatch_vcs-0.2.0.tar.gz -> hatch_vcs-0.2.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/.flake8 new/hatch_vcs-0.2.1/.flake8 --- old/hatch_vcs-0.2.0/.flake8 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/.flake8 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -# TODO: move this to pyproject.toml when supported, see https://github.com/PyCQA/flake8/issues/234 - -[flake8] -select = B,C,E,F,W,B001,B003,B006,B007,B301,B305,B306,B902,Q000,Q001,Q002,Q003 -ignore = E203,E722,W503 -max-line-length = 120 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/.github/workflows/test.yml new/hatch_vcs-0.2.1/.github/workflows/test.yml --- old/hatch_vcs-0.2.0/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 @@ -24,7 +24,7 @@ fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v2 @@ -35,7 +35,7 @@ python-version: ${{ matrix.python-version }} - name: Install Hatch - run: pip install --upgrade --pre hatch + run: pip install --upgrade hatch - if: matrix.python-version == '3.9' && runner.os == 'Linux' name: Lint @@ -52,4 +52,4 @@ - if: matrix.python-version == '3.9' name: Run tests on Python 2.7 - run: hatch run test.py27:no-cov + run: hatch run all.py2.7:test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/HISTORY.md new/hatch_vcs-0.2.1/HISTORY.md --- old/hatch_vcs-0.2.0/HISTORY.md 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/HISTORY.md 2020-02-02 01:00:00.000000000 +0100 @@ -8,6 +8,12 @@ ## Unreleased +## 0.2.1 - 2022-12-06 + +***Fixed:*** + +- Allow `root` in `raw-options` + ## 0.2.0 - 2022-03-18 ***Added:*** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/PKG-INFO new/hatch_vcs-0.2.1/PKG-INFO --- old/hatch_vcs-0.2.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,20 +1,23 @@ Metadata-Version: 2.1 Name: hatch-vcs -Version: 0.2.0 +Version: 0.2.1 Summary: Hatch plugin for versioning with your preferred VCS Project-URL: Funding, https://github.com/sponsors/ofek Project-URL: History, https://github.com/ofek/hatch-vcs/blob/master/HISTORY.md Project-URL: Issues, https://github.com/ofek/hatch-vcs/issues Project-URL: Source, https://github.com/ofek/hatch-vcs Author-email: Ofek Lev <o...@ofek.dev> +License: MIT +License-File: LICENSE.txt Keywords: git,hatch,mercurial,plugin,scm,vcs,version Classifier: Development Status :: 4 - Beta Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Requires-Dist: hatchling>=0.21.0 @@ -28,19 +31,21 @@ | --- | --- | | CI/CD | [](https://github.com/ofek/hatch-vcs/actions/workflows/test.yml) [](https://github.com/ofek/hatch-vcs/actions/workflows/build.yml) | | Package | [](https://pypi.org/project/hatch-vcs/) [](https://pypi.org/project/hatch-vcs/) | -| Meta | [](https://github.com/psf/black) [](https://github.com/ambv/black) [](https://github.com/pycqa/isort) [](https://spdx.org/licenses/) [](https://github.com/sponsors/ofek) | +| Meta | [](https://github.com/pypa/hatch) [](https://github.com/psf/black) [](https://github.com/ambv/black) [](https://spdx.org/licenses/) [](https://github.com/sponsors/ofek) | ----- -This provides a plugin for [Hatch](https://github.com/ofek/hatch) that uses your preferred version control system (like Git) to determine project versions. +This provides a plugin for [Hatch](https://github.com/pypa/hatch) that uses your preferred version control system (like Git) to determine project versions. **Table of Contents** - [Global dependency](#global-dependency) - [Version source](#version-source) - [Version source options](#version-source-options) + - [Version source environment variables](#version-source-environment-variables) - [Build hook](#build-hook) - [Build hook options](#build-hook-options) + - [Editable installs](#editable-installs) - [License](#license) ## Global dependency @@ -55,7 +60,7 @@ ## Version source -The [version source plugin](https://ofek.dev/hatch/latest/plugins/version-source/) name is `vcs`. +The [version source plugin](https://hatch.pypa.io/latest/plugins/version-source/) name is `vcs`. - ***pyproject.toml*** @@ -79,20 +84,38 @@ | `fallback-version` | `str` | | The version that will be used if no other method for detecting the version is successful. If not specified, unsuccessful version detection will raise an error. | | `raw-options` | `dict` | | A table of [`setuptools-scm` parameters](https://github.com/pypa/setuptools_scm#configuration-parameters) that will override any of the options listed above. The `write_to` and `write_to_template` parameters are ignored. | +### Version source environment variables + +- `SETUPTOOLS_SCM_PRETEND_VERSION`: When defined and not empty, it's used as the primary source for the version, in which case it will be an unparsed string. + ## Build hook -The [build hook plugin](https://ofek.dev/hatch/latest/plugins/build-hook/) name is `vcs`. +The [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) name is `vcs`. - ***pyproject.toml*** ```toml [tool.hatch.build.hooks.vcs] + version-file = "_version.py" ``` - ***hatch.toml*** ```toml [build.hooks.vcs] + version-file = "_version.py" + ``` + +Building or installing when the latest tag is ``v1.2.3`` will generate the file + +- ***_version.py*** + + ```python + # coding: utf-8 + # file generated by setuptools_scm + # don't change, don't track in version control + __version__ = version = '1.2.3' + __version_tuple__ = version_tuple = (1, 2, 3) ``` ### Build hook options @@ -102,6 +125,10 @@ | `version-file` | `str` | ***REQUIRED*** | The relative path to the file that gets updated with the current version. | | `template` | `str` | | The template used to overwrite the `version-file`. See the [code](https://github.com/pypa/setuptools_scm/blob/v6.4.0/src/setuptools_scm/__init__.py#L30-L39) for the default template for each file extension. | +### Editable installs + +The version file is only updated upon install or build. Thus the version number in an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs) (Hatch's [dev mode](https://hatch.pypa.io/latest/config/build/#dev-mode)) will be incorrect if the version changes and the project is not rebuilt. An unsupported workaround for keeping the version number up-to-date can be found at [hatch-vcs-footgun-example](https://github.com/maresb/hatch-vcs-footgun-example). + ## License `hatch-vcs` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/README.md new/hatch_vcs-0.2.1/README.md --- old/hatch_vcs-0.2.0/README.md 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/README.md 2020-02-02 01:00:00.000000000 +0100 @@ -4,19 +4,21 @@ | --- | --- | | CI/CD | [](https://github.com/ofek/hatch-vcs/actions/workflows/test.yml) [](https://github.com/ofek/hatch-vcs/actions/workflows/build.yml) | | Package | [](https://pypi.org/project/hatch-vcs/) [](https://pypi.org/project/hatch-vcs/) | -| Meta | [](https://github.com/psf/black) [](https://github.com/ambv/black) [](https://github.com/pycqa/isort) [](https://spdx.org/licenses/) [](https://github.com/sponsors/ofek) | +| Meta | [](https://github.com/pypa/hatch) [](https://github.com/psf/black) [](https://github.com/ambv/black) [](https://spdx.org/licenses/) [](https://github.com/sponsors/ofek) | ----- -This provides a plugin for [Hatch](https://github.com/ofek/hatch) that uses your preferred version control system (like Git) to determine project versions. +This provides a plugin for [Hatch](https://github.com/pypa/hatch) that uses your preferred version control system (like Git) to determine project versions. **Table of Contents** - [Global dependency](#global-dependency) - [Version source](#version-source) - [Version source options](#version-source-options) + - [Version source environment variables](#version-source-environment-variables) - [Build hook](#build-hook) - [Build hook options](#build-hook-options) + - [Editable installs](#editable-installs) - [License](#license) ## Global dependency @@ -31,7 +33,7 @@ ## Version source -The [version source plugin](https://ofek.dev/hatch/latest/plugins/version-source/) name is `vcs`. +The [version source plugin](https://hatch.pypa.io/latest/plugins/version-source/) name is `vcs`. - ***pyproject.toml*** @@ -55,20 +57,38 @@ | `fallback-version` | `str` | | The version that will be used if no other method for detecting the version is successful. If not specified, unsuccessful version detection will raise an error. | | `raw-options` | `dict` | | A table of [`setuptools-scm` parameters](https://github.com/pypa/setuptools_scm#configuration-parameters) that will override any of the options listed above. The `write_to` and `write_to_template` parameters are ignored. | +### Version source environment variables + +- `SETUPTOOLS_SCM_PRETEND_VERSION`: When defined and not empty, it's used as the primary source for the version, in which case it will be an unparsed string. + ## Build hook -The [build hook plugin](https://ofek.dev/hatch/latest/plugins/build-hook/) name is `vcs`. +The [build hook plugin](https://hatch.pypa.io/latest/plugins/build-hook/) name is `vcs`. - ***pyproject.toml*** ```toml [tool.hatch.build.hooks.vcs] + version-file = "_version.py" ``` - ***hatch.toml*** ```toml [build.hooks.vcs] + version-file = "_version.py" + ``` + +Building or installing when the latest tag is ``v1.2.3`` will generate the file + +- ***_version.py*** + + ```python + # coding: utf-8 + # file generated by setuptools_scm + # don't change, don't track in version control + __version__ = version = '1.2.3' + __version_tuple__ = version_tuple = (1, 2, 3) ``` ### Build hook options @@ -78,6 +98,10 @@ | `version-file` | `str` | ***REQUIRED*** | The relative path to the file that gets updated with the current version. | | `template` | `str` | | The template used to overwrite the `version-file`. See the [code](https://github.com/pypa/setuptools_scm/blob/v6.4.0/src/setuptools_scm/__init__.py#L30-L39) for the default template for each file extension. | +### Editable installs + +The version file is only updated upon install or build. Thus the version number in an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs) (Hatch's [dev mode](https://hatch.pypa.io/latest/config/build/#dev-mode)) will be incorrect if the version changes and the project is not rebuilt. An unsupported workaround for keeping the version number up-to-date can be found at [hatch-vcs-footgun-example](https://github.com/maresb/hatch-vcs-footgun-example). + ## License `hatch-vcs` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/hatch.toml new/hatch_vcs-0.2.1/hatch.toml --- old/hatch_vcs-0.2.0/hatch.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/hatch.toml 2020-02-02 01:00:00.000000000 +0100 @@ -1,40 +1,44 @@ [envs.default] dependencies = [ + "coverage[toml]", "pytest", - "pytest-cov", ] [envs.default.scripts] -cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=hatch_vcs --cov=tests" -no-cov = "cov --no-cov" +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" +cov-report = [ + "- coverage combine", + "coverage report --show-missing", +] +cov = [ + "test-cov", + "cov-report", +] -[envs.test.overrides] +[envs.all.overrides] matrix.python.dev-mode = [ - { value = false, if = ["27"] }, + { value = false, if = ["2.7"] }, ] -[[envs.test.matrix]] -python = ["27", "37", "38", "39", "310"] +[[envs.all.matrix]] +python = ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] [envs.lint] -skip-install = true +detached = true dependencies = [ - "flake8~=4.0.1", - "flake8-bugbear~=21.11.29", - "flake8-quotes~=3.3.1", - "black~=21.12b0", - "isort~=5.10.1", - "mypy~=0.931", + "black>=22.10.0", + "mypy>=0.991", + "ruff>=0.0.166", ] [envs.lint.scripts] -typing = "mypy --install-types --non-interactive hatch_vcs tests" +typing = "mypy --install-types --non-interactive {args:hatch_vcs tests}" style = [ - "flake8 .", - "black --check --diff .", - "isort --check-only --diff .", + "ruff {args:.}", + "black --check --diff {args:.}", ] fmt = [ - "isort .", - "black .", + "black {args:.}", + "ruff --fix {args:.}", "style", ] all = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/hatch_vcs/__about__.py new/hatch_vcs-0.2.1/hatch_vcs/__about__.py --- old/hatch_vcs-0.2.0/hatch_vcs/__about__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/hatch_vcs/__about__.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2022-present Ofek Lev <o...@ofek.dev> # # SPDX-License-Identifier: MIT -__version__ = '0.2.0' +__version__ = '0.2.1' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/hatch_vcs/build_hook.py new/hatch_vcs-0.2.1/hatch_vcs/build_hook.py --- old/hatch_vcs-0.2.0/hatch_vcs/build_hook.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/hatch_vcs/build_hook.py 2020-02-02 01:00:00.000000000 +0100 @@ -8,7 +8,7 @@ PLUGIN_NAME = 'vcs' def __init__(self, *args, **kwargs): - super(VCSBuildHook, self).__init__(*args, **kwargs) + super(VCSBuildHook, self).__init__(*args, **kwargs) # noqa: UP008 self.__config_version_file = None self.__config_template = None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/hatch_vcs/hooks.py new/hatch_vcs-0.2.1/hatch_vcs/hooks.py --- old/hatch_vcs-0.2.0/hatch_vcs/hooks.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/hatch_vcs/hooks.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,8 +3,8 @@ # SPDX-License-Identifier: MIT from hatchling.plugin import hookimpl -from .build_hook import VCSBuildHook -from .version_source import VCSVersionSource +from hatch_vcs.build_hook import VCSBuildHook +from hatch_vcs.version_source import VCSVersionSource @hookimpl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/hatch_vcs/version_source.py new/hatch_vcs-0.2.1/hatch_vcs/version_source.py --- old/hatch_vcs-0.2.0/hatch_vcs/version_source.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/hatch_vcs/version_source.py 2020-02-02 01:00:00.000000000 +0100 @@ -8,7 +8,7 @@ PLUGIN_NAME = 'vcs' def __init__(self, *args, **kwargs): - super(VCSVersionSource, self).__init__(*args, **kwargs) + super(VCSVersionSource, self).__init__(*args, **kwargs) # noqa: UP008 self.__config_tag_pattern = None self.__config_fallback_version = None @@ -47,13 +47,11 @@ return self.__config_raw_options - def get_version_data(self): + def construct_setuptools_scm_config(self): from copy import deepcopy - from setuptools_scm import get_version - config = deepcopy(self.config_raw_options) - config['root'] = self.root + config.setdefault('root', self.root) config.setdefault('tag_regex', self.config_tag_pattern) @@ -64,6 +62,10 @@ # Writing only occurs when the build hook is enabled config.pop('write_to', None) config.pop('write_to_template', None) + return config + + def get_version_data(self): + from setuptools_scm import get_version - version = get_version(**config) + version = get_version(**self.construct_setuptools_scm_config()) return {'version': version} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/mypy.ini new/hatch_vcs-0.2.1/mypy.ini --- old/hatch_vcs-0.2.0/mypy.ini 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/mypy.ini 1970-01-01 01:00:00.000000000 +0100 @@ -1,8 +0,0 @@ -[mypy] -disallow_untyped_defs = false -follow_imports = normal -ignore_missing_imports = true -pretty = true -show_column_numbers = true -warn_no_return = false -warn_unused_ignores = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/pyproject.toml new/hatch_vcs-0.2.1/pyproject.toml --- old/hatch_vcs-0.2.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -4,9 +4,10 @@ [project] name = "hatch-vcs" +dynamic = ["version"] description = 'Hatch plugin for versioning with your preferred VCS' readme = "README.md" -license = "MIT" +license = { text = "MIT" } keywords = [ "git", "hatch", @@ -27,6 +28,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] @@ -35,7 +37,6 @@ "setuptools-scm>=6.4.0; python_version > '3'", "setuptools-scm<6; python_version < '3'", ] -dynamic = ["version"] [project.urls] Funding = "https://github.com/sponsors/ofek" @@ -49,31 +50,81 @@ [tool.hatch.version] path = "hatch_vcs/__about__.py" -[tool.hatch.build.targets.sdist] -[tool.hatch.build.targets.wheel] - [tool.black] -include = '\.pyi?$' +target-version = ["py37"] line-length = 120 skip-string-normalization = true -target-version = ["py37"] -[tool.isort] -default_section = "THIRDPARTY" -force_grid_wrap = 0 -include_trailing_comma = true -known_first_party = ["hatch_vcs"] -line_length = 120 -multi_line_output = 3 -use_parentheses = true +[tool.ruff] +target-version = "py37" +line-length = 120 +select = [ + "A", + "B", + "C", + "E", + "F", + "FBT", + "I", + "N", + "Q", + "RUF", + "S", + "T", + "UP", + "W", + "YTT", +] +ignore = [ + # Allow non-abstract empty methods in abstract base classes + "B027", + # Ignore McCabe complexity + "C901", + # Allow boolean positional values in function calls, like `dict.get(... True)` + "FBT003", + # Ignore checks for possible passwords + "S105", "S106", "S107", +] +unfixable = [ + # Don't touch unused imports + "F401", +] + +[tool.ruff.isort] +known-first-party = ["hatch_vcs"] + +[tool.ruff.flake8-quotes] +inline-quotes = "single" + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.per-file-ignores] +# Tests can use relative imports and assertions +"tests/**/*" = ["I252", "S101"] + +[tool.mypy] +disallow_untyped_defs = false +follow_imports = "normal" +ignore_missing_imports = true +pretty = true +show_column_numbers = true +show_error_codes = true +warn_no_return = false +warn_unused_ignores = true [tool.coverage.run] +source_pkgs = ["hatch_vcs", "tests"] branch = true parallel = true omit = [ "hatch_vcs/__about__.py", ] +[tool.coverage.paths] +hatch_vcs = ["hatch_vcs", "*/hatch-vcs/hatch_vcs"] +tests = ["tests", "*/hatch-vcs/tests"] + [tool.coverage.report] exclude_lines = [ "no cov", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/tests/conftest.py new/hatch_vcs-0.2.1/tests/conftest.py --- old/hatch_vcs-0.2.0/tests/conftest.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/tests/conftest.py 2020-02-02 01:00:00.000000000 +0100 @@ -33,13 +33,17 @@ @contextmanager -def create_project(directory, metadata, setup_vcs=True): - project_dir = os.path.join(directory, 'my-app') - os.mkdir(project_dir) +def create_project(directory, metadata, setup_vcs=True, nested=False): # noqa: FBT002 + root_dir = project_dir = os.path.join(directory, 'my-app') + os.mkdir(root_dir) - gitignore_file = os.path.join(project_dir, '.gitignore') + gitignore_file = os.path.join(root_dir, '.gitignore') write_file(gitignore_file, '/my_app/version.py') + if nested: + project_dir = os.path.join(root_dir, 'project') + os.mkdir(project_dir) + project_file = os.path.join(project_dir, 'pyproject.toml') write_file(project_file, metadata) @@ -55,6 +59,9 @@ os.chdir(project_dir) try: if setup_vcs: + if nested: + os.chdir(root_dir) + git('init') git('config', '--local', 'user.name', 'foo') git('config', '--local', 'user.email', 'f...@bar.baz') @@ -62,6 +69,9 @@ git('commit', '-m', 'test') git('tag', '1.2.3') + if nested: + os.chdir(project_dir) + yield project_dir finally: os.chdir(origin) @@ -130,3 +140,25 @@ setup_vcs=False, ) as project: yield project + + +@pytest.fixture +def new_project_root_elsewhere(temp_dir): + with create_project( + temp_dir, + """\ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "my-app" +dynamic = ["version"] + +[tool.hatch.version] +source = "vcs" +raw-options = { root = ".." } +""", + nested=True, + ) as project: + yield project diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/tests/test_build.py new/hatch_vcs-0.2.1/tests/test_build.py --- old/hatch_vcs-0.2.0/tests/test_build.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/tests/test_build.py 2020-02-02 01:00:00.000000000 +0100 @@ -75,7 +75,8 @@ assert os.path.isfile(version_file) lines = read_file(version_file).splitlines() - assert lines[3] == "version = '1.2.3'" + assert lines[3].startswith(('version =', '__version__ =')) + assert lines[3].endswith("version = '1.2.3'") @pytest.mark.skipif(sys.version_info[0] == 2, reason='Depends on fix in 6.4.0 which is Python 3-only') @@ -101,6 +102,37 @@ assert os.path.isdir(metadata_directory) package_directory = os.path.join(extraction_directory, 'my_app') + assert os.path.isdir(package_directory) + assert len(os.listdir(package_directory)) == 4 + + assert os.path.isfile(os.path.join(package_directory, '__init__.py')) + assert os.path.isfile(os.path.join(package_directory, 'foo.py')) + assert os.path.isfile(os.path.join(package_directory, 'bar.py')) + assert os.path.isfile(os.path.join(package_directory, 'baz.py')) + + +def test_root(new_project_root_elsewhere): + build_project('-t', 'wheel') + + build_dir = os.path.join(new_project_root_elsewhere, 'dist') + assert os.path.isdir(build_dir) + + artifacts = os.listdir(build_dir) + assert len(artifacts) == 1 + wheel_file = artifacts[0] + + assert wheel_file == 'my_app-1.2.3-py2.py3-none-any.whl' + + extraction_directory = os.path.join(os.path.dirname(new_project_root_elsewhere), '_archive') + os.mkdir(extraction_directory) + + with zipfile.ZipFile(os.path.join(build_dir, wheel_file), 'r') as zip_archive: + zip_archive.extractall(extraction_directory) + + metadata_directory = os.path.join(extraction_directory, 'my_app-1.2.3.dist-info') + assert os.path.isdir(metadata_directory) + + package_directory = os.path.join(extraction_directory, 'my_app') assert os.path.isdir(package_directory) assert len(os.listdir(package_directory)) == 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatch_vcs-0.2.0/tests/utils.py new/hatch_vcs-0.2.1/tests/utils.py --- old/hatch_vcs-0.2.0/tests/utils.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatch_vcs-0.2.1/tests/utils.py 2020-02-02 01:00:00.000000000 +0100 @@ -12,7 +12,7 @@ def read_file(path): - with open(path, 'r') as f: + with open(path) as f: return f.read() @@ -21,16 +21,21 @@ f.write(contents) -def build_project(*args): - _run_command(sys.executable, '-m', 'hatchling', 'build', *args) +def build_project(*args, **kwargs): + if 'env' not in kwargs: + env = os.environ.copy() + env.pop('SETUPTOOLS_SCM_PRETEND_VERSION', None) + else: + env = kwargs['env'] + _run_command(sys.executable, '-m', 'hatchling', 'build', *args, env=env) def git(*args): _run_command('git', *args) -def _run_command(*command): - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) +def _run_command(*command, **kwargs): + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs) stdout, _ = process.communicate() if process.returncode: # no cov