Skip to content

fix: Release 0.8.1; find compatible versions fixes; remove pip vendored imports; #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
architecture: x64
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
pip install -e .[test]
- name: Test with pytest
run: |
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ and this project adheres to a _modified_ form of _[Semantic Versioning][semver]_

### Removed

## [0.8.1]

### Added

### Changed

- Use regular imports for `packaging` and `requests` library instead of pip vendored imports ([#23])

### Fixed

- Fix `find_compatible_versions` sort to use semver sort ([#23])

[#23]: https://github.com/openlawlibrary/upgrade-python-package/pull/23

### Removed

## [0.8.0]

### Added
Expand Down Expand Up @@ -183,7 +199,8 @@ and this project adheres to a _modified_ form of _[Semantic Versioning][semver]_
[#5]: https://github.com/openlawlibrary/upgrade-python-package/pull/5
[#6]: https://github.com/openlawlibrary/upgrade-python-package/pull/6

[Unreleased]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.8.0...HEAD
[Unreleased]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.8.1...HEAD
[0.8.1]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.8.0...0.8.1
[0.8.0]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.7.3...0.8.0
[0.7.3]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.7.2...0.7.3
[0.7.2]: https://github.com/openlawlibrary/upgrade-python-package/compare/0.7.1...0.7.2
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers =
install_requires =
lxml >= 4.9
requests == 2.*
packaging >= 24.1
packages = upgrade.scripts
zip_safe = False
include_package_data = True
Expand All @@ -41,6 +42,7 @@ test =
flake8
pytest
mock
setuptools


[bdist_wheel]
Expand Down
8 changes: 4 additions & 4 deletions upgrade/scripts/find_compatible_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from urllib.parse import urljoin

import lxml.etree as et
import pip._vendor.requests as requests
from pip._vendor.packaging.utils import parse_wheel_filename
from pip._vendor.packaging.version import Version
import requests as requests
from packaging.utils import parse_wheel_filename
from packaging.version import Version

from upgrade.scripts.requirements import (
filter_versions,
Expand Down Expand Up @@ -55,7 +55,7 @@ def get_compatible_upgrade_versions(
)
logging.debug(f"Found compatible versions: {compatible_versions}")

return sorted(compatible_versions, reverse=True)
return sorted(compatible_versions, reverse=True, key=Version)


def get_installed_version(requirements_obj: Any, venv_executable: str) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion upgrade/scripts/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_requirements_obj(requirements: str) -> Any:
we import the vendored version. This way we guarantee
that the packaging APIs are matching pip's behavior exactly.
"""
from pip._vendor.packaging.requirements import Requirement
from packaging.requirements import Requirement

return Requirement(requirements)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions upgrade/scripts/upgrade_python_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from importlib import util
from pathlib import Path

from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.utils import parse_wheel_filename
from packaging.specifiers import SpecifierSet
from packaging.utils import parse_wheel_filename

from upgrade.scripts.exceptions import PipFormatDecodeFailed
from upgrade.scripts.requirements import filter_versions
Expand Down
1 change: 1 addition & 0 deletions upgrade/tests/manage_venv/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _create_venv(path, version, venv_name=None):
venv_path = str(Path(path, venv_name))
run(original_executable, "-m", "venv", venv_path)
venv_executable = get_venv_executable(venv_path)
run(venv_executable, "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel")
run(
venv_executable,
"-m",
Expand Down
2 changes: 1 addition & 1 deletion upgrade/tests/upgrade_package/test_filter_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pip._vendor.packaging.specifiers import SpecifierSet
from packaging.specifiers import SpecifierSet

from upgrade.scripts.requirements import filter_versions

Expand Down