Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Interpreter Argument for pep517 sdist Generation #2283

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guide/src/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Options:
This option is ignored on all non-linux platforms

-i, --interpreter [<INTERPRETER>...]
The python versions to build wheels for, given as the executables of interpreters such as `python3.9` or `/usr/bin/python3.8`
The python versions to build wheels or an sdist for, given as the executables of interpreters such as `python3.9` or `/usr/bin/python3.8`

-f, --find-interpreter
Find interpreters from the host machine
Expand Down
10 changes: 9 additions & 1 deletion maturin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ def build_wheel(

# noinspection PyUnusedLocal
def build_sdist(sdist_directory: str, config_settings: Optional[Mapping[str, Any]] = None) -> str:
command = ["maturin", "pep517", "write-sdist", "--sdist-directory", sdist_directory]
command = [
"maturin",
"pep517",
"write-sdist",
"--sdist-directory",
sdist_directory,
"--interpreter",
_get_sys_executable(),
]

print("Running `{}`".format(" ".join(command)))
sys.stdout.flush()
Expand Down
2 changes: 1 addition & 1 deletion src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub struct BuildOptions {
)]
pub platform_tag: Vec<PlatformTag>,

/// The python versions to build wheels for, given as the executables of
/// The python versions to build wheels or an sdist for, given as the executables of
/// interpreters such as `python3.9` or `/usr/bin/python3.8`.
#[arg(short, long, num_args = 0.., action = clap::ArgAction::Append)]
pub interpreter: Vec<PathBuf>,
Expand Down
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ enum Pep517Command {
#[arg(short = 'm', long = "manifest-path", value_name = "PATH")]
/// The path to the Cargo.toml
manifest_path: Option<PathBuf>,
/// The interpreter to use when building an sdist. If empty, maturin
/// will attempt to find an interpreter from the virtual environment
/// or system environment.
#[arg(short = 'i', long = "interpreter", value_name = "PATH")]
interpreter: Option<PathBuf>,
},
}

Expand Down Expand Up @@ -306,6 +311,7 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
Pep517Command::WriteSDist {
sdist_directory,
manifest_path,
interpreter,
} => {
let build_options = BuildOptions {
out: Some(sdist_directory),
Expand All @@ -316,6 +322,7 @@ fn pep517(subcommand: Pep517Command) -> Result<()> {
all_features: true,
..Default::default()
},
interpreter: interpreter.map_or_else(Vec::new, |interp| vec![interp]),
..Default::default()
};
let build_context = build_options.into_build_context(false, false, false)?;
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd/build.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Options:
This option is ignored on all non-linux platforms

-i, --interpreter [<INTERPRETER>...]
The python versions to build wheels for, given as the executables of interpreters such as
`python3.9` or `/usr/bin/python3.8`
The python versions to build wheels or an sdist for, given as the executables of
interpreters such as `python3.9` or `/usr/bin/python3.8`

-f, --find-interpreter
Find interpreters from the host machine
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd/publish.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Options:
This option is ignored on all non-linux platforms

-i, --interpreter [<INTERPRETER>...]
The python versions to build wheels for, given as the executables of interpreters such as
`python3.9` or `/usr/bin/python3.8`
The python versions to build wheels or an sdist for, given as the executables of
interpreters such as `python3.9` or `/usr/bin/python3.8`

-f, --find-interpreter
Find interpreters from the host machine
Expand Down
Loading