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