diff --git a/CHANGELOG.md b/CHANGELOG.md index c82508140..b79c7be1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Sandboxed processes sticking around after CLI is killed with a signal -- Lockfiles with local versions breaking the `requirements.txt` parser +- Lockfiles with local versions breaking the pip parser ## 6.3.0 - 2024-04-18 diff --git a/lockfile/src/parsers/pypi.rs b/lockfile/src/parsers/pypi.rs index ea88bf755..950bb4796 100644 --- a/lockfile/src/parsers/pypi.rs +++ b/lockfile/src/parsers/pypi.rs @@ -102,7 +102,10 @@ fn package<'a>(input: &'a str, registry: Option<&str>) -> IResult<&'a str, Packa // Parse first-party dependencies. let (input, version) = package_version(input)?; + + // Parse local version specifier. let (input, local_version) = opt(local_version)(input)?; + let version = match (registry, local_version) { (_, Some(_)) => PackageVersion::Unknown, (Some(registry), _) => PackageVersion::ThirdParty(ThirdPartyVersion { diff --git a/tests/fixtures/requirements-locked.txt b/tests/fixtures/requirements-locked.txt index d79f71544..ac347b86c 100644 --- a/tests/fixtures/requirements-locked.txt +++ b/tests/fixtures/requirements-locked.txt @@ -20,7 +20,7 @@ requests[security,tests]==2.28.1 werkzeug==2.9.2 ; python_version >= "3.7" and python_version < "3.12" -localversion==2.3.4+1.0.99 +localversion==2.3.4+1.0.99.local attr @ file:///tmp/attr diff --git a/tests/fixtures/requirements-unlocked.txt b/tests/fixtures/requirements-unlocked.txt index 4f075a6e0..1daaf904a 100644 --- a/tests/fixtures/requirements-unlocked.txt +++ b/tests/fixtures/requirements-unlocked.txt @@ -32,3 +32,4 @@ FooProject8 > 1.8.* FooProject9 > 2.0.*, !=2.1 FooProject10==1.2.3 --random-flag git+https://github.com/matiascodesal/git-for-pip-example.git@v1.0.0#egg=my-git-package +localversion >= 2.3.4+1.0.99.local