fvutils/pyvsc

Installing pyvsc fails on pyboolector for python 3.11.5 on Linux (Arch)

Closed this issue · 3 comments

Arch linux upgraded to python 3.11 back in April '23. I think the pyboolector pypi package is only built up to 3.10 currently.

Anything I can do to help? I attempted to build the pypi package in the boolector project, but I don't know enough about python packages. I can get Boolector and the python API to build, but getting the package built seems like a different challenge.

Originally posted here back in May: Boolector/boolector#207

Output:

$ pip install pyboolector --no-cache-dir
Defaulting to user installation because normal site-packages is not writeable
Collecting pyboolector
  Downloading PyBoolector-3.2.2.20230110.4.tar.gz (21 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-em418vya/pyboolector_2016934fc25f453282301a41a5aa8881/setup.py", line 14, in <module>
          with open(cmakelists_txt, "r") as f:
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-em418vya/CMakeLists.txt'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
$ python -V
Python 3.11.5

Currently I can get around things with the pyboolector.so library I built by running:

PYTHONPATH=/boolector/build/lib python ./test.py

Hi @alwilson, appreciate the heads-up on this. I've created a PR on the Boolector project to support for 3.11 and 3.12. You can find that here:
Boolector/boolector#211

Also, there are some minor unit test regressions due to 3.11. Coverpoint bin names use str() to get the enum name, but it looks like that now returns the enum value instead. Also, some uses of random.sample() hit a type error now that wants the population arg to be a sequence. Here's some quick fixes I made, not sure if it works for 3.10 though and not sure about the enum workaround since it doesn't return the enum instance name as well.

diff --git a/src/vsc/coverage.py b/src/vsc/coverage.py
index 2567db6..55ae833 100644
--- a/src/vsc/coverage.py
+++ b/src/vsc/coverage.py
@@ -820,7 +820,7 @@ class coverpoint(object):
 
                         for v in enum_bins.range_l:                        
                             e = ei.v2e_m[v[0]]
-                            self.model.add_bin_model(CoverpointBinEnumModel(str(e), v[0]))
+                            self.model.add_bin_model(CoverpointBinEnumModel(e.name, v[0]))
                             
                     elif isinstance(self.cp_t, type_base):
                         binspec = RangelistModel()
diff --git a/src/vsc/model/coverpoint_cross_model.py b/src/vsc/model/coverpoint_cross_model.py
index ff387b9..3776aef 100644
--- a/src/vsc/model/coverpoint_cross_model.py
+++ b/src/vsc/model/coverpoint_cross_model.py
@@ -93,7 +93,7 @@ class CoverpointCrossModel(CoverItemBase):
     
     def select_unhit_bin(self, r:RandIF)->int:
         if len(self.unhit_s) > 0:
-            return random.sample(self.unhit_s, 1)[0]
+            return random.sample(sorted(self.unhit_s), 1)[0]
         else:
             return -1
 
diff --git a/src/vsc/model/rand_info_builder.py b/src/vsc/model/rand_info_builder.py
index b661b4f..5b16be7 100644
--- a/src/vsc/model/rand_info_builder.py
+++ b/src/vsc/model/rand_info_builder.py
@@ -159,7 +159,7 @@ class RandInfoBuilder(ModelVisitor,RandIF):
         return self._rng.randint(low,high)
     
     def sample(self, s, k):
-        return self._rng.sample(s, k)
+        return self._rng.sample(sorted(s), k)
     
     def visit_constraint_block(self, c):
         if RandInfoBuilder.EN_DEBUG:
diff --git a/ve/unit/test_coverage_driven_constraints.py b/ve/unit/test_coverage_driven_constraints.py
index 7921623..a22701d 100644
--- a/ve/unit/test_coverage_driven_constraints.py
+++ b/ve/unit/test_coverage_driven_constraints.py
@@ -24,7 +24,7 @@ class TestCoverageDrivenConstraints(VscTestCase):
                 return low
     
             def sample(self, s, k):
-                return random.sample(s, k)
+                return random.sample(sorted(s), k)
         
         
         @vsc.randobj
diff --git a/ve/unit/test_coverage_enum.py b/ve/unit/test_coverage_enum.py
index abf911a..6f97f99 100644
--- a/ve/unit/test_coverage_enum.py
+++ b/ve/unit/test_coverage_enum.py
@@ -31,8 +31,8 @@ class TestCoverageEnum(VscTestCase):
         v = my_e.B
         cg.sample()
         
-        self.assertEqual(cg.cp.get_model().get_bin_name(0), "my_e.A")
-        self.assertEqual(cg.cp.get_model().get_bin_name(1), "my_e.B")
+        self.assertEqual(cg.cp.get_model().get_bin_name(0), "A")
+        self.assertEqual(cg.cp.get_model().get_bin_name(1), "B")
 
 #     def test_bin_names_enum(self):
 #         
@@ -81,10 +81,10 @@ class TestCoverageEnum(VscTestCase):
         v = my_e.D
         cg.sample()
         
-        self.assertEqual(cg.cp.get_model().get_bin_name(0), "my_e.A")
-        self.assertEqual(cg.cp.get_model().get_bin_name(1), "my_e.B")                
-        self.assertEqual(cg.cp.get_model().get_bin_name(2), "my_e.C")
-        self.assertEqual(cg.cp.get_model().get_bin_name(3), "my_e.D")                
+        self.assertEqual(cg.cp.get_model().get_bin_name(0), "A")
+        self.assertEqual(cg.cp.get_model().get_bin_name(1), "B")
+        self.assertEqual(cg.cp.get_model().get_bin_name(2), "C")
+        self.assertEqual(cg.cp.get_model().get_bin_name(3), "D")
         self.assertEqual(cg.cp.get_coverage(), 100)

That PR went through and pyboolector installs fine now. Sounds like they'll be fixing up some other version issues in the next release. Thanks @mballance!