Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
09256e1
wip windows support: create archive file
oraluben Nov 23, 2022
06f04ac
wip windows support: create and destroy map
oraluben Nov 23, 2022
d42ebaf
wip windows support: fix Darwin
oraluben Nov 23, 2022
e32c0a1
wip windows support: load archive
oraluben Nov 23, 2022
a03290a
wip windows support: fix Darwin
oraluben Nov 23, 2022
cbb402c
wip windows support: pass build, ref: scikit-build/scikit-build#803
oraluben Nov 24, 2022
d81aadc
fix format
oraluben Nov 24, 2022
aa9c3c5
GA tests on Windows
oraluben Nov 24, 2022
78f7296
wip windows support: create & open archive
oraluben Nov 26, 2022
d708b37
IDE follow-ups of #44.
oraluben Oct 13, 2023
dd1dd10
Merge remote-tracking branch 'origin/skbuild-core-cleanup' into msvc-…
oraluben Oct 13, 2023
d416fac
Updates to fix compile after merge.
oraluben Oct 13, 2023
a17c25e
Fix symbol issue.
oraluben Oct 16, 2023
030bd27
Pass create and load archive.
oraluben Oct 16, 2023
6836ba0
Merge branch 'main' into msvc-windows-support
oraluben Oct 16, 2023
761f7fc
Handle non-exist archive.
oraluben Oct 16, 2023
c902ec4
Fix utf8 issue on Windows.
oraluben Oct 16, 2023
e678120
Fix Linux.
oraluben Oct 16, 2023
4559bef
Enable 3.12 tests.
oraluben Oct 16, 2023
cd34c15
[skip ci] Trivial updates.
oraluben Oct 16, 2023
1c66620
Test if it's utf-8 issue.
oraluben Oct 16, 2023
9edbe0d
Fix
oraluben Oct 16, 2023
e98f5df
Fix
oraluben Oct 16, 2023
5d005fd
Randomly test other address.
oraluben Oct 16, 2023
3280203
Update GA.
oraluben Oct 16, 2023
8b9f5e1
Fix package test.
oraluben Oct 17, 2023
749a21b
Fix GA out of space and add debug information.
oraluben Oct 17, 2023
6dfe490
fix
oraluben Oct 17, 2023
785cf5a
Trivial updates.
oraluben Oct 17, 2023
1c18d12
Test.
oraluben Oct 17, 2023
ab1ea4f
Fix.
oraluben Oct 17, 2023
52450db
update
oraluben Oct 17, 2023
ca80cf2
close mapping
oraluben Oct 17, 2023
90f0b13
meta and test updates
oraluben Oct 17, 2023
a60cf64
update
oraluben Oct 17, 2023
b6f9282
Test update request location
oraluben Oct 17, 2023
a5981f0
Try map addr ~2TB
oraluben Oct 17, 2023
2925beb
[skip ci] cleanup.
oraluben Oct 17, 2023
7973bfe
update
oraluben Oct 17, 2023
6883d7b
update
oraluben Oct 17, 2023
efcbd6b
Merge branch 'msvc-windows-support' of github.com:oraluben/pycds into…
oraluben Oct 18, 2023
d77e0dd
[skip ci] cleanup debug
oraluben Oct 18, 2023
6597b85
Merge branch 'msvc-windows-support' of github.com:oraluben/pycds into…
oraluben Oct 18, 2023
0b7b056
Merge branch 'msvc-windows-support' of github.com:oraluben/pycds into…
oraluben Oct 18, 2023
54850a1
update
oraluben Oct 18, 2023
b164c36
Remove unrelated changes
oraluben Oct 18, 2023
02edb3c
Merge branch 'main' into msvc-windows-support
oraluben Oct 18, 2023
2213eb6
[skip ci] update
oraluben Oct 18, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# for actions/setup-python:
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
os: [ ubuntu-latest, macOS-latest ]
os: [ ubuntu-latest, macOS-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest ]
os: [ ubuntu-latest, macOS-latest, windows-latest ]
conda-py: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]

steps:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ concurrency:

jobs:
perf-import:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
Expand All @@ -28,7 +31,10 @@ jobs:
sh scripts/perf_import.sh

pyperformance:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest ]
os: [ ubuntu-latest, macOS-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.20)
project(pycds)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
if (MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4013")
else ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
endif ()

# Only for IDE linting, skbuild will handle wheel dependencies.
if (NOT SKBUILD)
Expand All @@ -11,16 +15,16 @@ endif ()

find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development.Module)

add_compile_definitions(Py_BUILD_CORE) # for sizeof(PyGC_Head)
add_compile_definitions(Py_BUILD_CORE Py_BUILD_CORE_MODULE) # for sizeof(PyGC_Head)
add_compile_definitions(NEED_OPCODE_TABLES) # for _PyOpcode_Caches and _PyOpcode_Deopt

python_add_library(_cds MODULE WITH_SOABI src/_cds/_cdsmodule.c src/_cds/lookup_table.c src/_cds/hashtable.c)
python_add_library(_cds MODULE WITH_SOABI src/_cds/_cdsmodule.c src/_cds/lookup_table.c src/_cds/hashtable.c src/_cds/platforms.c)
# clinic-generated files access core header.
target_include_directories(_cds PRIVATE "${Python_INCLUDE_DIRS}/internal")

# todo: if find cpython repo, run clinic
# currently we manually run `python3 ../cpython/Tools/clinic/clinic.py --make --srcdir src/_cds`

install(TARGETS _cds DESTINATION .)
install(TARGETS _cds LIBRARY DESTINATION .)

install(FILES src/artifacts/pycds.pth DESTINATION .)
21 changes: 19 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@
RELEASE = platform.release()
PYCDS_ROOT = os.path.dirname(__file__)

GA = os.environ.get('GITHUB_ACTIONS') == 'true'

CDS_PYPERFORMANCE = 'git+https://github.com/oraluben/pyperformance.git@cds'


def _clean_nox():
from nox.virtualenv import shutil

shutil.rmtree(os.path.join(PYCDS_ROOT, '.nox'), ignore_errors=True)


def ci_session_cleanup():
if OS == 'Windows' and GA:
_clean_nox()


def _py_version(session: nox.Session):
"""
:return: "3.9", "3.10", ...
Expand Down Expand Up @@ -132,9 +145,11 @@ def test_import_third_party(session: nox.Session, package):
img = os.path.join(tmp, 'test.img')

session.run('python', '-c', package.import_stmt, env={'PYCDSMODE': 'TRACE', 'PYCDSLIST': lst})
session.run('python', '-c', f'import cds.dump; cds.dump.run_dump("{lst}", "{img}")')
session.run('python', '-c', f'import cds.dump; cds.dump.run_dump({repr(lst)}, {repr(img)})')
session.run('python', '-c', package.import_stmt, env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img})

ci_session_cleanup()


@nox.session(name=f'test_import_third_party_perf-{py}', tags=['test_import_third_party_perf'], python=py)
@nox.parametrize('package', [package for package in PACKAGES if not package.should_skip(py)])
Expand All @@ -158,7 +173,7 @@ def test_import_third_party_perf(session: nox.Session, package):

logger.info(f'start generating CDS archive for {package.name}')
session.run('python', '-c', package.import_stmt, env={'PYCDSMODE': 'TRACE', 'PYCDSLIST': lst}, log=False)
session.run('python', '-c', f'import cds.dump; cds.dump.run_dump("{lst}", "{img}")', log=False)
session.run('python', '-c', f'import cds.dump; cds.dump.run_dump({repr(lst)}, {repr(img)})', log=False)
session.run('python', '-c', package.import_stmt, env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img}, log=False)
logger.info(f'finish generating CDS archive for {package.name}')

Expand All @@ -172,6 +187,8 @@ def test_import_third_party_perf(session: nox.Session, package):
'python', '-c', package.import_stmt,
env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img})

ci_session_cleanup()


def _pyperformance(session: nox.Session, pyperformance_args=None):
session.install(CDS_PYPERFORMANCE)
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ requires-python = ">=3.8"
classifiers = [
'Development Status :: 3 - Alpha',
'Operating System :: MacOS :: MacOS X',
# 'Operating System :: Microsoft :: Windows',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand All @@ -33,5 +33,9 @@ skip = "*-musllinux*"
[tool.cibuildwheel.macos]
archs = ["x86_64", "universal2", "arm64"]

[tool.cibuildwheel.windows]
archs = ["AMD64", "ARM64"]
test-skip = "*-win_arm64"

[tool.scikit-build]
wheel.packages = ["src/cds"]
68 changes: 68 additions & 0 deletions src/_cds/_cdscontext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef PYCDS__CDSCONTEXT_H
#define PYCDS__CDSCONTEXT_H

#include <Python.h>
#include <stdbool.h>

#include "lookup_table.h"
#include "platforms.h"

struct StringRefItem {
PyObject **ref;
struct StringRefItem *next;
};

struct StringRefList {
PyObject *str;
struct StringRefItem *refs;
struct StringRefList *next;
};

struct CDSArchiveHeader {
void *mapped_addr;
void *none_addr;
void *true_addr;
void *false_addr;
void *ellipsis_addr;
size_t used;

PyObject *obj;

struct StringRefList *all_string_ref;
};

struct MoveInContext {
int n_alloc;

table *orig_pyobject_to_in_heap_pyobject_map;
table *in_heap_str_to_string_ref_list_map;

#if PY_MINOR_VERSION >= 12
PyObject *static_strings;
#endif
};

struct CDSStatus {
int verbose;
int mode;

// Prevent re-entry of cds.init_from_env()
bool initialized;

long shift;
bool traverse_error;

const char *archive;
fd_type archive_fd;
#if IS_WINDOWS
fd_type mapping;
#endif

struct CDSArchiveHeader *archive_header;

PyObject *flags;

struct MoveInContext *move_in_ctx;
};

#endif // PYCDS__CDSCONTEXT_H
Loading