-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add rust-plain, python-pyproject tests
- Loading branch information
1 parent
4f84910
commit 90dd67d
Showing
16 changed files
with
207 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import * as std from "std" with { path: "../../std" }; | ||
import * as python from "python" with { path: "../../python" }; | ||
// import * as poetry from "poetry" with { path: "../../poetry" }; | ||
import { wrapScripts } from "../common"; | ||
|
||
export type Arg = { | ||
build?: string; | ||
env?: std.env.Arg; | ||
host?: string; | ||
source: tg.Directory; | ||
}; | ||
|
||
export const build = tg.target(async (arg: Arg) => { | ||
const { build, env: envArg, host, source } = arg ?? {}; | ||
|
||
const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); | ||
let arg_: python.BuildArg = { build, env: env_, host, source }; | ||
|
||
const maybeRequirements = source.tryGet("requirements.txt"); | ||
if (maybeRequirements) { | ||
if (maybeRequirements instanceof tg.File) { | ||
arg_ = { ...arg_, requirements: maybeRequirements }; | ||
} | ||
} | ||
|
||
return python.build(arg_); | ||
}); | ||
|
||
export default build; | ||
|
||
export const plain = tg.target(async (arg: Arg) => { | ||
const { build, env: envArg, host, source } = arg ?? {}; | ||
|
||
const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); | ||
const toolchain = await python.toolchain(); | ||
const interpreter = await toolchain.get("bin/python3").then(tg.File.expect); | ||
return wrapScripts({ | ||
directory: source, | ||
extension: ".py", | ||
interpreter, | ||
env: std.env.arg( | ||
{ | ||
PYTHONPATH: toolchain, | ||
}, | ||
env_, | ||
), | ||
}); | ||
}); | ||
|
||
// export const poetry = tg.target(async (arg: Arg) => { | ||
// const { build, env: envArg, host, source } = arg ?? {}; | ||
|
||
// const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); | ||
// const arg_ = { build, env: env_, host, source }; | ||
// return poetry.build(arg_); | ||
// }); | ||
|
||
export const pyproject = tg.target(async (arg: Arg) => { | ||
const { build, env: envArg, host, source } = arg ?? {}; | ||
|
||
const env_ = envArg ?? std.env.arg(env({ build, host }), envArg); | ||
const pyprojectToml = await source.get("pyproject.toml").then(tg.File.expect); | ||
const arg_ = { build, env: env_, host, pyprojectToml, source }; | ||
return python.build(arg_); | ||
}); | ||
|
||
type EnvArg = { | ||
build?: string | undefined; | ||
host?: string | undefined; | ||
}; | ||
|
||
export const env = tg.target(async (arg: EnvArg) => { | ||
const { build: build_, host: host_ } = arg ?? {}; | ||
const host = host_ ?? (await std.triple.host()); | ||
const build = build_ ?? host; | ||
return std.env(python.toolchain({ ...std.triple.rotate({ build, host }) })); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Hello, world!") |
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,3 @@ | ||
# demo | ||
|
||
A sample Poetry package. |
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,20 @@ | ||
[build-system] | ||
requires = ["setuptools>=45", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "demo_package" | ||
version = "0.1.0" | ||
description = "A demonstration package that displays text to stdout" | ||
readme = "README.md" | ||
authors = [ | ||
{name = "Tangram", email = "[email protected]"} | ||
] | ||
requires-python = ">=3.8" | ||
dependencies = [] | ||
|
||
[project.optional-dependencies] | ||
dev = ["pytest>=7.0"] | ||
|
||
[project.scripts] | ||
test = "demo_package.main:main" |
Empty file.
10 changes: 10 additions & 0 deletions
10
packages/autobuild/tests/python-pyproject/src/demo_package/main.py
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,10 @@ | ||
def get_message() -> str: | ||
return "Hello, world!" | ||
|
||
def main() -> None: | ||
"""Entry point for the application.""" | ||
message = get_message() | ||
print(message) | ||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
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,3 @@ | ||
# demo | ||
|
||
A sample Poetry package. |
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,21 @@ | ||
[metadata] | ||
name = demo-package | ||
version = 0.1.0 | ||
description = A demonstration package that displays text to stdout | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
author = Tangram | ||
author_email = [email protected] | ||
|
||
[options] | ||
package_dir = | ||
= src | ||
packages = find: | ||
python_requires = >=3.8 | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
demo-text = demo_package.main:main |
Empty file.
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,10 @@ | ||
def get_message() -> str: | ||
return "Hello world!" | ||
|
||
def main() -> None: | ||
"""Entry point for the application.""" | ||
message = get_message() | ||
print(message) | ||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
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,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
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