bpo-35081: Add pycore_ prefix to internal header files (GH-10263)

* Rename Include/internal/ header files:

  * pyatomic.h -> pycore_atomic.h
  * ceval.h -> pycore_ceval.h
  * condvar.h -> pycore_condvar.h
  * context.h -> pycore_context.h
  * pygetopt.h -> pycore_getopt.h
  * gil.h -> pycore_gil.h
  * hamt.h -> pycore_hamt.h
  * hash.h -> pycore_hash.h
  * mem.h -> pycore_mem.h
  * pystate.h -> pycore_state.h
  * warnings.h -> pycore_warnings.h

* PCbuild project, Makefile.pre.in, Modules/Setup: add the
  Include/internal/ directory to the search paths of header files.
* Update includes. For example, replace #include "internal/mem.h"
  with #include "pycore_mem.h".
diff --git a/Include/internal/pyatomic.h b/Include/internal/pycore_atomic.h
similarity index 100%
rename from Include/internal/pyatomic.h
rename to Include/internal/pycore_atomic.h
diff --git a/Include/internal/ceval.h b/Include/internal/pycore_ceval.h
similarity index 95%
rename from Include/internal/ceval.h
rename to Include/internal/pycore_ceval.h
index 4297b5a..ddeeb5c 100644
--- a/Include/internal/ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-#include "internal/pyatomic.h"
+#include "pycore_atomic.h"
 #include "pythread.h"
 
 struct _pending_calls {
@@ -25,7 +25,7 @@
     int last;
 };
 
-#include "internal/gil.h"
+#include "pycore_gil.h"
 
 struct _ceval_runtime_state {
     int recursion_limit;
diff --git a/Include/internal/condvar.h b/Include/internal/pycore_condvar.h
similarity index 100%
rename from Include/internal/condvar.h
rename to Include/internal/pycore_condvar.h
diff --git a/Include/internal/context.h b/Include/internal/pycore_context.h
similarity index 95%
rename from Include/internal/context.h
rename to Include/internal/pycore_context.h
index 59f88f2..57a410c 100644
--- a/Include/internal/context.h
+++ b/Include/internal/pycore_context.h
@@ -2,7 +2,7 @@
 #define Py_INTERNAL_CONTEXT_H
 
 
-#include "internal/hamt.h"
+#include "pycore_hamt.h"
 
 
 struct _pycontextobject {
diff --git a/Include/internal/pygetopt.h b/Include/internal/pycore_getopt.h
similarity index 100%
rename from Include/internal/pygetopt.h
rename to Include/internal/pycore_getopt.h
diff --git a/Include/internal/gil.h b/Include/internal/pycore_gil.h
similarity index 95%
rename from Include/internal/gil.h
rename to Include/internal/pycore_gil.h
index 7743b3f..5059850 100644
--- a/Include/internal/gil.h
+++ b/Include/internal/pycore_gil.h
@@ -4,8 +4,8 @@
 extern "C" {
 #endif
 
-#include "internal/condvar.h"
-#include "internal/pyatomic.h"
+#include "pycore_condvar.h"
+#include "pycore_atomic.h"
 
 #ifndef Py_HAVE_CONDVAR
 #  error You need either a POSIX-compatible or a Windows system!
diff --git a/Include/internal/hamt.h b/Include/internal/pycore_hamt.h
similarity index 100%
rename from Include/internal/hamt.h
rename to Include/internal/pycore_hamt.h
diff --git a/Include/internal/hash.h b/Include/internal/pycore_hash.h
similarity index 100%
rename from Include/internal/hash.h
rename to Include/internal/pycore_hash.h
diff --git a/Include/internal/mem.h b/Include/internal/pycore_mem.h
similarity index 100%
rename from Include/internal/mem.h
rename to Include/internal/pycore_mem.h
diff --git a/Include/internal/pystate.h b/Include/internal/pycore_state.h
similarity index 98%
rename from Include/internal/pystate.h
rename to Include/internal/pycore_state.h
index 38845d3..ff25d2e 100644
--- a/Include/internal/pystate.h
+++ b/Include/internal/pycore_state.h
@@ -7,9 +7,9 @@
 #include "pystate.h"
 #include "pythread.h"
 
-#include "internal/mem.h"
-#include "internal/ceval.h"
-#include "internal/warnings.h"
+#include "pycore_mem.h"
+#include "pycore_ceval.h"
+#include "pycore_warnings.h"
 
 
 /* GIL state */
diff --git a/Include/internal/warnings.h b/Include/internal/pycore_warnings.h
similarity index 100%
rename from Include/internal/warnings.h
rename to Include/internal/pycore_warnings.h
diff --git a/Include/pystate.h b/Include/pystate.h
index 8860f12..7fc921e 100644
--- a/Include/pystate.h
+++ b/Include/pystate.h
@@ -250,7 +250,7 @@
 #endif
 #ifdef Py_BUILD_CORE
    /* Macro which should only be used for performance critical code.
-      Need "#include "internal/pystate.h". See also _PyInterpreterState_Get()
+      Need "#include "pycore_state.h". See also _PyInterpreterState_Get()
       and _PyGILState_GetInterpreterStateUnsafe(). */
 #  define _PyInterpreterState_GET_UNSAFE() (PyThreadState_GET()->interp)
 #endif
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 232025f..0336290 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -91,7 +91,7 @@
 # command line to append to these values without stomping the pre-set
 # values.
 PY_CFLAGS=	$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
-PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST)
+PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST) -I$(srcdir)/Include/internal
 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
 # be able to build extension modules using the directories specified in the
 # environment variables
@@ -1025,14 +1025,14 @@
 		pyconfig.h \
 		$(PARSER_HEADERS) \
 		$(srcdir)/Include/Python-ast.h \
-		$(srcdir)/Include/internal/ceval.h \
-		$(srcdir)/Include/internal/gil.h \
-		$(srcdir)/Include/internal/mem.h \
-		$(srcdir)/Include/internal/pyatomic.h \
-		$(srcdir)/Include/internal/pygetopt.h \
-		$(srcdir)/Include/internal/pystate.h \
-		$(srcdir)/Include/internal/context.h \
-		$(srcdir)/Include/internal/warnings.h \
+		$(srcdir)/Include/internal/pycore_atomic.h \
+		$(srcdir)/Include/internal/pycore_ceval.h \
+		$(srcdir)/Include/internal/pycore_context.h \
+		$(srcdir)/Include/internal/pycore_getopt.h \
+		$(srcdir)/Include/internal/pycore_gil.h \
+		$(srcdir)/Include/internal/pycore_mem.h \
+		$(srcdir)/Include/internal/pycore_state.h \
+		$(srcdir)/Include/internal/pycore_warnings.h \
 		$(DTRACE_HEADERS)
 
 $(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
diff --git a/Modules/Setup b/Modules/Setup
index fb16698..c180463 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -101,29 +101,29 @@
 # This only contains the minimal set of modules required to run the
 # setup.py script in the root of the Python source tree.
 
-posix -DPy_BUILD_CORE posixmodule.c	# posix (UNIX) system calls
+posix -DPy_BUILD_CORE -I$(srcdir)/Include/internal posixmodule.c # posix (UNIX) system calls
 errno errnomodule.c			# posix (UNIX) errno values
 pwd pwdmodule.c				# this is needed to find out the user's home dir
 					# if $HOME is not set
 _sre _sre.c				# Fredrik Lundh's new regular expressions
 _codecs _codecsmodule.c			# access to the builtin codecs and codec registry
 _weakref _weakref.c			# weak references
-_functools -DPy_BUILD_CORE _functoolsmodule.c   # Tools for working with functions and callable objects
+_functools -DPy_BUILD_CORE -I$(srcdir)/Include/internal _functoolsmodule.c   # Tools for working with functions and callable objects
 _operator _operator.c	        	# operator.add() and similar goodies
 _collections _collectionsmodule.c	# Container types
 _abc _abc.c				# Abstract base classes
 itertools itertoolsmodule.c		# Functions creating iterators for efficient looping
 atexit atexitmodule.c			# Register functions to be run at interpreter-shutdown
-_signal -DPy_BUILD_CORE signalmodule.c
+_signal -DPy_BUILD_CORE -I$(srcdir)/Include/internal signalmodule.c
 _stat _stat.c				# stat.h interface
-time -DPy_BUILD_CORE timemodule.c	# -lm # time operations and variables
-_thread -DPy_BUILD_CORE _threadmodule.c	# low-level threading interface
+time -DPy_BUILD_CORE -I$(srcdir)/Include/internal timemodule.c	# -lm # time operations and variables
+_thread -DPy_BUILD_CORE -I$(srcdir)/Include/internal _threadmodule.c	# low-level threading interface
 
 # access to ISO C locale support
 _locale _localemodule.c  # -lintl
 
 # Standard I/O baseline
-_io -DPy_BUILD_CORE -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
+_io -DPy_BUILD_CORE -I$(srcdir)/Include/internal -I$(srcdir)/Modules/_io _io/_iomodule.c _io/iobase.c _io/fileio.c _io/bytesio.c _io/bufferedio.c _io/textio.c _io/stringio.c
 
 # faulthandler module
 faulthandler faulthandler.c
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index ff4172d..6c28b27 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1,7 +1,7 @@
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 /* _functools module written and maintained
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 2eb5262..24ae963 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -9,7 +9,7 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h"
 #include "pythread.h"
 #include "_iomodule.h"
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index d33fa99..ad65188 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -3,7 +3,7 @@
 /* Interface to Sjoerd's portable C thread library */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h" /* offsetof */
 #include "pythread.h"
 
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index 2eb8787..fb0b83a 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -4,7 +4,7 @@
 
 #include "Python.h"
 #include "frameobject.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 
 static char *
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 4773c79..a54be07 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -24,9 +24,9 @@
 */
 
 #include "Python.h"
-#include "internal/context.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_context.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "frameobject.h"        /* for PyFrame_ClearFreeList */
 #include "pydtrace.h"
 #include "pytime.h"             /* for _PyTime_GetMonotonicClock() */
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 521bc6e..53e5c2b 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -1,7 +1,7 @@
 /* Return the initial module search path. */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "osdefs.h"
 
 #include <sys/types.h>
diff --git a/Modules/main.c b/Modules/main.c
index 6a8aa05..1918f4f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -2,9 +2,9 @@
 
 #include "Python.h"
 #include "osdefs.h"
-#include "internal/mem.h"
-#include "internal/pygetopt.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_getopt.h"
+#include "pycore_state.h"
 
 #include <locale.h>
 
diff --git a/Modules/makesetup b/Modules/makesetup
index c7b0a60..bf5ca39 100755
--- a/Modules/makesetup
+++ b/Modules/makesetup
@@ -110,7 +110,7 @@
 	rulesf="@rules.$$"
 	trap 'rm -f $rulesf' 0 1 2 3
 	echo "
-# Rules appended by makedepend
+# Rules appended by makesetup
 " >$rulesf
 	DEFS=
 	BUILT=
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 9ccdc8e..0307436 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -32,7 +32,7 @@
 #else
 #include "winreparse.h"
 #endif
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 /* On android API level 21, 'AT_EACCESS' is not declared although
  * HAVE_FACCESSAT is defined. */
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index a81de6a..1915fd9 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -4,7 +4,7 @@
 /* XXX Signals should be recorded per thread, now we have thread state. */
 
 #include "Python.h"
-#include "internal/pyatomic.h"
+#include "pycore_atomic.h"
 
 #ifndef MS_WINDOWS
 #include "posixmodule.h"
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 305910c..be4758d 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1,7 +1,7 @@
 /* Abstract Object Interface (many thanks to Jim Fulton) */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include <ctype.h>
 #include "structmember.h" /* we need the offsetof() macro from there */
 #include "longintrepr.h"
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 782e275..7a0c340 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2,8 +2,8 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 #include "bytes_methods.h"
 #include "bytesobject.h"
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 1b36661..c912fc0 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3,8 +3,8 @@
 #define PY_SSIZE_T_CLEAN
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 
 #include "bytes_methods.h"
 #include "pystrhex.h"
diff --git a/Objects/call.c b/Objects/call.c
index bda0573..9061d0b 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "frameobject.h"
 
 
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 7b05e61..0b390c7 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -1,8 +1,8 @@
 /* Cell object implementation */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 
 PyObject *
 PyCell_New(PyObject *obj)
diff --git a/Objects/classobject.c b/Objects/classobject.c
index c4efaf2..93d1c67 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -1,8 +1,8 @@
 /* Class object implementation (dead now except for methods) */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 #define TP_DESCR_GET(t) ((t)->tp_descr_get)
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index cedf11e..6d8e9ac 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -3,7 +3,7 @@
 #include "Python.h"
 #include "code.h"
 #include "structmember.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 /* Holder for co_extra information */
 typedef struct {
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 82afa8c..a23b97f 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1,7 +1,7 @@
 /* Descriptors -- a new, flexible way to describe attributes */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h" /* Why is this not included in Python.h? */
 
 /*[clinic input]
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 363d902..a9ae907 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -111,7 +111,7 @@
 #define PyDict_MINSIZE 8
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "dict-common.h"
 #include "stringlib/eq.h"    /* to get unicode_eq() */
 
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 6aa3d8f..da79260 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -6,8 +6,8 @@
 
 #define PY_SSIZE_T_CLEAN
 #include <Python.h>
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 #include "osdefs.h"
 
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 64ee386..7704022 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1,7 +1,7 @@
 /* Frame object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #include "code.h"
 #include "frameobject.h"
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index c2f79c0..e5278f0 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -2,8 +2,8 @@
 /* Function object implementation */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "code.h"
 #include "structmember.h"
 
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 453b100..885b3f2 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -1,7 +1,7 @@
 /* Generator object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "frameobject.h"
 #include "structmember.h"
 #include "opcode.h"
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index 5f5ebfc..23f0639 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -1,8 +1,8 @@
 /* Iterator objects */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 
 typedef struct {
     PyObject_HEAD
diff --git a/Objects/listobject.c b/Objects/listobject.c
index e85fa5c..e38b21f 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -1,7 +1,7 @@
 /* List object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "accu.h"
 
 #ifdef STDC_HEADERS
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index adaa67c..f234bb4 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1,8 +1,8 @@
 /* Memoryview object implementation */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "pystrhex.h"
 #include <stddef.h>
 
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 9176e39..b0bbfa2 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -2,8 +2,8 @@
 /* Method object implementation */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 /* Free list for method objects to safe malloc/free overhead
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 5181941..7fb711a 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -2,7 +2,7 @@
 /* Module object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 static Py_ssize_t max_module_number;
diff --git a/Objects/object.c b/Objects/object.c
index b72ad01..f7395c7 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2,8 +2,8 @@
 /* Generic object operations; and implementation of None */
 
 #include "Python.h"
-#include "internal/pystate.h"
-#include "internal/context.h"
+#include "pycore_state.h"
+#include "pycore_context.h"
 #include "frameobject.h"
 
 #ifdef __cplusplus
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 88ded83..6a65a15 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "internal/mem.h"
+#include "pycore_mem.h"
 
 #include <stdbool.h>
 
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 67c3674..81c996b 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -465,7 +465,7 @@
 */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h"
 #include "dict-common.h"
 #include <stddef.h>
diff --git a/Objects/setobject.c b/Objects/setobject.c
index aa1f4ee..42fe80f 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -32,7 +32,7 @@
 */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 /* Object used as dummy key to fill deleted entries */
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 2288df5..9f1cf78 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -14,8 +14,8 @@
 */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "structmember.h"
 
 static PyObject *
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 288f134..cce266f 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -2,7 +2,7 @@
 /* Tuple object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "accu.h"
 
 /*[clinic input]
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 722fe5f..9a390b3 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1,7 +1,7 @@
 /* Type object implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "frameobject.h"
 #include "structmember.h"
 
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index f3f940a..3692da6 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -40,7 +40,7 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "ucnhash.h"
 #include "bytes_methods.h"
 #include "stringlib/eq.h"
diff --git a/PC/getpathp.c b/PC/getpathp.c
index ada0289..3a62738 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -80,7 +80,7 @@
 
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "osdefs.h"
 #include <wchar.h>
 
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index 95b349c..cf85e1b 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -27,7 +27,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)PC;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PydPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
       
       <Optimization>MaxSpeed</Optimization>
@@ -194,4 +194,4 @@
     <Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
     <Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
   </Target>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index f65bb5b..ebc35a7 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -112,15 +112,16 @@
     <ClInclude Include="..\Include\graminit.h" />
     <ClInclude Include="..\Include\grammar.h" />
     <ClInclude Include="..\Include\import.h" />
-    <ClInclude Include="..\Include\internal\ceval.h" />
-    <ClInclude Include="..\Include\internal\condvar.h" />
-    <ClInclude Include="..\Include\internal\context.h" />
-    <ClInclude Include="..\Include\internal\gil.h" />
-    <ClInclude Include="..\Include\internal\hamt.h" />
-    <ClInclude Include="..\Include\internal\mem.h" />
-    <ClInclude Include="..\Include\internal\pyatomic.h" />
-    <ClInclude Include="..\Include\internal\pystate.h" />
-    <ClInclude Include="..\Include\internal\warnings.h" />
+    <ClInclude Include="..\Include\internal\pycore_atomic.h" />
+    <ClInclude Include="..\Include\internal\pycore_ceval.h" />
+    <ClInclude Include="..\Include\internal\pycore_condvar.h" />
+    <ClInclude Include="..\Include\internal\pycore_context.h" />
+    <ClInclude Include="..\Include\internal\pycore_getopt.h" />
+    <ClInclude Include="..\Include\internal\pycore_gil.h" />
+    <ClInclude Include="..\Include\internal\pycore_hamt.h" />
+    <ClInclude Include="..\Include\internal\pycore_mem.h" />
+    <ClInclude Include="..\Include\internal\pycore_state.h" />
+    <ClInclude Include="..\Include\internal\pycore_warnings.h" />
     <ClInclude Include="..\Include\intrcheck.h" />
     <ClInclude Include="..\Include\iterobject.h" />
     <ClInclude Include="..\Include\listobject.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 7fdadc8..052c89c 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -135,31 +135,34 @@
     <ClInclude Include="..\Include\import.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\ceval.h">
+    <ClInclude Include="..\Include\internal\pycore_atomic.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\condvar.h">
+    <ClInclude Include="..\Include\internal\pycore_ceval.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\context.h">
+    <ClInclude Include="..\Include\internal\pycore_condvar.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\gil.h">
+    <ClInclude Include="..\Include\internal\pycore_context.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\hamt.h">
+    <ClInclude Include="..\Include\internal\pycore_getopt.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\mem.h">
+    <ClInclude Include="..\Include\internal\pycore_gil.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\pyatomic.h">
+    <ClInclude Include="..\Include\internal\pycore_hamt.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\pystate.h">
+    <ClInclude Include="..\Include\internal\pycore_mem.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\warnings.h">
+    <ClInclude Include="..\Include\internal\pycore_state.h">
+      <Filter>Include</Filter>
+    </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_warnings.h">
       <Filter>Include</Filter>
     </ClInclude>
     <ClInclude Include="..\Include\intrcheck.h">
@@ -249,9 +252,6 @@
     <ClInclude Include="..\Include\pyfpe.h">
       <Filter>Include</Filter>
     </ClInclude>
-    <ClInclude Include="..\Include\internal\pygetopt.h">
-      <Filter>Include</Filter>
-    </ClInclude>
     <ClInclude Include="..\Include\pylifecycle.h">
       <Filter>Include</Filter>
     </ClInclude>
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index edb291a..d18cf1b 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -10,7 +10,7 @@
 */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #ifdef MS_WINDOWS
 #define WIN32_LEAN_AND_MEAN
 #include "windows.h"
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
index 0a4b0c5..9e2159b 100644
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -16,8 +16,8 @@
 #define PGEN
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "pgenheaders.h"
 #include "grammar.h"
 #include "node.h"
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 8e1c01d..619ec6f 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "frameobject.h"
 #include "clinic/_warnings.c.h"
 
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8001c60..6c8672a 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2,7 +2,7 @@
 
 #include "Python.h"
 #include "Python-ast.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #include "node.h"
 #include "code.h"
diff --git a/Python/ceval.c b/Python/ceval.c
index 6443123..5599b6e 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -10,7 +10,7 @@
 #define PY_LOCAL_AGGRESSIVE
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #include "code.h"
 #include "dictobject.h"
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h
index 4a054a9..f2d5fdb 100644
--- a/Python/ceval_gil.h
+++ b/Python/ceval_gil.h
@@ -5,7 +5,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#include "internal/pyatomic.h"
+#include "pycore_atomic.h"
 
 /* First some general settings */
 
diff --git a/Python/codecs.c b/Python/codecs.c
index 4062429..62bbee6 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -9,7 +9,7 @@
    ------------------------------------------------------------------------ */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "ucnhash.h"
 #include <ctype.h>
 
diff --git a/Python/condvar.h b/Python/condvar.h
index 951b8ad..1351740 100644
--- a/Python/condvar.h
+++ b/Python/condvar.h
@@ -41,7 +41,7 @@
 #define _CONDVAR_IMPL_H_
 
 #include "Python.h"
-#include "internal/condvar.h"
+#include "pycore_condvar.h"
 
 #ifdef _POSIX_THREADS
 /*
diff --git a/Python/context.c b/Python/context.c
index 7344e96..b1f67b5 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -1,9 +1,9 @@
 #include "Python.h"
 
 #include "structmember.h"
-#include "internal/pystate.h"
-#include "internal/context.h"
-#include "internal/hamt.h"
+#include "pycore_state.h"
+#include "pycore_context.h"
+#include "pycore_hamt.h"
 
 
 #define CONTEXT_FREELIST_MAXLEN 255
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index 81086f4..ad14a8a 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1,6 +1,6 @@
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include <locale.h>
 #ifdef HAVE_LANGINFO_H
 #  include <langinfo.h>
diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c
index 73ae26d..9896560 100644
--- a/Python/dynload_shlib.c
+++ b/Python/dynload_shlib.c
@@ -2,7 +2,7 @@
 /* Support for dynamic loading of extension modules */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "importdl.h"
 
 #include <sys/types.h>
diff --git a/Python/errors.c b/Python/errors.c
index 2926ea1..14a70d9 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -2,7 +2,7 @@
 /* Error handling */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #ifndef __STDC__
 #ifndef MS_WINDOWS
diff --git a/Python/frozenmain.c b/Python/frozenmain.c
index 86af2b6..9e90666 100644
--- a/Python/frozenmain.c
+++ b/Python/frozenmain.c
@@ -2,7 +2,7 @@
 /* Python interpreter main program for frozen scripts */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include <locale.h>
 
 #ifdef MS_WINDOWS
diff --git a/Python/getopt.c b/Python/getopt.c
index e8d7e52..c165a94 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -31,7 +31,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <wchar.h>
-#include "internal/pygetopt.h"
+#include "pycore_getopt.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/Python/hamt.c b/Python/hamt.c
index 562f777..be3813b 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -1,8 +1,8 @@
 #include "Python.h"
 
 #include "structmember.h"
-#include "internal/pystate.h"
-#include "internal/hamt.h"
+#include "pycore_state.h"
+#include "pycore_hamt.h"
 
 /*
 This file provides an implemention of an immutable mapping using the
diff --git a/Python/import.c b/Python/import.c
index 338cd30..18cd29d 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -4,9 +4,9 @@
 
 #include "Python-ast.h"
 #undef Yield /* undefine macro conflicting with winbase.h */
-#include "internal/hash.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_hash.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "errcode.h"
 #include "marshal.h"
 #include "code.h"
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index efccb8d..0406415 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -2,8 +2,8 @@
 
 #include "Python.h"
 #include "osdefs.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include <wchar.h>
 
 #ifdef __cplusplus
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index fab96fd..d349aaf 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -4,10 +4,10 @@
 
 #include "Python-ast.h"
 #undef Yield /* undefine macro conflicting with winbase.h */
-#include "internal/context.h"
-#include "internal/hamt.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_context.h"
+#include "pycore_hamt.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "grammar.h"
 #include "node.h"
 #include "token.h"
diff --git a/Python/pystate.c b/Python/pystate.c
index 98e954d..c77902a 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2,8 +2,8 @@
 /* Thread and interpreter state structures and their interfaces */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 
 #define _PyThreadState_SET(value) \
     _Py_atomic_store_relaxed(&_PyRuntime.gilstate.tstate_current, \
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 276c5d1..2f61aab 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -12,7 +12,7 @@
 
 #include "Python-ast.h"
 #undef Yield /* undefine macro conflicting with winbase.h */
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #include "grammar.h"
 #include "node.h"
 #include "token.h"
diff --git a/Python/symtable.c b/Python/symtable.c
index dc934a5..dae6fda 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1,5 +1,5 @@
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 #ifdef Yield
 #undef Yield /* undefine conflicting macro from winbase.h */
 #endif
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 71414c9..cb13e21 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -15,8 +15,8 @@
 */
 
 #include "Python.h"
-#include "internal/mem.h"
-#include "internal/pystate.h"
+#include "pycore_mem.h"
+#include "pycore_state.h"
 #include "code.h"
 #include "frameobject.h"
 #include "pythread.h"
diff --git a/Python/thread.c b/Python/thread.c
index a1e1fa6..6355381 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -6,7 +6,7 @@
    Stuff shared by all thread_*.h files is collected here. */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #ifndef _POSIX_THREADS
 /* This means pthreads are not implemented in libc headers, hence the macro
diff --git a/Python/traceback.c b/Python/traceback.c
index 5b5c715..e2070f0 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -2,7 +2,7 @@
 /* Traceback implementation */
 
 #include "Python.h"
-#include "internal/pystate.h"
+#include "pycore_state.h"
 
 #include "code.h"
 #include "frameobject.h"