diff --git a/HISTORY.rst b/HISTORY.rst
index 9f9cc5b..568f9d1 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -12,6 +12,7 @@ History
   ``importlib.metadata.version("pip-lock")``
   (`docs <https://docs.python.org/3.8/library/importlib.metadata.html#distribution-versions>`__ /
   `backport <https://pypi.org/project/importlib-metadata/>`__).
+* Fix parsing of package names featuring extras e.g. ``package[extra1,extra2]``.
 
 2.0.0 (2019-02-28)
 ------------------
diff --git a/src/pip_lock.py b/src/pip_lock.py
index 9d93bfa..3c1e7a0 100644
--- a/src/pip_lock.py
+++ b/src/pip_lock.py
@@ -40,8 +40,11 @@ def get_package_versions(lines, ignore_external=False):
         if ignore_external and line.startswith("-e"):
             continue
 
-        name, version_plus = line.split("==", 1)
-        versions[name.lower()] = version_plus.split(" ", 1)[0]
+        full_name, version_and_extras = line.split("==", 1)
+        # Strip extras
+        name = full_name.split("[", 1)[0].lower()
+        version = version_and_extras.split(" ", 1)[0]
+        versions[name] = version
 
     return versions
 

pip-lock does detect dependencies with setup extras
There are requirement mismatches with requirements.txt
    * Package django-storages[boto3] is in requirements.txt but not in virtualenv
diff --git a/tests/test_pip_lock.py b/tests/test_pip_lock.py
index da3f02a..c4a3881 100644
--- a/tests/test_pip_lock.py
+++ b/tests/test_pip_lock.py
@@ -17,7 +17,7 @@ def create_file(tmpdir, name, text):
     return str(t)
 
 
-class TestReadPip(object):
+class TestReadPip:
     def test_read(self, tmpdir):
         path = create_file(tmpdir, "requirements.txt", "package1==1.0\npackage2==1.1")
         assert read_pip(path) == ["package1==1.0", "package2==1.1"]
@@ -33,7 +33,7 @@ class TestReadPip(object):
         assert read_pip(path) == [""]
 
 
