Skip to content
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

Fix ci: remove pkg_resource import, bump pre-commit dependencies #46

Merged
merged 2 commits into from
Feb 21, 2024
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-yapf
rev: 'v0.31.0' # Use the sha / tag you want to point at
- repo: https://github.com/google/yapf
rev: 'v0.40.2' # Use the sha / tag you want to point at
hooks:
- id: yapf
args: [-i, -p]
- repo: https://github.com/pycqa/flake8
rev: '4.0.1' # pick a git hash / tag to point to
rev: '7.0.0' # pick a git hash / tag to point to
hooks:
- id: flake8
18 changes: 9 additions & 9 deletions src/appenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def update_lockfile(self, args=None, remaining=None):
cmd("{tmpdir}/bin/python -m pip install -r requirements.txt".format(
tmpdir=tmpdir))

# Hack because we might not have pkg_resources, but the venv should
# Hack because we might not have packaging, but the venv should
tmp_paths = cmd(
"{tmpdir}/bin/python -c"
" 'import sys; print(\"\\n\".join(sys.path))'".format(
Expand All @@ -441,7 +441,7 @@ def update_lockfile(self, args=None, remaining=None):
if not line:
continue
sys.path.append(line)
import pkg_resources
from packaging.requirements import Requirement

extra_specs = []
result = cmd(
Expand All @@ -452,8 +452,8 @@ def update_lockfile(self, args=None, remaining=None):
if line.strip().startswith('-e '):
# We'd like to pick up the original -e statement here.
continue
spec = list(pkg_resources.parse_requirements(line))[0]
pinned_versions[spec.project_name] = spec
spec = Requirement(line)
pinned_versions[spec.name] = spec
requested_versions = {}
with open('requirements.txt') as f:
for line in f.readlines():
Expand All @@ -467,20 +467,20 @@ def update_lockfile(self, args=None, remaining=None):
# filter comments, in particular # appenv-python-preferences
if line.strip().startswith('#'):
continue
spec = list(pkg_resources.parse_requirements(line))[0]
requested_versions[spec.project_name] = spec
spec = Requirement(line)
requested_versions[spec.name] = spec

final_versions = {}
for spec in requested_versions.values():
# Pick versions with URLs to ensure we don't get the screwed up
# results from pip freeze.
if spec.url:
final_versions[spec.project_name] = spec
final_versions[spec.name] = spec
for spec in pinned_versions.values():
# Ignore versions we already picked
if spec.project_name in final_versions:
if spec.name in final_versions:
continue
final_versions[spec.project_name] = spec
final_versions[spec.name] = spec
lines = [str(spec) for spec in final_versions.values()]
lines.extend(extra_specs)
lines.sort()
Expand Down
Loading