Skip to content

Add support for Python 3.13; drop support for Python 3.8 #1057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 15, 2024

Conversation

chrisrink10
Copy link
Member

@chrisrink10 chrisrink10 commented Sep 18, 2024

Fixes #1056

I ran pyupgrade --py39-plus on the entire source tree to convert from typing.{List,Set,...} to the generic forms of the builtins (among other available upgrades).

Upgrading to 3.13 also surfaced #1088 which I filed to address separately since this PR is already quite large.

@chrisrink10 chrisrink10 added the blocked PR or issue cannot be completed due to some issue label Sep 18, 2024
@chrisrink10 chrisrink10 force-pushed the feature/support-python-313 branch 3 times, most recently from 99c4f02 to 3d07534 Compare September 22, 2024 17:49
@chrisrink10 chrisrink10 force-pushed the feature/support-python-313 branch from 3d07534 to 8aa90ec Compare October 10, 2024 17:48
@chrisrink10 chrisrink10 marked this pull request as ready for review October 10, 2024 17:48
@chrisrink10 chrisrink10 removed the blocked PR or issue cannot be completed due to some issue label Oct 10, 2024
@ikappaki
Copy link
Contributor

ikappaki commented Oct 10, 2024

Hi @chrisrink10, apologies for the intrusion, MS-Windows failure below is due to python/cpython#125283 change in os.path.isabs behavior, in case you were wondering:

_________________________________ reader-test _________________________________
ERROR in (reader-test) (test_io.lpy:86)

Traceback (most recent call last):
  File "D:\a\basilisp\basilisp\tests\basilisp\test_io.lpy", line 86, in reader_test
    (is (= "hi there" (slurp (str "file:///" filename))))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\core.lpy", line 7149, in slurp
    (with-open [reader (apply basilisp.io/reader f opts)]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\core.lpy", line 207, in apply
    (basilisp.lang.runtime/apply f args)))
                           ^^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\lang\runtime.py", line 1311, in apply
    return f(*final)
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\io.lpy", line 291, in reader
    (defn reader
    ...<28 lines>...
           (make-reader f)))
  File "C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\functools.py", line 929, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\io.lpy", line 210, in __make_reader_str_5880
    (try
    ^^^^
    ...<2 lines>...
        (make-reader (pathlib/Path f) opts))))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\functools.py", line 929, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\io.lpy", line 249, in __make_reader_ParseResult_5860
    (-> (as-path f)
        (make-reader opts))
  File "C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\functools.py", line 929, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\io.lpy", line 233, in __make_reader_Path_5906
      (apply-kw python/open f opts))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<55 lines>...
                {:url f :opts opts}))))
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\core.lpy", line 828, in apply_kw
    (basilisp.lang.runtime/apply-kw f args))
                           ^^^^^^^^^^^^^^^^^
  File "D:\a\basilisp\basilisp\.tox\py313\Lib\site-packages\basilisp\lang\runtime.py", line 1336, in apply_kw
    return f(*final, **kwargs)
OSError: [Errno 22] Invalid argument: '\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpc1675mnk'

@ikappaki
Copy link
Contributor

Something along the following fixes the break

diff --git a/src/basilisp/io.lpy b/src/basilisp/io.lpy
index a07e861..9dca382 100644
--- a/src/basilisp/io.lpy
+++ b/src/basilisp/io.lpy
@@ -34,7 +34,7 @@
       (let [path (.-path f)]
         ;; On MS-Windows, extracting an absolute path from the URL
         ;; incorrectly adds a leading `/', .e.g. /C:\xyz.
-        (pathlib/Path #?(:windows (if (os.path/isabs path) (subs path 1) path)
+        (pathlib/Path #?(:windows (if (str/starts-with? path "/") (subs path 1) path)
                          :default path)))
       (throw
        (ex-info "Cannot coerce non-File URL to pathlib.Path"

@chrisrink10
Copy link
Member Author

@ikappaki thanks! I pushed that and will see how it goes.

@chrisrink10 chrisrink10 force-pushed the feature/support-python-313 branch from da93abd to 6fb0268 Compare October 14, 2024 20:39
@chrisrink10 chrisrink10 changed the title Add support for Python 3.13 Add support for Python 3.13; drop support for Python 3.8 Oct 14, 2024
@@ -188,7 +188,7 @@ jobs:
tox run-parallel -p 2

report-coverage:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -412,7 +404,7 @@ def exec_module(self, module: types.ModuleType) -> None:
else:
try:
self._exec_cached_module(fullname, spec.loader_state, path_stats, ns)
except (EOFError, ImportError, IOError, OSError) as e:
except (EOFError, ImportError, OSError) as e:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisrink10 chrisrink10 merged commit 8d34366 into main Oct 15, 2024
12 checks passed
@chrisrink10 chrisrink10 deleted the feature/support-python-313 branch October 15, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Python 3.13
2 participants