{"id":21455430,"url":"https://github.com/bmwant/extras","last_synced_at":"2025-03-17T03:24:25.367Z","repository":{"id":67578284,"uuid":"538153644","full_name":"bmwant/extras","owner":"bmwant","description":"Dummy package to make Python packages extras deprecation easier","archived":false,"fork":false,"pushed_at":"2022-10-31T14:55:19.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-23T13:13:50.301Z","etag":null,"topics":["extas","pip","poetry","poetry-python","pyproject-toml","python","python-package","python-pip","setuptools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmwant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-18T15:30:47.000Z","updated_at":"2022-09-19T11:03:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"9056a3bf-c5e2-4e57-8a4e-69fc81e9eeff","html_url":"https://github.com/bmwant/extras","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmwant%2Fextras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmwant%2Fextras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmwant%2Fextras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmwant%2Fextras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmwant","download_url":"https://codeload.github.com/bmwant/extras/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965987,"owners_count":20375981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extas","pip","poetry","poetry-python","pyproject-toml","python","python-package","python-pip","setuptools"],"created_at":"2024-11-23T05:12:08.036Z","updated_at":"2025-03-17T03:24:25.349Z","avatar_url":"https://github.com/bmwant.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## extras\n\n[![PyPI](https://img.shields.io/pypi/v/package-extras)](https://pypi.org/project/package-extras/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/package-extras)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![EditorConfig](https://img.shields.io/badge/-EditorConfig-grey?logo=editorconfig)](https://editorconfig.org/)\n\nPackage that allows to make assertions about [extras](https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-extras) being installed or not.\n\nFor the detailed explanation read [this blog post](https://bmwlog.pp.ua/deprecation-of-package-extras/).\n\n### Usage\n\nFor the `pyproject.toml` users\n\n```toml\n[tool.poetry.dependencies]\npackage-extras = { version = \"^0.2.0\", optional = true }\n# your actual extras below\npsycopg2 = { version = \"^2.9\", optional = true }\nmysqlclient = { version = \"^1.3\", optional = true }\n\n[tool.poetry.extras]\ndatabases = [\"package-extras\", \"mysqlclient\", \"psycopg2\"]\n```\n\n`setup.py` equivalent\n\n```python\nextras_require = \\\n{'databases': ['package-extras\u003e=0.2.0',\n               'psycopg2\u003e=2.9,\u003c3.0',\n               'mysqlclient\u003e=1.3,\u003c2.0']}\n\nsetup_kwargs = {\n    # ... rest of the arguments\n    'extras_require': extras_require,\n}\nsetup(**setup_kwargs)\n```\n\nAdd this or similar block to your code (likely top-level `__init__.py` file)\n\n```python\nimport warnings\n\ntry:\n    import package_extras\nexcept ModuleNotFoundError:\n    pass\nelse:\n    warnings.warn(\n        \"'test_package[databases]' extra is deprecated \"\n        \"and will be removed in a future release.\",\n        category=DeprecationWarning,\n        stacklevel=2,\n    )\n```\n\nOr in case you want to assert the opposite (make sure that extras have been installed)\n\n```python\nimport warnings\n\ntry:\n    import package_extras\nexcept ModuleNotFoundError:\n    warnings.warn(\n        \"You are going to use functionality that depends on 'databases' extras. \"\n        \"Please install 'test_package[databases]' to proceed.\",\n        category=ImportWarning,\n        stacklevel=2,\n    )\n```\n\n\u003e NOTE: `ImportWarning` is ignored by default, so you either need to run `python -W all` or use `RuntimeWarning` instead.\n\nAfter installation via `pip install test_package[databases]` your package users will get this warning.\n\n```console\n\u003e\u003e\u003e import test_package\nDeprecationWarning: 'test_package[databases]' extra is deprecated and will be removed in a future release.\n```\n\n### Development\n\n```bash\n$ poetry install\n$ poetry build\n\n$ poetry config pypi-token.pypi my-token\n$ poetry publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmwant%2Fextras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmwant%2Fextras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmwant%2Fextras/lists"}