From caa9cdf5d03d7ab04b971494f0cde2ebc8b1b297 Mon Sep 17 00:00:00 2001
From: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Date: Thu, 25 Nov 2021 23:29:03 +0000
Subject: [PATCH] Rename src_py3 to src (#965)

---
 .flake8                                       |  2 +-
 .github/workflows/ci.yml                      |  4 +-
 .github/workflows/package.yml                 | 71 +++++++++++++++++++
 CONTRIBUTING.md                               |  4 +-
 typing_extensions/MANIFEST.in                 |  4 +-
 typing_extensions/pyproject.toml              |  4 --
 .../test_typing_extensions.py                 |  0
 .../{src_py3 => src}/typing_extensions.py     |  0
 typing_extensions/tox.ini                     |  2 +-
 9 files changed, 79 insertions(+), 12 deletions(-)
 create mode 100644 .github/workflows/package.yml
 rename typing_extensions/{src_py3 => src}/test_typing_extensions.py (100%)
 rename typing_extensions/{src_py3 => src}/typing_extensions.py (100%)

diff --git a/.flake8 b/.flake8
index be291da98..53cf55a09 100644
--- a/.flake8
+++ b/.flake8
@@ -12,4 +12,4 @@ ignore =
 exclude =
   # tests have more relaxed formatting rules
   # and its own specific config in .flake8-tests
-  typing_extensions/src_py3/test_typing_extensions.py,
+  typing_extensions/src/test_typing_extensions.py,
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 758b3162d..80b40924f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -30,7 +30,7 @@ jobs:
         run: |
           # Be wary of running `pip install` here, since it becomes easy for us to
           # accidentally pick up typing_extensions as installed by a dependency 
-          cd typing_extensions/src_py3
+          cd typing_extensions/src
           python -m unittest test_typing_extensions.py
 
   linting:
@@ -63,4 +63,4 @@ jobs:
         run: flake8
 
       - name: Lint tests
-        run: flake8 --config=.flake8-tests typing_extensions/src_py3/test_typing_extensions.py
+        run: flake8 --config=.flake8-tests typing_extensions/src/test_typing_extensions.py
diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml
new file mode 100644
index 000000000..25f958684
--- /dev/null
+++ b/.github/workflows/package.yml
@@ -0,0 +1,71 @@
+name: Test packaging
+
+on:
+  push:
+  pull_request:
+
+permissions:
+  contents: read
+
+jobs:
+  wheel:
+    name: Test wheel install
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3
+
+      - name: Install pypa/build
+        run: |
+          # Be wary of running `pip install` here, since it becomes easy for us to
+          # accidentally pick up typing_extensions as installed by a dependency 
+          python -m pip install --upgrade build
+          python -m pip list
+
+      - name: Build and install wheel
+        run: |
+          cd typing_extensions
+          python -m build .
+          export path_to_file=$(find dist -type f -name "typing_extensions-*.whl")
+          echo "::notice::Installing wheel: $path_to_file"
+          pip install -vvv $path_to_file
+          python -m pip list
+
+      - name: Attempt to import typing_extensions
+        run: python -c "import typing_extensions; print(typing_extensions.__all__)"
+
+  sdist:
+    name: Test sdist install
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3
+
+      - name: Install pypa/build
+        run: |
+          # Be wary of running `pip install` here, since it becomes easy for us to
+          # accidentally pick up typing_extensions as installed by a dependency 
+          python -m pip install --upgrade build
+          python -m pip list
+
+      - name: Build and install sdist
+        run: |
+          cd typing_extensions
+          python -m build .
+          export path_to_file=$(find dist -type f -name "typing_extensions-*.tar.gz")
+          echo "::notice::Installing sdist: $path_to_file"
+          pip install -vvv $path_to_file
+          python -m pip list
+
+      - name: Attempt to import typing_extensions
+        run: python -c "import typing_extensions; print(typing_extensions.__all__)"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 895ab8d91..f76b51df8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -34,10 +34,10 @@ backwards-incompatible changes.
 
 - Build the source and wheel distributions:
 
-  - `pip3 install -U flit`
+  - `python -m pip install --upgrade build`
   - `cd typing_extensions`
   - `rm -rf dist/`
-  - `flit build --no-setup-py`
+  - `python -m build .`
 
 - Install the built distributions locally and test (if you were using `tox`, you already
   tested the source distribution).
diff --git a/typing_extensions/MANIFEST.in b/typing_extensions/MANIFEST.in
index c399b170d..e3e1b70c1 100644
--- a/typing_extensions/MANIFEST.in
+++ b/typing_extensions/MANIFEST.in
@@ -1,3 +1,3 @@
 include CHANGELOG LICENSE README.rst
-include src_py3/typing_extensions.py
-include src_py3/test_typing_extensions.py
+include src/typing_extensions.py
+include src/test_typing_extensions.py
diff --git a/typing_extensions/pyproject.toml b/typing_extensions/pyproject.toml
index bf594d142..da3ebee88 100644
--- a/typing_extensions/pyproject.toml
+++ b/typing_extensions/pyproject.toml
@@ -61,7 +61,3 @@ classifiers = [
 [[project.authors]]
 name = "Guido van Rossum, Jukka Lehtosalo, Ɓukasz Langa, Michael Lee"
 email = "levkivskyi@gmail.com"
-
-# This tells Flit that the module is stored in the src_py3 directory.
-[tool.flit.module]
-name = "src_py3/typing_extensions"
diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src/test_typing_extensions.py
similarity index 100%
rename from typing_extensions/src_py3/test_typing_extensions.py
rename to typing_extensions/src/test_typing_extensions.py
diff --git a/typing_extensions/src_py3/typing_extensions.py b/typing_extensions/src/typing_extensions.py
similarity index 100%
rename from typing_extensions/src_py3/typing_extensions.py
rename to typing_extensions/src/typing_extensions.py
diff --git a/typing_extensions/tox.ini b/typing_extensions/tox.ini
index 892280f98..0c5959b2b 100644
--- a/typing_extensions/tox.ini
+++ b/typing_extensions/tox.ini
@@ -2,5 +2,5 @@
 envlist = py36, py37, py38, py39
 
 [testenv]
-changedir = src_py3
+changedir = src
 commands = python -m unittest discover