-
Notifications
You must be signed in to change notification settings - Fork 347
refactor: Use environments to install Conan #10127
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
base: main
Are you sure you want to change the base?
Conversation
RUN eval "$(pyenv init - bash)" \ | ||
&& eval "$(pyenv virtualenv-init -)" \ | ||
&& pyenv virtualenv conan \ | ||
&& pyenv activate conan \ | ||
&& pip install conan==${CONAN_VERSION} \ | ||
&& pyenv deactivate \ | ||
&& pyenv virtualenv conan2 \ | ||
&& pyenv activate conan2 \ | ||
&& pip install conan==${CONAN2_VERSION} \ | ||
&& pyenv deactivate \ | ||
&& sudo chmod +x ${PYENV_ROOT}/bin/conan |
Check warning
Code scanning / Scorecard
Pinned-Dependencies Medium
Click Remediation section below to solve this issue
RUN eval "$(pyenv init - bash)" \ | ||
&& eval "$(pyenv virtualenv-init -)" \ | ||
&& pyenv virtualenv conan \ | ||
&& pyenv activate conan \ | ||
&& pip install conan==${CONAN_VERSION} \ | ||
&& pyenv deactivate \ | ||
&& pyenv virtualenv conan2 \ | ||
&& pyenv activate conan2 \ | ||
&& pip install conan==${CONAN2_VERSION} \ | ||
&& pyenv deactivate \ | ||
&& sudo chmod +x ${PYENV_ROOT}/bin/conan |
Check warning
Code scanning / Scorecard
Pinned-Dependencies Medium
Click Remediation section below to solve this issue
aa2e6e1
to
17e8541
Compare
17e8541
to
6953358
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10127 +/- ##
============================================
- Coverage 56.76% 56.72% -0.04%
Complexity 1640 1640
============================================
Files 337 337
Lines 12469 12484 +15
Branches 1172 1178 +6
============================================
+ Hits 7078 7082 +4
- Misses 4940 4951 +11
Partials 451 451
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9a52c9c
to
7ecc19b
Compare
c4ad09c
to
5976150
Compare
This comment was marked as outdated.
This comment was marked as outdated.
d98bb1e
to
d95e56a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@heliocastro Kind reminder to look at this. AFAIK, there are only the tests to fix. I think this is an important change that should be in ORT. |
workingDir, | ||
environment + mapOf( | ||
"CONAN_NON_INTERACTIVE" to "1", | ||
"CONAN_SERIES" to if (useConan2) "2" else "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename CONAN_SERIES
to e.g. CONAN_MAJOR_VERSION
or so? "Series" sounds a bit uncommon to me.
a83a763
to
e5b7543
Compare
@heliocastro I fixed the shims error (with the help of pyenv/pyenv#1157 (comment)). I will do tomorrow the fix required by @sschuberth. |
Perfectly fine. Sorry for unable to get on it sooner as I have a crazy workload at work. |
- Move previous conan/conan2 naming approach to Python environment solution. A wrapper that detects CONAN_SERIES environment var switchis between the two release series. Defaults to CONAN_SERIES=2. - Enable profile creation support by default Passing environment var CONAN_CREATE_PROFILE=false will prevent to generate a default profile. Signed-off-by: Helio Chissini de Castro <[email protected]> Signed-off-by: Nicolas Nobelis <[email protected]>
…nments Signed-off-by: Nicolas Nobelis <[email protected]>
…efault This new profile is created with `-detect` therefore it will contains the compilation flags. This is cleaner as it allows to remove the passing of the compilation flags from the package manager. It also fix the usage of Conan on non-Linux plaforms. Signed-off-by: Nicolas Nobelis <[email protected]>
- Remove DUMMY_COMPILER_SETTINGS from plugin code as breaks any non-linux systems. Signed-off-by: Helio Chissini de Castro <[email protected]> Signed-off-by: Nicolas Nobelis <[email protected]>
As agreed with @nnobelis this will not go into today's release yet. |
e5b7543
to
76b591b
Compare
This is an alignment commit to reflect the change in ORT due to [1]. [1]: oss-review-toolkit/ort#10127 Signed-off-by: Nicolas Nobelis <[email protected]>
@sschuberth Can we merge this now ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the changes basically seem to be good, I'm missing an overarching rationale explaining what actual issues venvs solve. Is it about being able to properly detect profile settings in isolation?
@@ -136,7 +136,7 @@ ARG PYTHON_VERSION | |||
ARG PYENV_GIT_TAG | |||
|
|||
ENV PYENV_ROOT=/opt/python | |||
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/conan2/bin | |||
ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the commit message needs to be reworked. To me, using dashes for a list / an enumeration is always an alarm sign that probably too much work has been crammed into a single commit.
I propose something like:
Migrate the previous approach to install binaries named `conan` and
`conan2` to properly separated virtualenvs for Python. This is done via the
pyenv-virtualenv plugin [1] for pyenv [2].
[1]: https://github.com/pyenv/pyenv-virtualenv
[2]: https://github.com/pyenv/pyenv
@@ -79,7 +79,7 @@ internal class ConanCommand(private val useConan2: Boolean = false) : CommandLin | |||
override fun getVersionRequirement(): RangesList = RangesListFactory.create(">=1.44.0 <3.0") | |||
|
|||
override fun run(vararg args: CharSequence, workingDir: File?, environment: Map<String, String>) = | |||
super.run(args = args, workingDir, environment + ("CONAN_NON_INTERACTIVE" to "1")) | |||
super.run(args = args, workingDir, environment + mapOf("CONAN_NON_INTERACTIVE" to "1", "CONAN_SERIES" to "1")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still refer to CONAN_SERIES
instead of CONAN_MAJOR_VERSION
. But is it even correct to hard-code this here? Shouldn't it be dropped to make run
work for both major versions?
if [[ "$conan_option" -eq 1 ]]; then # Setting up Conan 1.x series | ||
pyenv activate conan | ||
# Docker has modern libc | ||
CONAN_RECURSIVE_CALL=1 conan profile update settings.compiler.libcxx=libstdc++11 ort-default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this only need to be done for Conan 1?
# License-Filename: LICENSE | ||
# | ||
|
||
conan_option=${CONAN_MAJOR_VERSION:-2} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making this
CONAN_VENV="conan${CONAN_MAJOR_VERSION:-2}"
and then below simply call
pyenv activate $CONAN_VENV
once?
However, that would require to rename the venv from "conan" to "conan1", but maybe it's not a bad ideal to be explicit anyway.
|
||
# Since this script is installed with the name "conan", there is a risk of infinite recursion if pyenv is not available | ||
# on the PATH, which can occur when setting up a development environment. To prevent this, check for recursive calls. | ||
if [[ "$CONAN_RECURSIVE_CALL" -eq 1 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler check could be to compare ${BASH_SOURCE[1]}
with this script's path, i.e. ${BASH_SOURCE[0]}
.
@@ -44,6 +44,12 @@ import org.ossreviewtoolkit.utils.ort.createOrtTempDir | |||
internal class ConanV1Handler(private val conan: Conan) : ConanVersionHandler { | |||
override fun getConanHome(): File = Os.userHomeDirectory.resolve(".conan") | |||
|
|||
override fun createConanProfileIfNeeded() { | |||
if (!getConanHome().resolve("profiles/ort-default").isFile) { | |||
conan.command.run("profile", "new", "ort-default", "--detect").requireSuccess() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "ort-default" should only be added to the script in this commit which makes use of it.
@@ -222,6 +222,8 @@ class Conan( | |||
config.lockfileName?.let { hasLockfile(workingDir.resolve(it).path) } == true | |||
} | |||
|
|||
handler.createConanProfileIfNeeded() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message: s/-detect/--detect/
@@ -122,12 +122,6 @@ class Conan( | |||
private val config: ConanConfig | |||
) : PackageManager("Conan") { | |||
companion object { | |||
internal val DUMMY_COMPILER_SETTINGS = arrayOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine (and even less confusing) to squash this to the previous commit, saying to replace hard-coded dummy compiler settings with proper ones. Otherwise there's an intermediate commit with both dummy and detected settings, which does not make sense.
Move previous conan/conan2 naming approach to Python environment solution. A wrapper that detects CONAN_SERIES environment var switchis between the two release series. Defaults to CONAN_SERIES=2.
Enable profile creation support by default Passing environment var CONAN_CREATE_PROFILE=false will prevent to generate a default profile.
This is somehow how it works: