Skip to content

Commit 3fc9604

Browse files
Oryx: Build with .NET 6 (devcontainers#298)
* Oryx: Install dotnet 3.1 runtime * fix tests * build with .NET 6 + add tests * add tests * fix tests * shellcheck: nit
1 parent be4f049 commit 3fc9604

8 files changed

Lines changed: 77 additions & 10 deletions

File tree

src/oryx/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "oryx",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"name": "Oryx",
55
"description": "Installs the oryx CLI",
66
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/oryx",

src/oryx/install.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ echo "Installing Oryx..."
116116
# Ensure apt is in non-interactive to avoid prompts
117117
export DEBIAN_FRONTEND=noninteractive
118118

119-
120119
# Install dependencies
121-
check_packages git sudo curl ca-certificates apt-transport-https gnupg2 dirmngr libc-bin
120+
check_packages git sudo curl ca-certificates apt-transport-https gnupg2 dirmngr libc-bin moreutils
122121

123122
if ! cat /etc/group | grep -e "^oryx:" > /dev/null 2>&1; then
124123
groupadd -r oryx
@@ -127,16 +126,23 @@ usermod -a -G oryx "${USERNAME}"
127126

128127
# Required to decide if we want to clean up dotnet later.
129128
DOTNET_INSTALLATION_PACKAGE=""
129+
DOTNET_BINARY=""
130+
131+
if dotnet --version > /dev/null ; then
132+
DOTNET_BINARY=$(which dotnet)
133+
fi
130134

131-
# Install dotnet unless available
132-
if ! dotnet --version > /dev/null ; then
133-
echo "'dotnet' was not detected. Attempting to install the latest version of the dotnet sdk to build oryx."
135+
# Oryx needs to be built with .NET 6
136+
if [[ "${DOTNET_BINARY}" = "" ]] || [[ "$(dotnet --version)" != *"6"* ]] ; then
137+
echo "'dotnet 6' was not detected. Attempting to install .NET 6 to build oryx."
134138
install_dotnet_using_apt
135139

136140
if ! dotnet --version > /dev/null ; then
137141
echo "(!) Please install Dotnet before installing Oryx"
138142
exit 1
139143
fi
144+
145+
DOTNET_BINARY="/usr/bin/dotnet"
140146
fi
141147

142148
BUILD_SCRIPT_GENERATOR=/usr/local/buildscriptgen
@@ -150,8 +156,8 @@ git clone --depth=1 https://github.com/microsoft/Oryx $GIT_ORYX
150156

151157
$GIT_ORYX/build/buildSln.sh
152158

153-
dotnet publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj
154-
dotnet publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj
159+
${DOTNET_BINARY} publish -property:ValidateExecutableReferencesMatchSelfContained=false -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildScriptGeneratorCli/BuildScriptGeneratorCli.csproj
160+
${DOTNET_BINARY} publish -r linux-x64 -o ${BUILD_SCRIPT_GENERATOR} -c Release $GIT_ORYX/src/BuildServer/BuildServer.csproj
155161

156162
chmod a+x ${BUILD_SCRIPT_GENERATOR}/GenerateBuildScript
157163

src/python/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "1.0.14",
3+
"version": "1.0.15",
44
"name": "Python",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
66
"description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.",

src/python/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export PIPX_HOME=${PIPX_HOME:-"/usr/local/py-utils"}
1717

1818
USERNAME=${USERNAME:-"automatic"}
1919
UPDATE_RC=${UPDATE_RC:-"true"}
20-
USE_ORYX_IF_AVAILABLE=${USE_ORYX_IF_AVAILABLE:-"true"}
20+
USE_ORYX_IF_AVAILABLE=${USEORYXIFAVAILABLE:-"true"}
2121

2222
INSTALL_JUPYTERLAB=${INSTALLJUPYTERLAB:-"false"}
2323
CONFIGURE_JUPYTERLAB_ALLOW_ORIGIN=${CONFIGUREJUPYTERLABALLOWORIGIN:-""}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mpmath==1.2.1
2+
sympy==1.11.1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sympy import Symbol, Eq, solve
2+
3+
x = Symbol("x")
4+
y = Symbol("y")
5+
6+
equation_1 = Eq((x + y), 2)
7+
equation_2 = Eq((x - y), 4)
8+
print("Equation 1:", equation_1)
9+
print("Equation 2:", equation_2)
10+
11+
solution = solve((equation_1, equation_2), (x, y))
12+
print("Solution:", solution)

test/oryx/scenarios.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,20 @@
88
},
99
"oryx": {}
1010
}
11+
},
12+
"test_python_project": {
13+
"image": "ubuntu:focal",
14+
"features": {
15+
"python": {
16+
"version": "3.10.4",
17+
"additionalVersions": "3.9.7",
18+
"useOryxIfAvailable": "false"
19+
},
20+
"dotnet": {
21+
"version": "7",
22+
"installUsingApt": "false"
23+
},
24+
"oryx": {}
25+
}
1126
}
1227
}

test/oryx/test_python_project.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
cd sample-python
9+
10+
# Replicates Oryx's behavior for universal image
11+
DEBIAN_FLAVOR="focal-scm"
12+
mkdir -p /opt/oryx && echo "vso-focal" > /opt/oryx/.imagetype
13+
echo "DEBIAN|${DEBIAN_FLAVOR}" | tr '[a-z]' '[A-Z]' > /opt/oryx/.ostype
14+
15+
ln -snf /usr/local/oryx/* /opt/oryx
16+
17+
PYTHON_PATH="/home/codespace/.python/current"
18+
mkdir -p /home/codespace/.python
19+
ln -snf /usr/local/python/current $PYTHON_PATH
20+
ln -snf /usr/local/python /opt/python
21+
22+
export PATH="/home/codespace/.python/current/bin:${PATH}"
23+
which python
24+
25+
pythonVersion=$(python -V 2>&1 | grep -Po '(?<=Python )(.+)')
26+
pythonSite=`python -m site --user-site`
27+
check "oryx-build-python" oryx build --property python_version="${pythonVersion}" --property packagedir="${pythonSite}" ./
28+
check "oryx-build-python-installed" python3 -m pip list | grep mpmath
29+
check "oryx-build-python-result" python3 ./src/solve.py
30+
31+
# Report result
32+
reportResults

0 commit comments

Comments
 (0)