Show More
@@ -13,6 +13,7 This includes: | |||
|
13 | 13 | # Distributed under the terms of the Modified BSD License. |
|
14 | 14 | |
|
15 | 15 | import os |
|
16 | from pathlib import Path | |
|
16 | 17 | import re |
|
17 | 18 | import sys |
|
18 | 19 | from glob import glob |
@@ -30,21 +31,19 from setuptools.command.install_scripts import install_scripts | |||
|
30 | 31 | #------------------------------------------------------------------------------- |
|
31 | 32 | |
|
32 | 33 | # A few handy globals |
|
33 | isfile = os.path.isfile | |
|
34 | pjoin = os.path.join | |
|
35 | repo_root = os.path.dirname(os.path.abspath(__file__)) | |
|
34 | repo_root = Path(__file__).resolve().parent | |
|
36 | 35 | |
|
37 |
def execfile( |
|
|
36 | def execfile(path, globs, locs=None): | |
|
38 | 37 | locs = locs or globs |
|
39 |
with open( |
|
|
40 |
exec(compile(f.read(), |
|
|
38 | with path.open(encoding="utf-8") as f: | |
|
39 | exec(compile(f.read(), str(path), "exec"), globs, locs) | |
|
41 | 40 | |
|
42 | 41 | #--------------------------------------------------------------------------- |
|
43 | 42 | # Basic project information |
|
44 | 43 | #--------------------------------------------------------------------------- |
|
45 | 44 | |
|
46 | 45 | # release.py contains version, authors, license, url, keywords, etc. |
|
47 |
execfile( |
|
|
46 | execfile(Path(repo_root, "IPython", "core", "release.py"), globals()) | |
|
48 | 47 | |
|
49 | 48 | # Create a dict with the basic information |
|
50 | 49 | # This dict is eventually passed to setup after additional keys are added. |
@@ -62,13 +61,13 def check_package_data(package_data): | |||
|
62 | 61 | """verify that package_data globs make sense""" |
|
63 | 62 | print("checking package data") |
|
64 | 63 | for pkg, data in package_data.items(): |
|
65 |
pkg_root = |
|
|
64 | pkg_root = Path(*pkg.split(".")) | |
|
66 | 65 | for d in data: |
|
67 |
path = |
|
|
68 |
if |
|
|
69 | assert len(glob(path)) > 0, "No files match pattern %s" % path | |
|
66 | path = pkg_root / d | |
|
67 | if "*" in str(path): | |
|
68 | assert len(glob(str(path))) > 0, "No files match pattern %s" % path | |
|
70 | 69 | else: |
|
71 |
assert |
|
|
70 | assert path.exists(), f"Missing package data: {path}" | |
|
72 | 71 | |
|
73 | 72 | |
|
74 | 73 | def check_package_data_first(command): |
@@ -95,18 +94,18 def find_data_files(): | |||
|
95 | 94 | """ |
|
96 | 95 | |
|
97 | 96 | if "freebsd" in sys.platform: |
|
98 |
manpagebase = |
|
|
97 | manpagebase = Path("man") / "man1" | |
|
99 | 98 | else: |
|
100 |
manpagebase = |
|
|
99 | manpagebase = Path("share") / "man" / "man1" | |
|
101 | 100 | |
|
102 | 101 | # Simple file lists can be made by hand |
|
103 |
manpages = [f for f in glob( |
|
|
102 | manpages = [f for f in Path("docs/man").glob("*.1.gz") if f.is_file()] | |
|
104 | 103 | if not manpages: |
|
105 | 104 | # When running from a source tree, the manpages aren't gzipped |
|
106 |
manpages = [f for f in glob( |
|
|
105 | manpages = [f for f in Path("docs/man").glob("*.1") if f.is_file()] | |
|
107 | 106 | |
|
108 | 107 | # And assemble the entire output list |
|
109 |
data_files = [ |
|
|
108 | data_files = [(str(manpagebase), [str(f) for f in manpages])] | |
|
110 | 109 | |
|
111 | 110 | return data_files |
|
112 | 111 | |
@@ -126,11 +125,11 def target_outdated(target,deps): | |||
|
126 | 125 | true, otherwise return false. |
|
127 | 126 | """ |
|
128 | 127 | try: |
|
129 |
target_time = |
|
|
130 |
except |
|
|
128 | target_time = Path(target).stat().st_mtime | |
|
129 | except FileNotFoundError: | |
|
131 | 130 | return 1 |
|
132 | 131 | for dep in deps: |
|
133 |
dep_time = |
|
|
132 | dep_time = Path(dep).stat().st_mtime | |
|
134 | 133 | if dep_time > target_time: |
|
135 | 134 | # print("For target",target,"Dep failed:",dep) # dbg |
|
136 | 135 | # print("times (dep,tar):",dep_time,target_time) # dbg |
@@ -190,25 +189,24 def git_prebuild(pkg_dir, build_cmd=build_py): | |||
|
190 | 189 | repo_commit, _ = proc.communicate() |
|
191 | 190 | repo_commit = repo_commit.strip().decode("ascii") |
|
192 | 191 | |
|
193 |
out_pth = |
|
|
194 |
if o |
|
|
192 | out_pth = Path(base_dir) / pkg_dir / "utils" / "_sysinfo.py" | |
|
193 | if out_pth.is_file() and not repo_commit: | |
|
195 | 194 | # nothing to write, don't clobber |
|
196 | 195 | return |
|
197 | 196 | |
|
198 |
print("writing git commit ' |
|
|
197 | print(f"writing git commit '{repo_commit}' to {out_pth}") | |
|
199 | 198 | |
|
200 | 199 | # remove to avoid overwriting original via hard link |
|
201 | 200 | try: |
|
202 |
o |
|
|
203 |
except |
|
|
201 | out_pth.unlink() | |
|
202 | except FileNotFoundError: | |
|
204 | 203 | pass |
|
205 |
with open( |
|
|
204 | with out_pth.open("w", encoding="utf-8") as out_file: | |
|
206 | 205 | out_file.writelines( |
|
207 | 206 | [ |
|
208 | 207 | "# GENERATED BY setup.py\n", |
|
209 |
'commit = " |
|
|
208 | f'commit = "{repo_commit}"\n', | |
|
210 | 209 | ] |
|
211 | 210 | ) |
|
212 | 211 | |
|
213 | 212 | return MyBuildPy |
|
214 |
General Comments 0
You need to be logged in to leave comments.
Login now