-class TestGetPackageVersion(object):
+class TestGetPackageVersion:
     def test_version(self):
         assert get_package_versions(["package1==1.0", "package2==1.1"]) == {
             "package1": "1.0",
@@ -53,7 +53,7 @@ class TestGetPackageVersion(object):
         assert get_package_versions(["https://www.google.com"]) == {}
 
 
-class TestGetMismatches(object):
+class TestGetMismatches:
     def setUp(self, tmpdir):
         super(TestGetMismatches, self).setUp()
         self.requirements_path = create_file(
@@ -115,8 +115,17 @@ class TestGetMismatches(object):
 
         assert get_mismatches(requirements_path) == {}
 
+    @mock.patch("pip_lock.pip_freeze")
+    def test_package_with_extra(self, pip_freeze, tmpdir):
+        pip_freeze.return_value = ["package==1.1"]
+        requirements_path = create_file(
+            tmpdir, "requirements.txt", "package[anextra]==1.1"
+        )
+
+        assert get_mismatches(requirements_path) == {}
+
 
-class TestPrintErrors(object):
+class TestPrintErrors:
     def test_errors(self, capsys):
         print_errors(["error message 1", "error message 2"])
         _, err = capsys.readouterr()
@@ -131,7 +140,7 @@ class TestPrintErrors(object):
         assert "post text" in err
 
 
-class TestCheckRequirements(object):
+class TestCheckRequirements:
     @mock.patch("pip_lock.get_mismatches")
     def test_no_mismatches(self, get_mismatches):
         get_mismatches.return_value = {}

pip install -e .
parse_log_pytest
requirements.txt
pytest multilint twine
3.7
requirements/requirements.in
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==24.2.0
bleach==6.0.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
cryptography==44.0.2
docutils==0.20.1
exceptiongroup==1.2.2
flake8==5.0.4
flake8-bugbear==23.3.12
flake8-comprehensions==3.13.0
flake8-tidy-imports==4.9.0
idna==3.10
importlib-metadata==4.2.0
iniconfig==2.0.0
isort==5.11.5
jaraco.classes==3.2.3
jeepney==0.9.0
keyring==23.9.3
markdown-it-py==2.2.0
mccabe==0.7.0
mdurl==0.1.2
more-itertools==9.1.0
multilint==5.0.1
packaging==24.0
-e git+https://github.com/adamchainz/pip-lock.git@4a0e0106254aeceb13f7ff068ce295424b1d44a2#egg=pip_lock
pkginfo==1.10.0
pluggy==1.2.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.17.2
pytest==7.4.4
pytest-randomly==3.12.0
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.8.1
SecretStorage==3.3.3
six==1.17.0
tomli==2.0.1
twine==4.0.2
typing_extensions==4.7.1
urllib3==2.0.7
webencodings==0.5.1
zipp==3.15.0

name: pip-lock
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==24.2.0
      - bleach==6.0.0
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - cryptography==44.0.2
      - docutils==0.20.1
      - exceptiongroup==1.2.2
      - flake8==5.0.4
      - flake8-bugbear==23.3.12
      - flake8-comprehensions==3.13.0
      - flake8-tidy-imports==4.9.0
      - idna==3.10
      - importlib-metadata==4.2.0
      - iniconfig==2.0.0
      - isort==5.11.5
      - jaraco-classes==3.2.3
      - jeepney==0.9.0
      - keyring==23.9.3
      - markdown-it-py==2.2.0
      - mccabe==0.7.0
      - mdurl==0.1.2
      - more-itertools==9.1.0
      - multilint==5.0.1
      - packaging==24.0
      - pip-lock==2.0.0
      - pkginfo==1.10.0
      - pluggy==1.2.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pytest==7.4.4
      - pytest-randomly==3.12.0
      - readme-renderer==37.3
      - requests==2.31.0
      - requests-toolbelt==1.0.0
      - rfc3986==2.0.0
      - rich==13.8.1
      - secretstorage==3.3.3
      - six==1.17.0
      - tomli==2.0.1
      - twine==4.0.2
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - webencodings==0.5.1
      - zipp==3.15.0
prefix: /opt/conda/envs/pip-lock

tests/test_pip_lock.py::TestGetMismatches::test_package_with_extra
tests/test_pip_lock.py::TestReadPip::test_empty tests/test_pip_lock.py::TestReadPip::test_read tests/test_pip_lock.py::TestReadPip::test_include tests/test_pip_lock.py::TestGetPackageVersion::test_ignore_comments tests/test_pip_lock.py::TestGetPackageVersion::test_ignore_includes tests/test_pip_lock.py::TestGetPackageVersion::test_version tests/test_pip_lock.py::TestGetPackageVersion::test_ignore_urls tests/test_pip_lock.py::TestGetPackageVersion::test_ignore_empty tests/test_pip_lock.py::TestGetMismatches::test_version_mismatch tests/test_pip_lock.py::TestGetMismatches::test_no_mismatches_case_insensitive tests/test_pip_lock.py::TestGetMismatches::test_missing tests/test_pip_lock.py::TestGetMismatches::test_empty tests/test_pip_lock.py::TestGetMismatches::test_relative_requirements_file tests/test_pip_lock.py::TestGetMismatches::test_no_mismatches tests/test_pip_lock.py::TestGetMismatches::test_editable_packages tests/test_pip_lock.py::TestPrintErrors::test_pre_post_text tests/test_pip_lock.py::TestPrintErrors::test_errors tests/test_pip_lock.py::TestCheckRequirements::test_relative_requirements_file tests/test_pip_lock.py::TestCheckRequirements::test_mismatches tests/test_pip_lock.py::TestCheckRequirements::test_no_mismatches
HISTORY.rst src/pip_lock.py
HISTORY.rst src/pip_lock.py