diff --git a/docs/history.md b/docs/history.md index 20891b80f..e96ff4dd5 100644 --- a/docs/history.md +++ b/docs/history.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Unreleased +***Changed:*** + +- Rename the default publishing plugin from `pypi` to the more generic `index` + ***Added:*** - Support the absence of `pyproject.toml` files, as is the case for apps and non-Python projects diff --git a/docs/plugins/publisher/pypi.md b/docs/plugins/publisher/index.md similarity index 86% rename from docs/plugins/publisher/pypi.md rename to docs/plugins/publisher/index.md index 994e2d9e3..335020d9d 100644 --- a/docs/plugins/publisher/pypi.md +++ b/docs/plugins/publisher/index.md @@ -1,4 +1,4 @@ -# PyPI publisher +# Index publisher ----- @@ -6,12 +6,12 @@ See the documentation for [publishing](../../publish.md). ## Configuration -The publisher plugin name is `pypi`. +The publisher plugin name is `index`. === ":octicons-file-code-16: config.toml" ```toml - [publish.pypi] + [publish.index] ``` ## Options diff --git a/docs/publish.md b/docs/publish.md index 5ed3569bd..4dc318a57 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -4,7 +4,7 @@ After your project is [built](build.md), you can distribute it using the [`publish`](cli/reference.md#hatch-publish) command. -The `-p`/`--publisher` option controls which publisher to use, with the default being [pypi](plugins/publisher/pypi.md). +The `-p`/`--publisher` option controls which publisher to use, with the default being [index](plugins/publisher/index.md). ## Artifact selection @@ -29,14 +29,14 @@ Only files ending with `.whl` or `.tar.gz` will be published. ## Repository -You can select the repository (package index) with which to upload using the `-r`/`--repo` option or by setting the `HATCH_PYPI_REPO` environment variable. +You can select the repository with which to upload using the `-r`/`--repo` option or by setting the `HATCH_INDEX_REPO` environment variable. -Rather than specifying the full URL of a repository, you can use a named repository from a `publish.pypi.repos` table defined in Hatch's [config file](config/hatch.md): +Rather than specifying the full URL of a repository, you can use a named repository from a `publish.index.repos` table defined in Hatch's [config file](config/hatch.md): === ":octicons-file-code-16: config.toml" ```toml - [publish.pypi.repos] + [publish.index.repos] repo1 = "url1" ... ``` @@ -52,7 +52,7 @@ The `main` repository is used by default. ## Authentication -The first time you publish to a repository you need to authenticate using the `-u`/`--user` (environment variable `HATCH_PYPI_USER`) and `-a`/`--auth` (environment variable `HATCH_PYPI_AUTH`) options. You will be prompted if either option is not provided. +The first time you publish to a repository you need to authenticate using the `-u`/`--user` (environment variable `HATCH_INDEX_USER`) and `-a`/`--auth` (environment variable `HATCH_INDEX_AUTH`) options. You will be prompted if either option is not provided. The user that most recently published to the chosen repository is [cached](config/hatch.md#cache), with their credentials saved to the system [keyring](https://github.com/jaraco/keyring), so that they will no longer need to provide authentication information. @@ -65,20 +65,20 @@ You can require a confirmation prompt or use of the `-y`/`--yes` flag by setting === ":octicons-file-code-16: config.toml" ```toml - [publish.pypi] + [publish.index] disable = true ``` === ":octicons-file-code-16: pyproject.toml" ```toml - [tool.hatch.publish.pypi] + [tool.hatch.publish.index] disable = true ``` === ":octicons-file-code-16: hatch.toml" ```toml - [publish.pypi] + [publish.index] disable = true ``` diff --git a/mkdocs.yml b/mkdocs.yml index 4f74f48f9..d2a129501 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -90,7 +90,7 @@ nav: - Default: plugins/environment-collector/default.md - Publisher: - Reference: plugins/publisher/reference.md - - PyPI: plugins/publisher/pypi.md + - Index: plugins/publisher/index.md - Version source: - Reference: plugins/version-source/reference.md - Regex: plugins/version-source/regex.md diff --git a/src/hatch/cli/publish/__init__.py b/src/hatch/cli/publish/__init__.py index 0596d07c2..0490147ff 100644 --- a/src/hatch/cli/publish/__init__.py +++ b/src/hatch/cli/publish/__init__.py @@ -6,19 +6,19 @@ @click.command(short_help='Publish build artifacts') @click.argument('artifacts', nargs=-1) @click.option( - '--user', '-u', envvar=PublishEnvVars.USER, help='The user with which to authenticate [env var: `HATCH_PYPI_USER`]' + '--user', '-u', envvar=PublishEnvVars.USER, help='The user with which to authenticate [env var: `HATCH_INDEX_USER`]' ) @click.option( '--auth', '-a', envvar=PublishEnvVars.AUTH, - help='The credentials to use for authentication [env var: `HATCH_PYPI_AUTH`]', + help='The credentials to use for authentication [env var: `HATCH_INDEX_AUTH`]', ) @click.option( '--repo', '-r', envvar=PublishEnvVars.REPO, - help='The repository with which to publish artifacts [env var: `HATCH_PYPI_REPO`]', + help='The repository with which to publish artifacts [env var: `HATCH_INDEX_REPO`]', ) @click.option('--no-prompt', '-n', is_flag=True, help='Disable prompts, such as for missing required fields') @click.option( @@ -26,8 +26,8 @@ '-p', 'publisher_name', envvar=PublishEnvVars.PUBLISHER, - default='pypi', - help='The publisher plugin to use (default is `pypi`) [env var: `HATCH_PUBLISHER`]', + default='index', + help='The publisher plugin to use (default is `index`) [env var: `HATCH_PUBLISHER`]', ) @click.option( '--option', @@ -45,9 +45,9 @@ def publish(app, artifacts, user, auth, repo, no_prompt, publisher_name, options, yes): """Publish build artifacts.""" option_map = {'no_prompt': no_prompt} - if publisher_name == 'pypi': + if publisher_name == 'index': if options: - app.abort('Use the standard CLI flags rather than passing explicit options when using the `pypi` plugin') + app.abort('Use the standard CLI flags rather than passing explicit options when using the `index` plugin') if user: option_map['user'] = user diff --git a/src/hatch/config/constants.py b/src/hatch/config/constants.py index 6dc820f87..36cf4515e 100644 --- a/src/hatch/config/constants.py +++ b/src/hatch/config/constants.py @@ -19,8 +19,8 @@ class ConfigEnvVars: class PublishEnvVars: - USER = 'HATCH_PYPI_USER' - AUTH = 'HATCH_PYPI_AUTH' - REPO = 'HATCH_PYPI_REPO' + USER = 'HATCH_INDEX_USER' + AUTH = 'HATCH_INDEX_AUTH' + REPO = 'HATCH_INDEX_REPO' PUBLISHER = 'HATCH_PUBLISHER' OPTIONS = 'HATCH_PUBLISHER_OPTIONS' diff --git a/src/hatch/config/model.py b/src/hatch/config/model.py index 765762361..886b3ad8d 100644 --- a/src/hatch/config/model.py +++ b/src/hatch/config/model.py @@ -181,7 +181,7 @@ def publish(self): self._field_publish = publish else: - self._field_publish = self.raw_data['publish'] = {'pypi': {'user': '', 'auth': ''}} + self._field_publish = self.raw_data['publish'] = {'index': {'user': '', 'auth': ''}} return self._field_publish diff --git a/src/hatch/publish/pypi.py b/src/hatch/publish/index.py similarity index 99% rename from src/hatch/publish/pypi.py rename to src/hatch/publish/index.py index 022bc9e81..14c3c4863 100644 --- a/src/hatch/publish/pypi.py +++ b/src/hatch/publish/index.py @@ -22,8 +22,8 @@ RENAMED_METADATA_FIELDS = {'classifier': 'classifiers', 'project_url': 'project_urls'} -class PyPIPublisher(PublisherInterface): - PLUGIN_NAME = 'pypi' +class IndexPublisher(PublisherInterface): + PLUGIN_NAME = 'index' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/src/hatch/publish/plugin/hooks.py b/src/hatch/publish/plugin/hooks.py index f1586d85d..c2aa50d39 100644 --- a/src/hatch/publish/plugin/hooks.py +++ b/src/hatch/publish/plugin/hooks.py @@ -1,7 +1,7 @@ -from hatch.publish.pypi import PyPIPublisher +from hatch.publish.index import IndexPublisher from hatchling.plugin import hookimpl @hookimpl def hatch_register_publisher(): - return PyPIPublisher + return IndexPublisher diff --git a/tests/cli/config/test_set.py b/tests/cli/config/test_set.py index bd3ca7981..e9978999a 100644 --- a/tests/cli/config/test_set.py +++ b/tests/cli/config/test_set.py @@ -64,19 +64,19 @@ def test_standard_complex_map(hatch, config_file, helpers): def test_standard_hidden(hatch, config_file, helpers): - result = hatch('config', 'set', 'publish.pypi.auth', 'foo') + result = hatch('config', 'set', 'publish.index.auth', 'foo') assert result.exit_code == 0, result.output assert result.output == helpers.dedent( """ New setting: - [publish.pypi] + [publish.index] auth = "<...>" """ ) config_file.load() - assert config_file.model.publish['pypi']['auth'] == 'foo' + assert config_file.model.publish['index']['auth'] == 'foo' def test_prompt(hatch, config_file, helpers): @@ -96,20 +96,20 @@ def test_prompt(hatch, config_file, helpers): def test_prompt_hidden(hatch, config_file, helpers): - result = hatch('config', 'set', 'publish.pypi.auth', input='foo') + result = hatch('config', 'set', 'publish.index.auth', input='foo') assert result.exit_code == 0, result.output assert result.output == helpers.dedent( f""" - Value for `publish.pypi.auth`:{' '} + Value for `publish.index.auth`:{' '} New setting: - [publish.pypi] + [publish.index] auth = "<...>" """ ) config_file.load() - assert config_file.model.publish['pypi']['auth'] == 'foo' + assert config_file.model.publish['index']['auth'] == 'foo' def test_prevent_invalid_config(hatch, config_file, helpers): diff --git a/tests/cli/config/test_show.py b/tests/cli/config/test_show.py index 4a875687b..a5edef0d4 100644 --- a/tests/cli/config/test_show.py +++ b/tests/cli/config/test_show.py @@ -1,6 +1,6 @@ def test_default_scrubbed(hatch, config_file, helpers, default_cache_dir, default_data_dir): config_file.model.project = 'foo' - config_file.model.publish['pypi']['auth'] = 'bar' + config_file.model.publish['index']['auth'] = 'bar' config_file.save() result = hatch('config', 'show') @@ -54,7 +54,7 @@ def test_default_scrubbed(hatch, config_file, helpers, default_cache_dir, defaul def test_reveal(hatch, config_file, helpers, default_cache_dir, default_data_dir): config_file.model.project = 'foo' - config_file.model.publish['pypi']['auth'] = 'bar' + config_file.model.publish['index']['auth'] = 'bar' config_file.save() result = hatch('config', 'show', '-a') @@ -79,7 +79,7 @@ def test_reveal(hatch, config_file, helpers, default_cache_dir, default_data_dir [projects] - [publish.pypi] + [publish.index] user = "" auth = "bar" diff --git a/tests/cli/publish/test_publish.py b/tests/cli/publish/test_publish.py index 81084f2ed..89011d297 100644 --- a/tests/cli/publish/test_publish.py +++ b/tests/cli/publish/test_publish.py @@ -110,7 +110,7 @@ def test_explicit_options(hatch, temp_dir): assert result.exit_code == 1, result.output assert result.output == ( - 'Use the standard CLI flags rather than passing explicit options when using the `pypi` plugin\n' + 'Use the standard CLI flags rather than passing explicit options when using the `index` plugin\n' ) @@ -131,7 +131,7 @@ def test_unknown_publisher(hatch, temp_dir): def test_disabled(hatch, temp_dir, config_file): - config_file.model.publish['pypi']['disable'] = True + config_file.model.publish['index']['disable'] = True config_file.save() project_name = 'My App' @@ -146,7 +146,7 @@ def test_disabled(hatch, temp_dir, config_file): result = hatch('publish', '-n') assert result.exit_code == 1, result.output - assert result.output == 'Publisher is disabled: pypi\n' + assert result.output == 'Publisher is disabled: index\n' def test_missing_user(hatch, temp_dir): @@ -216,9 +216,9 @@ def test_flags(hatch, temp_dir_cache, helpers, published_project_name): def test_plugin_config(hatch, temp_dir_cache, helpers, published_project_name, config_file): - config_file.model.publish['pypi']['user'] = '__token__' - config_file.model.publish['pypi']['auth'] = PUBLISHER_TOKEN - config_file.model.publish['pypi']['repo'] = 'test' + config_file.model.publish['index']['user'] = '__token__' + config_file.model.publish['index']['auth'] = PUBLISHER_TOKEN + config_file.model.publish['index']['repo'] = 'test' config_file.save() with temp_dir_cache.as_cwd(): @@ -426,10 +426,10 @@ def test_no_artifacts(hatch, temp_dir_cache, helpers, published_project_name): def test_enable_with_flag(hatch, temp_dir_cache, helpers, published_project_name, config_file): - config_file.model.publish['pypi']['user'] = '__token__' - config_file.model.publish['pypi']['auth'] = PUBLISHER_TOKEN - config_file.model.publish['pypi']['repo'] = 'test' - config_file.model.publish['pypi']['disable'] = True + config_file.model.publish['index']['user'] = '__token__' + config_file.model.publish['index']['auth'] = PUBLISHER_TOKEN + config_file.model.publish['index']['repo'] = 'test' + config_file.model.publish['index']['disable'] = True config_file.save() with temp_dir_cache.as_cwd(): @@ -466,10 +466,10 @@ def test_enable_with_flag(hatch, temp_dir_cache, helpers, published_project_name def test_enable_with_prompt(hatch, temp_dir_cache, helpers, published_project_name, config_file): - config_file.model.publish['pypi']['user'] = '__token__' - config_file.model.publish['pypi']['auth'] = PUBLISHER_TOKEN - config_file.model.publish['pypi']['repo'] = 'test' - config_file.model.publish['pypi']['disable'] = True + config_file.model.publish['index']['user'] = '__token__' + config_file.model.publish['index']['auth'] = PUBLISHER_TOKEN + config_file.model.publish['index']['repo'] = 'test' + config_file.model.publish['index']['disable'] = True config_file.save() with temp_dir_cache.as_cwd(): @@ -496,7 +496,7 @@ def test_enable_with_prompt(hatch, temp_dir_cache, helpers, published_project_na assert result.exit_code == 0, result.output assert result.output == helpers.dedent( f""" - Confirm `pypi` publishing [y/N]: y + Confirm `index` publishing [y/N]: y {artifacts[0].relative_to(path)} ... success {artifacts[1].relative_to(path)} ... success diff --git a/tests/config/test_model.py b/tests/config/test_model.py index 6ba877fab..778724de6 100644 --- a/tests/config/test_model.py +++ b/tests/config/test_model.py @@ -21,7 +21,7 @@ def test_default(default_cache_dir, default_data_dir): 'cache': str(default_cache_dir), }, 'projects': {}, - 'publish': {'pypi': {'user': '', 'auth': ''}}, + 'publish': {'index': {'user': '', 'auth': ''}}, 'template': { 'name': 'Foo Bar', 'email': 'foo@bar.baz', @@ -722,8 +722,8 @@ class TestPublish: def test_default(self): config = RootConfig({}) - assert config.publish == config.publish == {'pypi': {'user': '', 'auth': ''}} - assert config.raw_data == {'publish': {'pypi': {'user': '', 'auth': ''}}} + assert config.publish == config.publish == {'index': {'user': '', 'auth': ''}} + assert config.raw_data == {'publish': {'index': {'user': '', 'auth': ''}}} def test_defined(self): config = RootConfig({'publish': {'foo': {'username': '', 'password': ''}}})