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

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

Closed
alwilson opened this issue Sep 2, 2023 · 3 comments
Closed

Comments

@alwilson
Copy link
Contributor

alwilson commented Sep 2, 2023

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
@mballance
Copy link
Member

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

@alwilson
Copy link
Contributor Author

alwilson commented Sep 3, 2023

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)

@alwilson
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants