Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ flame-it = ["rustpython-vm/flame-it", "flame", "flamescope"]
freeze-stdlib = ["rustpython-vm/freeze-stdlib"]
jit = ["rustpython-vm/jit"]
threading = ["rustpython-vm/threading"]
pylib = ["rustpython-vm/pylib"]
zlib = ["rustpython-stdlib/zlib"]
ssl = ["rustpython-stdlib/ssl"]
ssl-vendor = ["rustpython-stdlib/ssl-vendor"]
Expand All @@ -34,7 +35,6 @@ rustpython-compiler = { path = "compiler/porcelain", version = "0.1.1" }
rustpython-parser = { path = "parser", version = "0.1.1" }
rustpython-vm = { path = "vm", version = "0.1.1", default-features = false, features = ["compile-parse"] }
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false, features = ["compile-parse"]}
pylib = { package = "rustpython-pylib", path = "vm/pylib-crate", version = "0.1.0", optional = true }
dirs = { package = "dirs-next", version = "2.0.0" }
num-traits = "0.2.8"
cfg-if = "1.0"
Expand Down Expand Up @@ -66,6 +66,10 @@ path = "src/main.rs"
[profile.dev.package."*"]
opt-level = 3

[profile.test]
opt-level = 3

@youknowone youknowone Oct 1, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

doesn't this obfuscate backtrace and debug information?
how do you think about running tests with release build job if this is desired?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should still keep debug info I'm pretty sure - the default for test enables debuginfo and I'm pretty sure it's orthogonal to opt-level: https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When opt-level is not 0, the inlined callstacks are omitted, the progress is not linear to the code and some breakpoint doesn't work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the default development environment is better to be friendly to programmers unless there are unavoidable reasons

lto = "thin"

[profile.bench]
lto = true
codegen-units = 1
Expand Down
5 changes: 5 additions & 0 deletions Lib/distutils/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
'data' : '$userbase',
}

# XXX RUSTPYTHON: replace python with rustpython in all these paths
for group in INSTALL_SCHEMES.values():
for key in group.keys():
group[key] = group[key].replace("Python", "RustPython").replace("python", "rustpython")

# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
# and to SCHEME_KEYS here.
Expand Down
84 changes: 41 additions & 43 deletions Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
import re
import sys
import fnmatch

from .errors import DistutilsPlatformError

Expand All @@ -24,36 +23,47 @@
BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)

# Path to the base directory of the project. On Windows the binary may
# live in project/PCBuild/win32 or project/PCBuild/amd64.
# live in project/PCbuild/win32 or project/PCbuild/amd64.
# set for cross builds
if "_PYTHON_PROJECT_BASE" in os.environ:
project_base = os.path.abspath(os.environ["_PYTHON_PROJECT_BASE"])
else:
project_base = os.path.dirname(os.path.abspath(sys.executable))
if (os.name == 'nt' and
project_base.lower().endswith(('\\pcbuild\\win32', '\\pcbuild\\amd64'))):
project_base = os.path.dirname(os.path.dirname(project_base))
if sys.executable:
project_base = os.path.dirname(os.path.abspath(sys.executable))
else:
# sys.executable can be empty if argv[0] has been changed and Python is
# unable to retrieve the real program name
project_base = os.getcwd()


# python_build: (Boolean) if true, we're either building Python or
# building an extension with an un-installed Python, so we use
# different (hard-wired) directories.
# Setup.local is available for Makefile builds including VPATH builds,
# Setup.dist is available on Windows
def _is_python_source_dir(d):
for fn in ("Setup.dist", "Setup.local"):
for fn in ("Setup", "Setup.local"):
if os.path.isfile(os.path.join(d, "Modules", fn)):
return True
return False

_sys_home = getattr(sys, '_home', None)
if (_sys_home and os.name == 'nt' and
_sys_home.lower().endswith(('\\pcbuild\\win32', '\\pcbuild\\amd64'))):
_sys_home = os.path.dirname(os.path.dirname(_sys_home))

if os.name == 'nt':
def _fix_pcbuild(d):
if d and os.path.normcase(d).startswith(
os.path.normcase(os.path.join(PREFIX, "PCbuild"))):
return PREFIX
return d
project_base = _fix_pcbuild(project_base)
_sys_home = _fix_pcbuild(_sys_home)

def _python_build():
if _sys_home:
return _is_python_source_dir(_sys_home)
return _is_python_source_dir(project_base)

python_build = _python_build()


# Calculate the build qualifier flags if they are defined. Adding the flags
# to the include and lib directories only makes sense for an installation, not
# an in-source build.
Expand Down Expand Up @@ -100,11 +110,13 @@ def get_python_inc(plat_specific=0, prefix=None):
incdir = os.path.join(get_config_var('srcdir'), 'Include')
return os.path.normpath(incdir)
python_dir = 'python' + get_python_version() + build_flags
if not python_build and plat_specific:
import sysconfig
return sysconfig.get_path('platinclude')
return os.path.join(prefix, "include", python_dir)
elif os.name == "nt":
if python_build:
# Include both the include and PC dir to ensure we can find
# pyconfig.h
return (os.path.join(prefix, "include") + os.path.pathsep +
os.path.join(prefix, "PC"))
return os.path.join(prefix, "include")
else:
raise DistutilsPlatformError(
Expand All @@ -126,24 +138,25 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local')
if prefix is None:
if standard_lib:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX

if os.name == "posix":
libpython = os.path.join(prefix,
"lib", "python" + get_python_version())
if plat_specific or standard_lib:
# Platform-specific modules (any module from a non-pure-Python
# module distribution) or standard Python library modules.
libdir = sys.platlibdir
else:
# Pure Python
libdir = "lib"
libpython = os.path.join(prefix, libdir,
# XXX RUSTPYTHON: changed from python->rustpython
"rustpython" + get_python_version())
if standard_lib:
return libpython
elif (is_default_prefix and
'PYTHONUSERBASE' not in os.environ and
'VIRTUAL_ENV' not in os.environ and
'real_prefix' not in sys.__dict__ and
sys.prefix == sys.base_prefix):
return os.path.join(prefix, "lib", "python3", "dist-packages")
else:
return os.path.join(libpython, "site-packages")
elif os.name == "nt":
Expand Down Expand Up @@ -181,11 +194,9 @@ def customize_compiler(compiler):
_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'

(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags,
configure_cppflags, configure_cflags, configure_ldflags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',
'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')
(cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')

if 'CC' in os.environ:
newcc = os.environ['CC']
Expand All @@ -198,10 +209,6 @@ def customize_compiler(compiler):
cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
if fnmatch.filter([cc, cxx], '*-4.[0-8]'):
configure_cflags = configure_cflags.replace('-fstack-protector-strong', '-fstack-protector')
ldshared = ldshared.replace('-fstack-protector-strong', '-fstack-protector')
cflags = cflags.replace('-fstack-protector-strong', '-fstack-protector')
if 'LDSHARED' in os.environ:
ldshared = os.environ['LDSHARED']
if 'CPP' in os.environ:
Expand All @@ -210,22 +217,13 @@ def customize_compiler(compiler):
cpp = cc + " -E" # not always
if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
elif configure_ldflags:
ldshared = ldshared + ' ' + configure_ldflags
if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
cflags = cflags + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
elif configure_cflags:
cflags = opt + ' ' + configure_cflags
ldshared = ldshared + ' ' + configure_cflags
if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
elif configure_cppflags:
cpp = cpp + ' ' + configure_cppflags
cflags = cflags + ' ' + configure_cppflags
ldshared = ldshared + ' ' + configure_cppflags
if 'AR' in os.environ:
ar = os.environ['AR']
if 'ARFLAGS' in os.environ:
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,8 +1605,6 @@ def test_write_unicode_filenames(self):
self.assertEqual(zf.filelist[0].filename, "foo.txt")
self.assertEqual(zf.filelist[1].filename, "\xf6.txt")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_read_after_write_unicode_filenames(self):
with zipfile.ZipFile(TESTFN2, 'w') as zipfp:
zipfp.writestr('приклад', b'sample')
Expand Down Expand Up @@ -1815,8 +1813,6 @@ def test_struct_sizes(self):
self.assertEqual(zipfile.sizeEndCentDir64, 56)
self.assertEqual(zipfile.sizeEndCentDir64Locator, 20)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_comments(self):
"""Check that comments on the archive are handled properly."""

Expand Down Expand Up @@ -2872,7 +2868,7 @@ def test_open(self):
a, b, g = root.iterdir()
with a.open() as strm:
data = strm.read()
assert data == b"content of a"
assert data == "content of a"

def test_read(self):
for alpharep in self.zipfile_alpharep():
Expand Down
5 changes: 4 additions & 1 deletion Lib/tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
'Michael Foord')
from builtins import open as _builtin_open
try:
from builtins import open as _builtin_open
except ImportError:
pass
from codecs import lookup, BOM_UTF8
import collections
from io import TextIOWrapper
Expand Down
Loading