Repository: conan-io/conan

Issue:
del self.info.options.<option> in package_id() fails
In [conan.io docs](http://docs.conan.io/en/latest/reference/conanfile/methods.html?highlight=deploy#self-info) I saw an example:
```python
def package_id(self):
    del self.info.settings.compiler
    del self.info.options.shared
```
So I expected the following should work:
```
from conans import ConanFile

class TestConan(ConanFile):
    name = "Test"
    version = "0.0.1"
    options = {"opt": [True, False]}
    default_options = "opt=False"

    def package(self):
        pass

    def package_info(self):
        del self.info.options.opt
```
But it does not:
```
conan create . dbely/testing
...
Test/0.0.1@dbely/testing: Calling package()
Test/0.0.1@dbely/testing: Package '5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' created
ERROR: Traceback (most recent call last):
  File "c:\python36\lib\site-packages\conans\errors.py", line 24, in conanfile_exception_formatter
    yield
  File "c:\python36\lib\site-packages\conans\client\installer.py", line 473, in _call_package_info
    conanfile.package_info()
  File "C:\Users\dbely\.conan\data\Test\0.0.1\dbely\testing\export\conanfile.py", line 13, in package_info
    del self.info.options.opt
AttributeError: opt
```



Discussion:
Yes, this is intended ``package_id()`` and ``package_info()`` are very different methods for different things. The ``self.info`` field is used exclusively for the computation of the binary package ID, and it should only be modified in the ``package_id()`` method.

May I ask why are you trying to delete the option in the ``package_info()`` method? What would be the use case for that? Thanks!
Thanks, but `package_id()` fails too:
```python
from conans import ConanFile

class TestConan(ConanFile):
    name = "Test"
    version = "0.0.1"
    options = {"opt": [True, False]}
    default_options = "opt=False"

    def package(self):
        pass

    def package_id(self):
        del self.info.options.opt
```
```
ERROR: Test/0.0.1@dbely/testing: Error in package_id() method, line 13
        del self.info.options.opt
        AttributeError: opt
```
Am I still missing something?

> May I ask why are you trying to delete the option in the `package_info()` method? What would be the use case for that? Thanks!

There is an option that just sets an environment variable:
```python
    def package_info(self):
        ...
        if self.options.cygwin:
            self.output.info("Creating CYGWIN env var : %s" % self.options.cygwin)
            self.env_info.CYGWIN = str(self.options.cygwin)
```
I thought it could be safe to exclude it from `package_id()`

Resolving patch:
diff --git a/conans/model/options.py b/conans/model/options.py
--- a/conans/model/options.py
+++ b/conans/model/options.py
@@ -69,6 +69,11 @@ def __getattr__(self, attr):
             return None
         return self._dict[attr]
 
+    def __delattr__(self, attr):
+        if attr not in self._dict:
+            return
+        del self._dict[attr]
+
     def clear(self):
         self._dict.clear()
 
@@ -226,6 +231,9 @@ def __setattr__(self, attr, value):
             return super(OptionsValues, self).__setattr__(attr, value)
         return setattr(self._package_values, attr, value)
 
+    def __delattr__(self, attr):
+        delattr(self._package_values, attr)
+
     def clear_indirect(self):
         for v in self._reqs_options.values():
             v.clear()


Test patch:
diff --git a/conans/test/functional/package_id_test.py b/conans/test/functional/package_id_test.py
--- a/conans/test/functional/package_id_test.py
+++ b/conans/test/functional/package_id_test.py
@@ -1,7 +1,34 @@
 import unittest
 from conans.test.utils.tools import TestClient, TestServer
 
+
 class PackageIdTest(unittest.TestCase):
+    def remove_option_setting_test(self):
+        # https://github.com/conan-io/conan/issues/2826
+        conanfile = """from conans import ConanFile
+
+class TestConan(ConanFile):
+    settings = "os"
+    options = {"opt": [True, False]}
+    default_options = "opt=False"
+
+    def package_id(self):
+        self.output.info("OPTION OPT=%s" % self.info.options.opt)
+        del self.info.settings.os
+        del self.info.options.opt
+"""
+        client = TestClient()
+        client.save({"conanfile.py": conanfile})
+        client.run("create . Pkg/0.1@user/testing -s os=Windows")
+        self.assertIn("Pkg/0.1@user/testing: OPTION OPT=False", client.out)
+        self.assertIn("Pkg/0.1@user/testing: Package "
+                      "'5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' created",
+                      client.out)
+        client.run("create . Pkg/0.1@user/testing -s os=Linux -o Pkg:opt=True")
+        self.assertIn("Pkg/0.1@user/testing: OPTION OPT=True", client.out)
+        self.assertIn("Pkg/0.1@user/testing: Package "
+                      "'5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' created",
+                      client.out)
 
     def value_parse_test(self):
         # https://github.com/conan-io/conan/issues/2816