Skip to content

Commit 2690c0d

Browse files
committed
[GR-73547] Fix license file lookup for license builtin
PullRequest: graalpython/4276
2 parents 902462b + 1ce7cf0 commit 2690c0d

4 files changed

Lines changed: 24 additions & 16 deletions

File tree

LICENSE.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
Product License - GraalVM Community Edition 23.0 Python Language
2-
Component
3-
4-
This is a release of GraalVM Community Edition 20.0 Python Language Component.
51
This particular copy of the software is released under Universal Permissive
62
License (UPL) v. 1.0.
7-
Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved
3+
Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved
84

95
===========================================================================
106
Universal Permissive License v. 1.0.

graalpython/com.oracle.graal.python.test/src/tests/test_builtin.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# Copyright (c) 2018, 2023, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2026, Oracle and/or its affiliates.
22
# Copyright (C) 1996-2020 Python Software Foundation
33
#
44
# Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
5-
5+
import os
6+
import subprocess
7+
import sys
8+
import tempfile
69
import unittest
710

811
class MyIndexable(object):
@@ -68,7 +71,7 @@ def test_chr(self):
6871
self.assertEqual(chr(97), 'a')
6972
self.assertEqual(chr(0xfff), '\u0fff')
7073
self.assertEqual(chr(0xf0000), '\U000f0000')
71-
74+
7275
def test_ord(self):
7376
self.assertEqual(ord(' '), 32)
7477
self.assertEqual(ord('a'), 97)
@@ -93,19 +96,26 @@ def test_min(self):
9396

9497
def test_sort_keyfunc(self):
9598
lists = [[], [1], [1,2], [1,2,3], [1,3,2], [3,2,1], [9,3,8,1,7,9,3,6,7,8]]
96-
99+
97100
for l in lists:
98101
count = 0
99-
102+
100103
def keyfunc(v):
101104
nonlocal count
102105
count += 1
103106
return v
104-
107+
105108
result = sorted(l, key = keyfunc)
106109
self.assertEqual(len(l), count)
107110
self.assertEqual(sorted(l), result)
108111
count = 0
109112
result = sorted(l, key = keyfunc, reverse = True)
110113
self.assertEqual(len(l), count)
111-
self.assertEqual(sorted(l, reverse = True), result)
114+
self.assertEqual(sorted(l, reverse = True), result)
115+
116+
def test_license(self):
117+
with tempfile.TemporaryDirectory() as tmpdir:
118+
# Test that it can find the license even when ran outside of the distribution
119+
license = subprocess.check_output([sys.executable, "-c", "print(license())"], cwd=tmpdir, text=True, input=("\n" * 100))
120+
if sys.implementation.name == 'graalpy':
121+
self.assertIn('Oracle', license)

graalpython/lib-python/3/site.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,13 @@ def setcopyright():
435435
here = getattr(sys, '_stdlib_dir', None)
436436
if not here and hasattr(os, '__file__'):
437437
here = os.path.dirname(os.__file__)
438-
if here:
439-
files.extend(["LICENSE.txt", "LICENSE"])
440-
dirs.extend([os.path.join(here, os.pardir), here, os.curdir])
438+
# GraalPy change: use graalpy home
439+
files.append("LICENSE.txt")
440+
dirs.append(__graalpython__.home)
441441
builtins.license = _sitebuiltins._Printer(
442442
"license",
443-
"See https://www.python.org/psf/license/",
443+
# GraalPy change
444+
"See the license file in the root of distribution",
444445
files, dirs)
445446

446447

graalpython/lib-python/3/test/test_site.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ def test_sitecustomize_executed(self):
512512
'need SSL support to download license')
513513
@test.support.requires_resource('network')
514514
@test.support.system_must_validate_cert
515+
@test.support.impl_detail("CPython-specific", graalpy=False)
515516
def test_license_exists_at_url(self):
516517
# This test is a bit fragile since it depends on the format of the
517518
# string displayed by license in the absence of a LICENSE file.

0 commit comments

Comments
 (0)