diff --git a/docs/changelog/1042.bugfix.rst b/docs/changelog/1042.bugfix.rst
new file mode 100644
index 00000000..53bde7e2
--- /dev/null
+++ b/docs/changelog/1042.bugfix.rst
@@ -0,0 +1,4 @@
+session packages are now put inside a numbered directory (instead of prefix numbering it,
+because pip fails when wheels are not named according to
+`PEP-491 <https://www.python.org/dev/peps/pep-0491/#id9>`_, and prefix numbering messes with this)
+- by user:`gaborbernat`
diff --git a/src/tox/package.py b/src/tox/package.py
index 29548c65..45c88829 100644
--- a/src/tox/package.py
+++ b/src/tox/package.py
@@ -55,24 +55,30 @@ def create_session_view(package, temp_dir, report):
     """
     if not package:
         return package
-    temp_dir.ensure(dir=True)
+    package_dir = temp_dir.join("package")
+    package_dir.ensure(dir=True)
 
-    # we'll prefix it with a unique number, note adding as suffix can cause conflicts
-    # with tools that check the files extension (e.g. pip)
-    exists = [
-        i.basename[: -len(package.basename) - 1]
-        for i in temp_dir.listdir(fil="*-{}".format(package.basename))
-    ]
+    # we'll number the active instances, and use the max value as session folder for a new build
+    # note we cannot change package names as PEP-491 (wheel binary format)
+    # is strict about file name structure
+    exists = [i.basename for i in package_dir.listdir()]
     file_id = max(chain((0,), (int(i) for i in exists if six.text_type(i).isnumeric())))
-    session_package = temp_dir.join("{}-{}".format(file_id + 1, package.basename))
+
+    session_dir = package_dir.join(str(file_id + 1))
+    session_dir.ensure(dir=True)
+    session_package = session_dir.join(package.basename)
 
     # if we can do hard links do that, otherwise just copy
-    operation = "links"
+    links = False
     if hasattr(os, "link"):
-        os.link(str(package), str(session_package))
-    else:
-        operation = "copied"
+        try:
+            os.link(str(package), str(session_package))
+            links = True
+        except (OSError, NotImplementedError):
+            pass
+    if not links:
         package.copy(session_package)
+    operation = "links" if links else "copied"
     common = session_package.common(package)
     report.verbosity1(
         "package {} {} to {} ({})".format(
diff --git a/src/tox/session.py b/src/tox/session.py
index 4fb7cb8d..f847aff1 100644
--- a/src/tox/session.py
+++ b/src/tox/session.py
@@ -459,6 +459,7 @@ class Session:
                 ):
                     self.report.verbosity2("cleanup {}".format(tox_env.package))
                     tox_env.package.remove()
+                    py.path.local(tox_env.package.dirname).remove(ignore_errors=True)
 
     def _copyfiles(self, srcdir, pathlist, destdir):
         for relpath in pathlist:

Testing with `--installpkg somewheel.whl` broken (Regression in 3.5.0)
Tox 3.5.0 seems to break my Travis tests for Prequ. I have set the Travis configuration so that it runs `python setup.py bdist_wheel` and then runs as `tox -v --installpkg dist/*.whl`.  This worked fine with earlier Tox versions (<=3.4.0).

With Tox 3.5.0 my Travis job started to break with an exception raised from this line:

https://github.com/tox-dev/tox/blob/5f2535f1a697fe4bfbec571407a742615b410e24/src/tox/package.py#L64

The exception was `AttributeError: 'str' object has no attribute 'basename'`.  Full trace back is available in the build log: https://travis-ci.org/suutari/prequ/jobs/438550460

I think the error happens because `acquire_package` returns a bare `str` if `--instalpkg` is used, but otherwise it seems to return a `_path.local.LocalPath` instance. The failing code in `create_session_view` seems to assume (since commit 6538f74fd7) that the `package` is a a rich `Path` object rather than bare string.
diff --git a/tests/unit/test_package.py b/tests/unit/test_package.py
index e4c39a48..46014b5b 100644
--- a/tests/unit/test_package.py
+++ b/tests/unit/test_package.py
@@ -54,13 +54,13 @@ def test_make_sdist_distshare(tmpdir, initproj):
     package, dist = get_package(session)
     assert package.check()
     assert package.ext == ".zip"
-    assert package == config.temp_dir.join(package.basename)
+    assert package == config.temp_dir.join("package", "1", package.basename)
 
-    assert dist == config.distdir.join(package.basename[len("1-") :])
+    assert dist == config.distdir.join(package.basename)
     assert dist.check()
     assert os.stat(str(dist)).st_ino == os.stat(str(package)).st_ino
 
-    sdist_share = config.distshare.join(package.basename[len("1-") :])
+    sdist_share = config.distshare.join(package.basename)
     assert sdist_share.check()
     assert sdist_share.read("rb") == dist.read("rb"), (sdist_share, package)
 
@@ -126,7 +126,7 @@ def test_separate_sdist(cmd, initproj, tmpdir):
     assert msg in result.out, result.out
     operation = "copied" if not hasattr(os, "link") else "links"
     msg = "package {} {} to {}".format(
-        os.sep.join(("pkg123", ".tox", ".tmp", "1-pkg123-0.7.zip")),
+        os.sep.join(("pkg123", ".tox", ".tmp", "package", "1", "pkg123-0.7.zip")),
         operation,
         os.sep.join(("distshare", "pkg123-0.7.zip")),
     )

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock pytest-xdist
3.6
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
coverage==6.2
distlib==0.3.9
execnet==1.9.0
filelock==3.4.1
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
packaging==21.3
platformdirs==2.4.0
pluggy==0.13.1
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
pytest-mock==3.6.1
pytest-xdist==3.0.2
six==1.17.0
toml==0.10.2
tomli==1.2.3
-e git+https://github.com/tox-dev/tox.git@1eccb2042dd96a08e8a2684945c811bf5c32402f#egg=tox
typing_extensions==4.1.1
virtualenv==20.17.1
zipp==3.6.0

name: tox
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=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - 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=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - coverage==6.2
      - distlib==0.3.9
      - execnet==1.9.0
      - filelock==3.4.1
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==0.13.1
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-mock==3.6.1
      - pytest-xdist==3.0.2
      - six==1.17.0
      - toml==0.10.2
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - virtualenv==20.17.1
      - zipp==3.6.0
prefix: /opt/conda/envs/tox

tests/unit/test_package.py::test_make_sdist_distshare tests/unit/test_package.py::test_separate_sdist
tests/unit/test_package.py::test_package_isolated_toml_no_build_system tests/unit/test_package.py::test_package_isolated_toml_no_requires tests/unit/test_package.py::test_package_isolated_toml_no_backend tests/unit/test_package.py::test_package_isolated_toml_bad_requires tests/unit/test_package.py::test_package_isolated_toml_bad_backend
tests/unit/test_package.py::test_make_sdist tests/unit/test_package.py::test_sdistonly tests/unit/test_package.py::test_separate_sdist_no_sdistfile tests/unit/test_package.py::test_sdist_latest tests/unit/test_package.py::test_installpkg tests/unit/test_package.py::test_package_isolated_no_pyproject_toml tests/unit/test_package.py::test_dist_exists_version_change tests/unit/test_package.py::test_tox_parallel_build_safe tests/unit/test_package.py::test_install_via_installpkg
docs/changelog/1042.bugfix.rst src/tox/package.py src/tox/session.py
docs/changelog/1042.bugfix.rst src/tox/package.py src/tox/session.py