pacparser 1.5.2.dev2__tar.gz → 1.5.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pacparser
3
- Version: 1.5.2.dev2
3
+ Version: 1.5.3
4
4
  Summary: Pacparser package
5
5
  Home-page: https://github.com/manugarg/pacparser
6
6
  Author: Manu Garg
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pacparser
3
- Version: 1.5.2.dev2
3
+ Version: 1.5.3
4
4
  Summary: Pacparser package
5
5
  Home-page: https://github.com/manugarg/pacparser
6
6
  Author: Manu Garg
@@ -76,11 +76,18 @@ def git_version():
76
76
  )
77
77
 
78
78
 
79
+ def in_git_repo():
80
+ try:
81
+ return subprocess.call(
82
+ "git rev-parse --git-dir".split(" "), stderr=subprocess.DEVNULL
83
+ ) == 0
84
+ except OSError:
85
+ # git is not installed.
86
+ return False
87
+
88
+
79
89
  def pacparser_version():
80
- if (
81
- subprocess.call("git rev-parse --git-dir".split(" "), stderr=subprocess.DEVNULL)
82
- == 0
83
- ):
90
+ if in_git_repo():
84
91
  return git_version()
85
92
 
86
93
  # Check if we have version.mk. It's added in the manual release tarball
@@ -176,15 +183,48 @@ class CleanCmd(_clean_cmd):
176
183
  shutil.rmtree("quickjs")
177
184
 
178
185
 
179
- def build_c_objects():
186
+ def find_build_tool(var, default):
187
+ """Return the command (as an argv list) for the build tool named by var.
188
+
189
+ The environment variable wins, then Python's sysconfig value, then the
190
+ default. Cross-compiled Pythons record the build machine's toolchain in
191
+ sysconfig, which usually doesn't exist where the module is being
192
+ installed, so a sysconfig value that isn't runnable is skipped.
193
+ """
194
+ cmd = shlex.split(os.environ.get(var, ""))
195
+ if cmd:
196
+ if not shutil.which(cmd[0]):
197
+ sys.exit("%s is set to '%s', but '%s' was not found." %
198
+ (var, os.environ[var], cmd[0]))
199
+ return cmd
200
+
201
+ cmd = shlex.split(sysconfig.get_config_var(var) or "")
202
+ if cmd and shutil.which(cmd[0]):
203
+ return cmd
204
+
205
+ if not shutil.which(default):
206
+ tried = "'%s'" % default
207
+ if cmd:
208
+ tried = "'%s' (from Python's build configuration) or %s" % (
209
+ cmd[0], tried)
210
+ sys.exit(
211
+ "Building pacparser from source needs a C toolchain, but %s was "
212
+ "not found. Install one, or point the %s environment variable at "
213
+ "it." % (tried, var))
214
+ # Export the fallback so that setuptools compiles the extension itself
215
+ # with the same tool instead of the unusable sysconfig one.
216
+ os.environ[var] = default
217
+ return [default]
218
+
219
+
220
+ def build_c_objects(cc):
180
221
  """Compile pacparser.o and quickjs/libquickjs.a from the C sources.
181
222
 
182
223
  The sdist ships the C sources but no prebuilt objects, so they have to
183
224
  be built before the _pacparser extension can be linked.
184
225
  """
185
- cc = shlex.split(sysconfig.get_config_var("CC") or "cc")
186
- ar = shlex.split(sysconfig.get_config_var("AR") or "ar")
187
226
  if not os.path.exists(os.path.join("quickjs", "libquickjs.a")):
227
+ ar = find_build_tool("AR", "ar")
188
228
  quickjs_obj = os.path.join("quickjs", "quickjs.o")
189
229
  if not os.path.exists(quickjs_obj):
190
230
  subprocess.check_call(
@@ -225,13 +265,19 @@ def main(patched_func):
225
265
  # that other commands (sdist, egg_info, clean, ...) do not require a
226
266
  # C toolchain.
227
267
  build_commands = ("build", "build_ext", "bdist", "bdist_wheel", "install")
268
+ building = sys.platform != "win32" and any(
269
+ cmd in build_commands for cmd in sys.argv[1:])
270
+ if building:
271
+ # Resolve the compiler even when the objects already exist: this is
272
+ # also what makes setuptools use a working compiler for the
273
+ # extension itself.
274
+ cc = find_build_tool("CC", "cc")
228
275
  if (
229
276
  len(found_objects) < len(obj_search_path)
230
- and sys.platform != "win32"
277
+ and building
231
278
  and os.path.exists("pacparser.c")
232
- and any(cmd in build_commands for cmd in sys.argv[1:])
233
279
  ):
234
- build_c_objects()
280
+ build_c_objects(cc)
235
281
  found_objects["pacparser.o"] = found_objects.get(
236
282
  "pacparser.o", "pacparser.o")
237
283
  found_objects["libquickjs.a"] = found_objects.get(
@@ -0,0 +1 @@
1
+ VERSION=1.5.3
@@ -1 +0,0 @@
1
- VERSION=1.5.2.dev2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes