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

feature/enabling environment variables unset action #4224

Merged
merged 8 commits into from Jan 10, 2019

Conversation

Projects
None yet
5 participants
@alacasta
Copy link
Contributor

commented Jan 4, 2019

Changelog: Feature: The tools.environment_append() now accepts unsetting variables by means of appending such variable with a value equal to None.

Tests covering tools.env.environment_append have been also included.
Fixes #4168
Docs: conan-io/docs#1003

Note: This is my first contribution to this project so please, apologize if something is not fitting contribution guidelines.

alacasta added some commits Jan 4, 2019

Enabling the possibility of unsetting variables by means of appending…
… such variable with value equal to None. Tests covering tools.env.environment_append have been included
@CLAassistant

This comment has been minimized.

Copy link

commented Jan 4, 2019

CLA assistant check
All committers have signed the CLA.

alacasta added some commits Jan 4, 2019

Fixing how the env_vars dictionary is being modified. Instead of remo…
…ving values on-the-fly, It is previourly checked which should be removed by iterating on the keys.
@alacasta

This comment has been minimized.

Copy link
Contributor Author

commented Jan 4, 2019

I've broken CI twice. One of them is because of a different python version used for development (2.7) and the requirements that are also checked (python 3.4). Do you have any Dockerized development environment for Conan containing all the required libraries and tools that Conan should be compatible with?

@lasote

This comment has been minimized.

Copy link
Contributor

commented Jan 4, 2019

Hi, thanks for the contribution! About the environment, no, we don't have testing environment prepared but we use tox that can help to test with different python version. Anyway, don't worry if the CI breaks and you need to push again.

@lasote lasote added this to the 1.12 milestone Jan 4, 2019

@lasote lasote self-requested a review Jan 4, 2019

@lasote lasote self-assigned this Jan 4, 2019

@lasote lasote requested review from memsharded and jgsogo and removed request for memsharded Jan 4, 2019

Fixing how the env_vars dictionary is being modified again. Iterating…
… on keys didn't work enough and now it is decoupled the iteration by using the keys that should be removed and were previously stored
@alacasta

This comment has been minimized.

Copy link
Contributor Author

commented Jan 4, 2019

Thanks @lasote!
Let's see now...

@jgsogo

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

The previous behavior for environment_append({'env_var1': None, }) was raising a TypeError exception (only str values were allowed), so I think it is safe to implement this new tool.
Nevertheless I wonder if environment_append is the place for this behavior or we should provide a different environment_remove to avoid possible misunderstandings. I just wanted to put this on the table, but I will agree with your decission.

Show resolved Hide resolved conans/client/tools/env.py
@lasote

This comment has been minimized.

Copy link
Contributor

commented Jan 8, 2019

I suggested a different tool at some point but finally, I think keeping it in the same could be easier and for me is also easy to understand as a user. I would vote for implementing it in the environment_append

@alacasta

This comment has been minimized.

Copy link
Contributor Author

commented Jan 8, 2019

Thanks for your comments @jgsogo!

Regarding

The previous behavior for environment_append({'env_var1': None, }) was raising a TypeError exception (only str values were allowed), so I think it is safe to implement this new tool.
Nevertheless I wonder if environment_append is the place for this behavior or we should provide a different environment_remove to avoid possible misunderstandings. I just wanted to put this on the table, but I will agree with your decission.

I must say that at the beginning i was from your opinion. However and after carefuly analyzing all the points discussed on #4168 seems like having a different tool for this purpose looks complementary to the use case suggested there (more oriented to usetting variables via profiles). Anyway, if this feature is finally included, this change will become automatically unused and will be able to be refactored.

We can just keep an eye on this if this happen :)

alacasta added some commits Jan 8, 2019

Fix. Setting all the variables to None (unsetting all of them) effect…
…ively removes them from environment.

- Applying changes needed.
- Adding regression test.
- Adding additional test covering the case where no variables are asked to be removed (empty dict).
- Improve tests naming.
@jgsogo

jgsogo approved these changes Jan 9, 2019

Copy link
Member

left a comment

Great first contribution! Thanks!

@lasote

lasote approved these changes Jan 10, 2019

@lasote lasote merged commit 8e4affa into conan-io:develop Jan 10, 2019

2 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
license/cla Contributor License Agreement is signed.
Details

@ghost ghost removed the stage: review label Jan 10, 2019

@kdsx

This comment has been minimized.

Copy link

commented Jan 10, 2019

Thanks for the fix!
By the way, does it work with profiles now?

@jgsogo

This comment has been minimized.

Copy link
Member

commented Jan 10, 2019

@kdsx, no, this PR does nothing related to the profiles. As commented (#4168 (comment)) the profiles should be a different feature, is there any issue opened specific to the profiles implementation?

@kdsx

This comment has been minimized.

Copy link

commented Jan 10, 2019

No, I haven't created it.

NoWiseMan added a commit to NoWiseMan/conan that referenced this pull request Jan 11, 2019

feature/enabling environment variables unset action (conan-io#4224)
* Enabling the possibility of unsetting variables by means of appending such variable with value equal to None. Tests covering tools.env.environment_append have been included

* Fixing PEP8 line width requirement

* Fixing PEP8 line width requirement

* Fixing path separator used in the unit test considering its os-dependant value

* Fixing how the env_vars dictionary is being modified. Instead of removing values on-the-fly, It is previourly checked which should be removed by iterating on the keys.

* Fixing how the env_vars dictionary is being modified again. Iterating on keys didn't work enough and now it is decoupled the iteration by using the keys that should be removed and were previously stored

* Fix. Setting all the variables to None (unsetting all of them) effectively removes them from environment.

- Applying changes needed.
- Adding regression test.
- Adding additional test covering the case where no variables are asked to be removed (empty dict).
- Improve tests naming.

NoWiseMan added a commit to NoWiseMan/conan that referenced this pull request Jan 11, 2019

feature/enabling environment variables unset action (conan-io#4224)
* Enabling the possibility of unsetting variables by means of appending such variable with value equal to None. Tests covering tools.env.environment_append have been included

* Fixing PEP8 line width requirement

* Fixing PEP8 line width requirement

* Fixing path separator used in the unit test considering its os-dependant value

* Fixing how the env_vars dictionary is being modified. Instead of removing values on-the-fly, It is previourly checked which should be removed by iterating on the keys.

* Fixing how the env_vars dictionary is being modified again. Iterating on keys didn't work enough and now it is decoupled the iteration by using the keys that should be removed and were previously stored

* Fix. Setting all the variables to None (unsetting all of them) effectively removes them from environment.

- Applying changes needed.
- Adding regression test.
- Adding additional test covering the case where no variables are asked to be removed (empty dict).
- Improve tests naming.

lasote added a commit that referenced this pull request Feb 26, 2019

add new arch [armv5el, armv5hf] (#4260)
* add new arch [armv5el, armv5hf]

- armv5el -> armv5 soft-float
- armv5hf -> armv5 hard-float

There are still many devices based on these architectures especially embedded devices like Danelec devices, Synology etc...

*  support for armv5el, armv5hf

- made changes to b2 generator
- add tests

* Feature/deterministic short paths (#4238)

* Add sha256 helper function

* Implement hashed_redirect

Generate deterministic short paths. This makes it possible to re-use the
compilation cache database after the re-installation of conan packages.

Resolves #3971

* Write the full path to the Conan cache in the shortened directory.

Resolves #3971

* Adds new architectures: ppc32, armv8_32 and armv8.3 (#4195)

* new archs in settings.yaml

* Added new archs to migration

* Update migration to original settings.yml

* Updated b2 generator with new archs

* pure review of b2 generator

* Added new archs to get_gnu_triplet()

* revert changes on b2 generator

* review

* Back to aaarch64 and link for ilp32 clarification

* Conversion to apple arch

* added armv8.3 to get_gnu_triplet()

* feature/enabling environment variables unset action (#4224)

* Enabling the possibility of unsetting variables by means of appending such variable with value equal to None. Tests covering tools.env.environment_append have been included

* Fixing PEP8 line width requirement

* Fixing PEP8 line width requirement

* Fixing path separator used in the unit test considering its os-dependant value

* Fixing how the env_vars dictionary is being modified. Instead of removing values on-the-fly, It is previourly checked which should be removed by iterating on the keys.

* Fixing how the env_vars dictionary is being modified again. Iterating on keys didn't work enough and now it is decoupled the iteration by using the keys that should be removed and were previously stored

* Fix. Setting all the variables to None (unsetting all of them) effectively removes them from environment.

- Applying changes needed.
- Adding regression test.
- Adding additional test covering the case where no variables are asked to be removed (empty dict).
- Improve tests naming.

* Removed versions (#4267)

* Fixed bug with cached default profile (#4256)

* Fixed bug

* Docstring

* removed caching in client_cache of settings and profile

* Feature: link editable packages (#4181)

* first try

* fix includes

* minor changes

* more import fixes

* fix more imports

* short path as decorator

* move SimplePaths to conans/paths/simple_paths.py

* move back constants to conans.paths

* moving folders to conans.paths

* remove diffs caused just by ordering of imports

* remove diffs caused just by ordering of imports

* no diffs

* no diff

* move is_case_insensitive_os to conans.paths

* add rm_conandir to windows imports

* move package_layouts to paths

* fix imports

* move LINKED_FOLDER_SENTINEL to conans.paths.__init__.py

* move 'get_package_layout' to 'SimplePaths'

* get rid of PackageBaseLayout, go for duck typing

* add parser for the file that will contain paths to includes, res, bins, libs,...

* rename PackageUserLayout > PackageEditableLayout

* interface for installed_as_editable info

* test with a header only editable package

* working example for header only lib

* add test for a library with settings and options (still header only)

* fix py2 test (declare string in source as unicode)

* change import to avoid conans.tools one, so we need to mock a different function

* make it compatible for win/linux

* create the editable file sentinel using --editable argument in install command

* add needed functions to simple_paths

* add helper functions to simple paths

* add package_metadata to new layouts

* add missing named var (something went wrong merging from develop)

* remove lines, not anymore there

* add package metadata to users one

* handle error: package folders needs a ConanFileReference

* reorder imports

* add missing import

* reorder imports

* if an editable package is dirty, log an error

* moved parser to conan_file

* move parsing for conan_package_layout closer to the ConanFile, we will be able to change it in the future

* placeholders should be preprended with settings|options

* fix typos, remove unused code

* fix bug/typo

* order imports

* remove unreachable code

* remove unreachable code

* remove comments

* move unittests to its folder

* install as editable (requires the package to be already in the cache)

* declare tests

* refactor the editable hack: rely on member attribute

* move imports

* rename file to match class name

* notify user about editable condition

* gather logic together

* make it editable from the very beginning, we don't care if it is editable or not

* any error will require us to delete the editable flag

* add tests

* add tests related to editable package removal

* rename tests

* add test for other commands

* add tests for conan commands

* Update conans/test/command/editable_reference/create_editable_package_test.py

Co-Authored-By: jgsogo <jgsogo@gmail.com>

* add changes from review

* move tests to final location

* remove unused var

* change variable name (it was a py conanfile)

* don0t care about the output, but check something

* remove comments

* add tests installing an editable package (and installing its dependencies)

* remove unused import

* move cpp_info overrides to an standalone model

* minor changes related to reviews

* mode create/remove editables to client_cache class

* renamed test folder

* remove code related to 'install --editable'

* link/unlink editable packages

* consider these tests

* handle remove command on editable

* adapt message

* removal is on its own test

* check after unlink

* add tests using linked packages

* add tests for several commands

* fix test related to utf8 and ordering

* apply ordering

* remove prints

* putting path between quotes seems to solve windows issue

* review (add more checks in tests)

* function changed its name

* no import in __init__.py

* remove installed as editable

* order is not guaranteed on info command output

* no need for os.path.join

* move EDITABLE before locking package layout

* no different behaviour for update

* new model for editable_cpp_info

* check that cache file has more priority than the repo one

* review

* remove test, it is accepted behaviour now

* review

* revert change, this line is needed to pass tests in Windows

* weird substitution is not needed, but path normalization is

* inform about link removal

* use conditional 'strict' arg when reusing cache for several TestClients

* pass string to conan_api, build ConanFileReference inside it

* add tests case for editable package without files, it will use package_info data

* remove unused import

* remove uneeded command

* get the path to the conanfile.py from the argument to 'link' command inside the 'conan_api'

* remove 'EditableCppInfo.create', rename loader ones to 'load(file...)' and 'loads(teext...)'

* rename func argument

* move CONAN_PACKAGE_LAYOUT_FILE to conans/paths

* reorder variables inside file

* renamed variables

* pep8

* not using revisions in editable nodes, fix ordering issue

* rename variables

* fixing version ranges with spaces (#4273)

* fixing version ranges with spaces

* fix broken test

* simplified testing

* more error cases

* [WIP] Rename common variables to conventional ones (#4272)

* rename internal member 'PackageReference.conan' to 'PackageReference.ref'

* rename internal member 'PackageReference.conan' to 'PackageReference.ref'

* working on ConanFileRefs

* working on ConanFileRefs

* working on PackageReference

* working on ClientCache

* back to ConanFileReference

* rename member 'Node::conan_ref'

* rename member 'PythonRequires::conan_ref'

* renaming vars in comments, docs,...

* lost references

* remove duplicated uneeded conversion to str

* some loose fringes

* minor fix, review by @lasote #4272

* rename PackageReference::package_id' to 'PackageReference::id'

* loose fringes

*  support for armv5el, armv5hf

- made changes to b2 generator
- add tests

* add handling for arm5hf to get_gnu_triplet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.