diff --git a/README.md b/README.md index bff82b64a8..0f2f66fffd 100644 --- a/README.md +++ b/README.md @@ -97,11 +97,12 @@ git clone https://github.com/htm-community/htm.core 2) At a command prompt, `cd` to the root directory of this repository. -3) Run: `python setup.py install --user --force` +3) Run: `pip install . --user --force` This will build and install a release version of htm.core. The `--user` option prevents the system installed site-packages folder from being changed and avoids the need for admin privileges. The `--force` option forces the package to be replaced if it already exists from a previous build. Alternatively you can type `pip uninstall htm.core` to remove a previous package before performing a build. * If you are using `virtualenv` you may not need the --user or --force options. + * If you are using a uv virtual environment then you only need to run: `uv pip install .` * If you are using Anaconda Python you must run within the `Anaconda Prompt` on Windows. Do not use --user or --force options. * If you run into problems due to caching of arguments in CMake, delete the @@ -439,8 +440,10 @@ You should run tests locally, and tests are also run as a part of the CI. There are two sets (somewhat duplicit) tests for c++ and python. * C++ Unit tests -- to run: `./build/Release/bin/unit_tests` - * Python Unit tests -- to run: `python setup.py test` (runs also the C++ tests above) - - `py/tests/` + * Python Unit tests -- to run + 1. Run `pytest ./py` + 2. Run `pytest ./bindings` + - `bindings/py/tests/` diff --git a/bindings/py/tests/sdr/SDR_test.py b/bindings/py/tests/sdr/SDR_test.py index dd5aacac73..0dd5eb7e30 100644 --- a/bindings/py/tests/sdr/SDR_test.py +++ b/bindings/py/tests/sdr/SDR_test.py @@ -444,7 +444,7 @@ def testSparsity(self): seed += 1 sdrs.append( inp ) X.intersection( sdrs ) - mean_sparsity = np.product( sparsities ) + mean_sparsity = np.prod( sparsities ) assert( X.getSparsity() >= (2./3.) * mean_sparsity ) assert( X.getSparsity() <= (4./3.) * mean_sparsity ) @@ -499,7 +499,7 @@ def testSparsity(self): seed += 1 sdrs.append( inp ) X.union( sdrs ) - mean_sparsity = np.product(list( 1 - s for s in sparsities )) + mean_sparsity = np.prod(list( 1 - s for s in sparsities )) assert( X.getSparsity() >= (2./3.) * (1 - mean_sparsity) ) assert( X.getSparsity() <= (4./3.) * (1 - mean_sparsity) ) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..7158438033 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[project] +name = "htm.core" +version = "2.1.16" +description = "This is a Community Fork of the nupic.core" +readme = "README.md" +requires-python = ">=3" +dependencies = [ + "numpy", + "hexy", + "pybind11", + "pytest-cov", + "hexy", + "mock", + "cmake", + "requests", + "prettytable", + "setuptools>=75.8.0", +] + +[build-system] +requires = ["setuptools", "cmake"] diff --git a/requirements.txt b/requirements.txt index 126593610d..6f2ec40f4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ pip>=22.3.1 wheel>=0.38.4 cmake>=3.14 #>=3.7, >=3.14 needed for MSVC 2019, >=3.21 needed for MSVC 2022 ## for python bindings (in /bindings/py/) -numpy==1.23 # For a newer numpy such as V2.x, you must be running at least Python 3.9 +numpy # For a newer numpy such as V2.x, you must be running at least Python 3.9 pytest>=4.6.5 #4.6.x series is last to support python2, once py2 dropped, we can switch to 5.x ## for python code (in /py/) hexy>=1.4.4 # for grid cell encoder diff --git a/setup.cfg b/setup.cfg index 4fe31a8d04..c7157a39e3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,6 +20,17 @@ description-file = README.md [build_ext] inplace=1 +[options] +install_requires = + numpy + pybind11 + pytest-cov + hexy + mock + cmake + requests + prettytable + [tool:pytest] # NOTE the ci builds rely on these settings addopts = diff --git a/setup.py b/setup.py index d65fd99b08..c1810afe80 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,6 @@ import json from setuptools import Command, find_packages, setup -from setuptools.command.test import test as BaseTestCommand # see https://stackoverflow.com/questions/44323474/distutils-core-vs-setuptools-with-c-extension from setuptools import Extension from pathlib import Path @@ -146,52 +145,6 @@ def findRequirements(platform, fileName="requirements.txt"): ] - -class TestCommand(BaseTestCommand): - user_options = [("pytest-args=", "a", "Arguments to pass to py.test")] - - - def initialize_options(self): - BaseTestCommand.initialize_options(self) - self.pytest_args = [] # pylint: disable=W0201 - - - def finalize_options(self): - BaseTestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - - def run_tests(self): - import pytest - cwd = os.getcwd() - errno = 0 - os.chdir(REPO_DIR) - # run c++ tests (from python) - cpp_tests = os.path.join(REPO_DIR, "build", "Release", "bin", "unit_tests") - subprocess.check_call([cpp_tests]) - os.chdir(cwd) - - - # run python bindings tests (in /bindings/py/tests/) - try: - os.chdir(os.path.join(REPO_DIR, "bindings", "py","tests")) - errno = pytest.main(self.pytest_args) - finally: - os.chdir(cwd) - if errno != 0: - sys.exit(errno) - - # python tests (in /py/tests/) - try: - os.chdir(os.path.join(REPO_DIR, "py", "tests")) - errno = pytest.main(self.pytest_args) - finally: - os.chdir(cwd) - sys.exit(errno) - - - def getPlatformInfo(): """Identify platform.""" if "linux" in sys.platform: @@ -206,7 +159,6 @@ def getPlatformInfo(): return platform - def getExtensionFileNames(platform, build_type): # look for extension libraries in Repository/build/Release/distr/src/htm/bindings # library filenames: @@ -451,7 +403,6 @@ def configure(platform, build_type): zip_safe=False, cmdclass={ "clean": CleanCommand, - "test": TestCommand, "configure": ConfigureCommand, }, author="Numenta & HTM Community",