-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved its configured target factory, provider, and test to the ...lib/rules/python directory instead of ...lib/bazel/rules/python. Simplified the test. Also moved BazelPythonConfigurationTest into the bazel dir. The `files` attribute of py_runtime is no longer mandatory. Since a non-empty value is not permitted when `interpreter_path` is used, it makes more sense to omit it rather than explicitly set it to empty. The error messages and rule logic are simplified. The provider now has an invariant that either interpreter is null or else interpreterPath and files are null; this will be clarified in a follow-up CL that exposes PyRuntimeProvider to Starlark. Work toward #7375. PiperOrigin-RevId: 234174755
- Loading branch information
1 parent
053508f
commit 267675f
Showing
11 changed files
with
238 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuntimeProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/com/google/devtools/build/lib/rules/python/PyRuntimeProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2017 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.rules.python; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.devtools.build.lib.actions.Artifact; | ||
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; | ||
import com.google.devtools.build.lib.collect.nestedset.NestedSet; | ||
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; | ||
import com.google.devtools.build.lib.vfs.PathFragment; | ||
import javax.annotation.Nullable; | ||
|
||
/** Information about the Python runtime used by the <code>py_*</code> rules. */ | ||
@AutoValue | ||
@Immutable | ||
public abstract class PyRuntimeProvider implements TransitiveInfoProvider { | ||
|
||
public static PyRuntimeProvider create( | ||
@Nullable NestedSet<Artifact> files, | ||
@Nullable Artifact interpreter, | ||
@Nullable PathFragment interpreterPath) { | ||
return new AutoValue_PyRuntimeProvider(files, interpreter, interpreterPath); | ||
} | ||
|
||
/** | ||
* Returns whether this runtime is hermetic, i.e. represents an in-build interpreter as opposed to | ||
* a system interpreter. | ||
* | ||
* <p>Hermetic runtimes have non-null values for {@link #getInterpreter} and {@link #getFiles}, | ||
* while non-hermetic runtimes have non-null {@link #getInterpreterPath}. | ||
* | ||
* <p>Note: Despite the name, it is still possible for a hermetic runtime to reference in-build | ||
* files that have non-hermetic behavior. For example, {@link #getInterpreter} could reference a | ||
* checked-in wrapper script that calls the system interpreter at execution time. | ||
*/ | ||
public boolean isHermetic() { | ||
return getInterpreter() != null; | ||
} | ||
|
||
@Nullable | ||
public abstract NestedSet<Artifact> getFiles(); | ||
|
||
@Nullable | ||
public abstract Artifact getInterpreter(); | ||
|
||
@Nullable | ||
public abstract PathFragment getInterpreterPath(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.