applepy-cli 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/PKG-INFO +1 -1
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.egg-info/PKG-INFO +1 -1
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.py +53 -21
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/pyproject.toml +1 -1
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/README.md +0 -0
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.egg-info/SOURCES.txt +0 -0
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.egg-info/dependency_links.txt +0 -0
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.egg-info/entry_points.txt +0 -0
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/applepy_cli.egg-info/top_level.txt +0 -0
- {applepy_cli-0.1.2 → applepy_cli-0.1.3}/setup.cfg +0 -0
|
@@ -21,7 +21,7 @@ import sysconfig
|
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
from textwrap import dedent
|
|
23
23
|
|
|
24
|
-
__version__ = "0.1.
|
|
24
|
+
__version__ = "0.1.3"
|
|
25
25
|
|
|
26
26
|
# ApplePy Swift package — used when generating Package.swift for new projects
|
|
27
27
|
APPLEPY_GITHUB_URL = "https://github.com/jagtesh/ApplePy.git"
|
|
@@ -50,17 +50,28 @@ classifiers = [
|
|
|
50
50
|
|
|
51
51
|
[tool.setuptools.packages.find]
|
|
52
52
|
include = ["{name}*"]
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.package-data]
|
|
55
|
+
{name} = ["*.so"]
|
|
56
|
+
'''
|
|
57
|
+
|
|
58
|
+
MANIFEST_IN_TEMPLATE = '''\
|
|
59
|
+
recursive-include swift *.swift
|
|
60
|
+
include swift/Package.swift
|
|
61
|
+
include swift/Package.resolved
|
|
62
|
+
recursive-exclude swift/.build *
|
|
53
63
|
'''
|
|
54
64
|
|
|
55
65
|
SETUP_PY_TEMPLATE = '''\
|
|
56
66
|
"""Build — compiles Swift source into a Python-loadable .so"""
|
|
57
67
|
import os
|
|
68
|
+
import shutil
|
|
58
69
|
import subprocess
|
|
59
70
|
import sys
|
|
60
71
|
import sysconfig
|
|
61
72
|
from pathlib import Path
|
|
62
73
|
|
|
63
|
-
from setuptools import setup
|
|
74
|
+
from setuptools import Extension, setup
|
|
64
75
|
from setuptools.command.build_ext import build_ext
|
|
65
76
|
|
|
66
77
|
|
|
@@ -71,7 +82,8 @@ class SwiftBuildExt(build_ext):
|
|
|
71
82
|
if sys.platform != "darwin":
|
|
72
83
|
raise RuntimeError("{name} only supports macOS")
|
|
73
84
|
|
|
74
|
-
|
|
85
|
+
src_dir = Path(__file__).parent
|
|
86
|
+
swift_dir = src_dir / "swift"
|
|
75
87
|
pkg_config_path = sysconfig.get_config_var("LIBPC") or ""
|
|
76
88
|
|
|
77
89
|
env = os.environ.copy()
|
|
@@ -84,21 +96,36 @@ class SwiftBuildExt(build_ext):
|
|
|
84
96
|
env=env,
|
|
85
97
|
)
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
# Find the built .dylib (check platform-specific and legacy paths)
|
|
100
|
+
lib_name = "lib{swift_target}.dylib"
|
|
101
|
+
candidates = [
|
|
102
|
+
swift_dir / ".build" / "debug" / lib_name,
|
|
103
|
+
swift_dir / ".build" / "arm64-apple-macosx" / "debug" / lib_name,
|
|
104
|
+
]
|
|
105
|
+
dylib = next((p for p in candidates if p.exists()), None)
|
|
106
|
+
if dylib is None:
|
|
107
|
+
raise RuntimeError(f"Build succeeded but {{lib_name}} not found in .build/")
|
|
108
|
+
|
|
109
|
+
# Copy to _native/ subdirectory (avoids shadowing the package)
|
|
110
|
+
dest_dir = src_dir / "{name}" / "_native"
|
|
111
|
+
dest_dir.mkdir(exist_ok=True)
|
|
112
|
+
src_dest = dest_dir / "{name}.so"
|
|
113
|
+
print(f"📦 Installing {{dylib.name}} → {{src_dest}}")
|
|
114
|
+
shutil.copy2(dylib, src_dest)
|
|
115
|
+
|
|
116
|
+
# Also copy to build_lib (for regular pip install / wheel builds)
|
|
117
|
+
if self.build_lib:
|
|
118
|
+
build_dest = Path(self.build_lib) / "{name}" / "_native" / "{name}.so"
|
|
119
|
+
build_dest.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
print(f"📦 Installing {{dylib.name}} → {{build_dest}}")
|
|
121
|
+
shutil.copy2(dylib, build_dest)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Dummy extension so setuptools invokes build_ext
|
|
125
|
+
setup(
|
|
126
|
+
ext_modules=[Extension("{name}._swift", sources=[])],
|
|
127
|
+
cmdclass={{"build_ext": SwiftBuildExt}},
|
|
128
|
+
)
|
|
102
129
|
'''
|
|
103
130
|
|
|
104
131
|
INIT_PY_TEMPLATE = '''\
|
|
@@ -117,7 +144,7 @@ if sys.platform != "darwin":
|
|
|
117
144
|
def _load_native():
|
|
118
145
|
"""Load the compiled Swift extension module."""
|
|
119
146
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
|
120
|
-
so_path = os.path.join(pkg_dir, "{name}.so")
|
|
147
|
+
so_path = os.path.join(pkg_dir, "_native", "{name}.so")
|
|
121
148
|
|
|
122
149
|
if not os.path.exists(so_path):
|
|
123
150
|
raise ImportError(
|
|
@@ -126,7 +153,7 @@ def _load_native():
|
|
|
126
153
|
" # or: pip install -e ."
|
|
127
154
|
)
|
|
128
155
|
|
|
129
|
-
spec = importlib.util.spec_from_file_location("{name}", so_path)
|
|
156
|
+
spec = importlib.util.spec_from_file_location("{name}._native.{name}", so_path)
|
|
130
157
|
mod = importlib.util.module_from_spec(spec)
|
|
131
158
|
spec.loader.exec_module(mod)
|
|
132
159
|
return mod
|
|
@@ -139,7 +166,7 @@ for _attr in dir(_native):
|
|
|
139
166
|
if not _attr.startswith("_"):
|
|
140
167
|
globals()[_attr] = getattr(_native, _attr)
|
|
141
168
|
|
|
142
|
-
__version__ = "0.1.
|
|
169
|
+
__version__ = "0.1.0"
|
|
143
170
|
'''
|
|
144
171
|
|
|
145
172
|
# Two Package.swift templates: one for GitHub (default), one for local dev
|
|
@@ -393,6 +420,7 @@ def cmd_new(args):
|
|
|
393
420
|
dirs = [
|
|
394
421
|
project_dir,
|
|
395
422
|
project_dir / name,
|
|
423
|
+
project_dir / name / "_native",
|
|
396
424
|
project_dir / name / "examples",
|
|
397
425
|
project_dir / "swift",
|
|
398
426
|
project_dir / "swift" / "Sources" / swift_target,
|
|
@@ -400,6 +428,9 @@ def cmd_new(args):
|
|
|
400
428
|
for d in dirs:
|
|
401
429
|
d.mkdir(parents=True, exist_ok=True)
|
|
402
430
|
|
|
431
|
+
# Create empty __init__.py for _native subpackage
|
|
432
|
+
(project_dir / name / "_native" / "__init__.py").write_text("")
|
|
433
|
+
|
|
403
434
|
# Build context for templates
|
|
404
435
|
ctx = {
|
|
405
436
|
"name": name,
|
|
@@ -421,6 +452,7 @@ def cmd_new(args):
|
|
|
421
452
|
project_dir / "setup.py": SETUP_PY_TEMPLATE,
|
|
422
453
|
project_dir / "README.md": README_TEMPLATE,
|
|
423
454
|
project_dir / ".gitignore": GITIGNORE_TEMPLATE,
|
|
455
|
+
project_dir / "MANIFEST.in": MANIFEST_IN_TEMPLATE,
|
|
424
456
|
project_dir / name / "__init__.py": INIT_PY_TEMPLATE,
|
|
425
457
|
project_dir / name / "examples" / "demo.py": DEMO_PY_TEMPLATE,
|
|
426
458
|
project_dir / "swift" / "Package.swift": pkg_swift_template,
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "applepy-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Build tool for ApplePy — scaffold, build, and publish Swift-powered Python packages"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "BSD-3-Clause"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|