Skip to content

Commit be2705b

Browse files
committed
Support for more packages without build scripts.
1 parent cd51140 commit be2705b

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

Lib/__np__/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,17 @@ def run_with_output(*args, **kwargs):
227227
quiet = kwargs.pop("quiet", False)
228228
assert not kwargs
229229

230+
env = os.environ.copy()
231+
# Don't use the pip path customization here. Just replicate our current path.
232+
env["PYTHONPATH"] = os.pathsep.join([x for x in sys.path if not x.endswith(os.path.sep + "site")])
233+
230234
p = subprocess.Popen(
231235
args,
232236
universal_newlines=True,
233237
stdin=stdin,
234238
stdout=subprocess.PIPE,
235239
stderr=subprocess.STDOUT,
240+
env=env,
236241
)
237242

238243
output = ""

Lib/__np__/packaging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_extra_sources_for_package(package_name):
240240
)
241241
return package_sources
242242

243-
def find_build_script_for_package(package_name, version):
243+
def find_build_script_for_package(package_name, version=None):
244244
try:
245245
package_index = getPackageJson("packages", package_name)
246246
except __np__.NoSuchURL:
@@ -249,10 +249,10 @@ def find_build_script_for_package(package_name, version):
249249
matched_source = None
250250
for source in package_index["scripts"]:
251251
matched_metadata = True
252-
if "metadata" in source and "Version" in source["metadata"]:
252+
if version is not None and "metadata" in source and "Version" in source["metadata"]:
253253
matched_metadata = fnmatch.fnmatch(version, source["metadata"]["Version"])
254254

255-
if matched_metadata:
255+
if matched_metadata or version is None:
256256
matched_source = source
257257
break
258258

Lib/pip.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ def our_load_pyproject_toml(use_pep517, pyproject_toml, setup_py, req_name):
6969

7070
# We will be taking over the build process.
7171
if os.path.isfile(os.path.join(os.path.dirname(os.path.dirname(pyproject_toml)), "script.json")):
72+
with open(os.path.join(os.path.dirname(os.path.dirname(pyproject_toml)), "script.json"), 'r') as f:
73+
data = json.load(f)
74+
requires = []
75+
if 'requires' in data['script_metadata']:
76+
requires = data['script_metadata']['requires']
7277
return pip._internal.pyproject.BuildSystemDetails(
73-
[], "__np__.metabuild:managed_build", [], [os.path.dirname(__file__), real_pip_dir])
78+
requires, "__np__.metabuild:managed_build", [], [os.path.dirname(__file__), real_pip_dir])
7479

7580
result = load_pyproject_toml_orig(use_pep517, pyproject_toml, setup_py, req_name)
7681
if result is None:
@@ -132,6 +137,12 @@ def find_all_candidates(self, project_name):
132137

133138
base_candidates = _PackageFinder.find_all_candidates(self, project_name)
134139

140+
build_script = __np__.packaging.find_build_script_for_package(project_name)
141+
142+
if build_script:
143+
# If we have a build script, filter out wheels.
144+
base_candidates = [x for x in base_candidates if not x.link.is_wheel]
145+
135146
return __np__.packaging.get_extra_sources_for_package(project_name) + base_candidates
136147

137148

0 commit comments

Comments
 (0)