Skip to content

Commit

Permalink
Operating system and python version are now required fields in CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <[email protected]>
  • Loading branch information
TG1999 committed Nov 8, 2022
1 parent 41545d6 commit b5f8cfa
Show file tree
Hide file tree
Showing 10 changed files with 497 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ v0.9.3
------

- Add support for recursive requirements.
- Add python 3.11 as a valid python version in choices.
- Operating system and python version are now required fields in CLI.
- Add dot versions (3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 2.7) with
current python version choices for CLI (36, 37, 38, 39, 310, 311, 27).


v0.9.2
Expand Down
5 changes: 1 addition & 4 deletions src/python_inspector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from python_inspector.resolution import get_requirements_from_python_manifest
from python_inspector.utils_pypi import PLATFORMS_BY_OS
from python_inspector.utils_pypi import PYPI_SIMPLE_URL
from python_inspector.utils_pypi import PYTHON_DOT_VERSIONS_BY_VER
from python_inspector.utils_pypi import Environment
from python_inspector.utils_pypi import valid_python_versions


class Resolution(NamedTuple):
Expand Down Expand Up @@ -103,9 +103,6 @@ def resolve_dependencies(
f"Must be one of: {', '.join(PLATFORMS_BY_OS.keys())}"
)

valid_python_versions = list(PYTHON_DOT_VERSIONS_BY_VER.keys())
valid_python_versions.extend([dot_ver for pyver, dot_ver in PYTHON_DOT_VERSIONS_BY_VER.items()])

if not python_version:
raise Exception(f"No python version provided.")
if python_version not in valid_python_versions:
Expand Down
4 changes: 3 additions & 1 deletion src/python_inspector/resolve_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def print_version(ctx, param, value):
"-p",
"--python-version",
"python_version",
type=click.Choice(utils_pypi.PYTHON_VERSIONS),
type=click.Choice(utils_pypi.valid_python_versions),
metavar="PYVER",
show_default=True,
required=True,
help="Python version to use for dependency resolution.",
)
@click.option(
Expand All @@ -82,6 +83,7 @@ def print_version(ctx, param, value):
type=click.Choice(utils_pypi.PLATFORMS_BY_OS),
metavar="OS",
show_default=True,
required=True,
help="OS to use for dependency resolution.",
)
@click.option(
Expand Down
7 changes: 6 additions & 1 deletion src/python_inspector/utils_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
TRACE_ULTRA_DEEP = False

# Supported environments
PYTHON_VERSIONS = "36", "37", "38", "39", "310", "27"
PYTHON_VERSIONS = "36", "37", "38", "39", "310", "311", "27"

PYTHON_DOT_VERSIONS_BY_VER = {
"36": "3.6",
Expand All @@ -107,8 +107,12 @@
"39": "3.9",
"310": "3.10",
"27": "2.7",
"311": "3.11",
}

valid_python_versions = list(PYTHON_DOT_VERSIONS_BY_VER.keys())
valid_python_versions.extend([dot_ver for pyver, dot_ver in PYTHON_DOT_VERSIONS_BY_VER.items()])


def get_python_dot_version(version):
"""
Expand All @@ -123,6 +127,7 @@ def get_python_dot_version(version):
"38": ["cp38", "cp38m", "abi3"],
"39": ["cp39", "cp39m", "abi3"],
"310": ["cp310", "cp310m", "abi3"],
"311": ["cp311", "cp311m", "abi3"],
"27": ["cp27", "cp27m"],
}

Expand Down
34 changes: 17 additions & 17 deletions tests/data/frozen-requirements.txt-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -6013,12 +6013,12 @@
"type": "pypi",
"namespace": null,
"name": "pip",
"version": "22.3",
"version": "22.3.1",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "The PyPA recommended tool for installing Python packages.\npip - The Python Package Installer\n==================================\n\n.. image:: https://img.shields.io/pypi/v/pip.svg\n :target: https://pypi.org/project/pip/\n\n.. image:: https://readthedocs.org/projects/pip/badge/?version=latest\n :target: https://pip.pypa.io/en/latest\n\npip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.\n\nPlease take a look at our documentation for how to install and use pip:\n\n* `Installation`_\n* `Usage`_\n\nWe release updates regularly, with a new version every 3 months. Find more details in our documentation:\n\n* `Release notes`_\n* `Release process`_\n\nIn pip 20.3, we've `made a big improvement to the heart of pip`_; `learn more`_. We want your input, so `sign up for our user experience research studies`_ to help us do it right.\n\n**Note**: pip 21.0, in January 2021, removed Python 2 support, per pip's `Python 2 support policy`_. Please migrate to Python 3.\n\nIf you find bugs, need help, or want to talk to the developers, please use our mailing lists or chat rooms:\n\n* `Issue tracking`_\n* `Discourse channel`_\n* `User IRC`_\n\nIf you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:\n\n* `GitHub page`_\n* `Development documentation`_\n* `Development IRC`_\n\nCode of Conduct\n---------------\n\nEveryone interacting in the pip project's codebases, issue trackers, chat\nrooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.\n\n.. _package installer: https://packaging.python.org/guides/tool-recommendations/\n.. _Python Package Index: https://pypi.org\n.. _Installation: https://pip.pypa.io/en/stable/installation/\n.. _Usage: https://pip.pypa.io/en/stable/\n.. _Release notes: https://pip.pypa.io/en/stable/news.html\n.. _Release process: https://pip.pypa.io/en/latest/development/release-process/\n.. _GitHub page: https://github.com/pypa/pip\n.. _Development documentation: https://pip.pypa.io/en/latest/development\n.. _made a big improvement to the heart of pip: https://pyfound.blogspot.com/2020/11/pip-20-3-new-resolver.html\n.. _learn more: https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020\n.. _sign up for our user experience research studies: https://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html\n.. _Python 2 support policy: https://pip.pypa.io/en/latest/development/release-process/#python-2-support\n.. _Issue tracking: https://github.com/pypa/pip/issues\n.. _Discourse channel: https://discuss.python.org/c/packaging\n.. _User IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa\n.. _Development IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa-dev\n.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md",
"release_date": "2022-10-15T11:41:14",
"release_date": "2022-11-05T15:56:17",
"parties": [
{
"type": "person",
Expand All @@ -6044,11 +6044,11 @@
"Topic :: Software Development :: Build Tools"
],
"homepage_url": "https://pip.pypa.io/",
"download_url": "https://files.pythonhosted.org/packages/47/ef/8b5470b5b94b36231ed9c0bde90caa71c0d4322d4a15f009b2b7f4287fe0/pip-22.3-py3-none-any.whl",
"size": 2051507,
"download_url": "https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc9485731ad018e35b0cb5/pip-22.3.1-py3-none-any.whl",
"size": 2051534,
"sha1": null,
"md5": "6123dc5fc3483ebb12becce7faa4cd28",
"sha256": "1daab4b8d3b97d1d763caeb01a4640a2250a0ea899e257b1e44b9eded91e15ab",
"md5": "74d0d338e0af6ca545d6ce7ef9734d75",
"sha256": "908c78e6bc29b676ede1c4d57981d490cb892eb45cd8c214ab6298125119e077",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/pypa/pip",
Expand All @@ -6068,20 +6068,20 @@
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": "https://pypi.org/pypi/pip/22.3/json",
"api_data_url": "https://pypi.org/pypi/pip/22.3.1/json",
"datasource_id": null,
"purl": "pkg:pypi/[email protected]"
"purl": "pkg:pypi/[email protected].1"
},
{
"type": "pypi",
"namespace": null,
"name": "pip",
"version": "22.3",
"version": "22.3.1",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "The PyPA recommended tool for installing Python packages.\npip - The Python Package Installer\n==================================\n\n.. image:: https://img.shields.io/pypi/v/pip.svg\n :target: https://pypi.org/project/pip/\n\n.. image:: https://readthedocs.org/projects/pip/badge/?version=latest\n :target: https://pip.pypa.io/en/latest\n\npip is the `package installer`_ for Python. You can use pip to install packages from the `Python Package Index`_ and other indexes.\n\nPlease take a look at our documentation for how to install and use pip:\n\n* `Installation`_\n* `Usage`_\n\nWe release updates regularly, with a new version every 3 months. Find more details in our documentation:\n\n* `Release notes`_\n* `Release process`_\n\nIn pip 20.3, we've `made a big improvement to the heart of pip`_; `learn more`_. We want your input, so `sign up for our user experience research studies`_ to help us do it right.\n\n**Note**: pip 21.0, in January 2021, removed Python 2 support, per pip's `Python 2 support policy`_. Please migrate to Python 3.\n\nIf you find bugs, need help, or want to talk to the developers, please use our mailing lists or chat rooms:\n\n* `Issue tracking`_\n* `Discourse channel`_\n* `User IRC`_\n\nIf you want to get involved head over to GitHub to get the source code, look at our development documentation and feel free to jump on the developer mailing lists and chat rooms:\n\n* `GitHub page`_\n* `Development documentation`_\n* `Development IRC`_\n\nCode of Conduct\n---------------\n\nEveryone interacting in the pip project's codebases, issue trackers, chat\nrooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.\n\n.. _package installer: https://packaging.python.org/guides/tool-recommendations/\n.. _Python Package Index: https://pypi.org\n.. _Installation: https://pip.pypa.io/en/stable/installation/\n.. _Usage: https://pip.pypa.io/en/stable/\n.. _Release notes: https://pip.pypa.io/en/stable/news.html\n.. _Release process: https://pip.pypa.io/en/latest/development/release-process/\n.. _GitHub page: https://github.com/pypa/pip\n.. _Development documentation: https://pip.pypa.io/en/latest/development\n.. _made a big improvement to the heart of pip: https://pyfound.blogspot.com/2020/11/pip-20-3-new-resolver.html\n.. _learn more: https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020\n.. _sign up for our user experience research studies: https://pyfound.blogspot.com/2020/03/new-pip-resolver-to-roll-out-this-year.html\n.. _Python 2 support policy: https://pip.pypa.io/en/latest/development/release-process/#python-2-support\n.. _Issue tracking: https://github.com/pypa/pip/issues\n.. _Discourse channel: https://discuss.python.org/c/packaging\n.. _User IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa\n.. _Development IRC: https://kiwiirc.com/nextclient/#ircs://irc.libera.chat:+6697/pypa-dev\n.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md",
"release_date": "2022-10-15T11:41:17",
"release_date": "2022-11-05T15:56:20",
"parties": [
{
"type": "person",
Expand All @@ -6107,11 +6107,11 @@
"Topic :: Software Development :: Build Tools"
],
"homepage_url": "https://pip.pypa.io/",
"download_url": "https://files.pythonhosted.org/packages/f8/08/7f92782ff571c7c7cb6c5eeb8ebbb1f68cb02bdb24e55c5de4dd9ce98bc3/pip-22.3.tar.gz",
"size": 2077961,
"download_url": "https://files.pythonhosted.org/packages/a3/50/c4d2727b99052780aad92c7297465af5fe6eec2dbae490aa9763273ffdc1/pip-22.3.1.tar.gz",
"size": 2078129,
"sha1": null,
"md5": "f0dd02265e7ccd2f8758c840fba64810",
"sha256": "8182aec21dad6c0a49a2a3d121a87cd524b950e0b6092b181625f07ebdde7530",
"md5": "996f58a94fe0b8b82b6795c42bd171ba",
"sha256": "65fd48317359f3af8e593943e6ae1506b66325085ea64b706a998c6e83eeaf38",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/pypa/pip",
Expand All @@ -6131,9 +6131,9 @@
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": "https://pypi.org/pypi/pip/22.3/json",
"api_data_url": "https://pypi.org/pypi/pip/22.3.1/json",
"datasource_id": null,
"purl": "pkg:pypi/[email protected]"
"purl": "pkg:pypi/[email protected].1"
},
{
"type": "pypi",
Expand Down Expand Up @@ -10940,7 +10940,7 @@
{
"key": "pip",
"package_name": "pip",
"installed_version": "22.3",
"installed_version": "22.3.1",
"dependencies": []
}
]
Expand Down
Loading

0 comments on commit b5f8cfa

Please sign in to comment.