diff --git a/.github/workflows/pull-request-closed.yml b/.github/workflows/pull-request-closed.yml index c149744f76..1603633e2b 100644 --- a/.github/workflows/pull-request-closed.yml +++ b/.github/workflows/pull-request-closed.yml @@ -92,10 +92,10 @@ jobs: - name: "Create virtual Environment" run: python3 -m venv .venv - - name: "Install wheel and conan package" + - name: "Install -r requirements_dev.txt" run: | source .venv/bin/activate - pip3 install wheel conan cmake + pip3 install cmake -r requirements_dev.txt - name: "Build basilisk with OpNav" run: source .venv/bin/activate && python3 conanfile.py --opNav True --allOptPkg diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fa98fdb3cb..d85eeb5b95 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -43,7 +43,7 @@ jobs: run: | python3 -m venv .venv source .venv/bin/activate - pip install wheel conan + pip install -r requirements_dev.txt - name: Build basilisk run: | source .venv/bin/activate @@ -78,8 +78,8 @@ jobs: run: sudo apt-get install python3-setuptools python3-tk python3.10-venv - name: "Create virtual Environment" run: python3 -m venv .venv - - name: "Install wheel and conan package" - run: source .venv/bin/activate && pip3 install wheel conan + - name: "Install requirements_dev.txt" + run: source .venv/bin/activate && pip3 install -r requirements_dev.txt - name: "Build basilisk" run: source .venv/bin/activate && python3 conanfile.py - name: "Run Python Tests" @@ -113,10 +113,10 @@ jobs: run: sudo apt-get install python3-setuptools python3-tk python3.11-venv - name: "Create virtual Environment" run: python3 -m venv .venv - - name: "Install wheel and conan package" - run: source .venv/bin/activate && pip3 install wheel conan + - name: "Install requirements_dev.txt" + run: source .venv/bin/activate && pip3 install -r requirements_dev.txt - name: "Build basilisk" - run: source .venv/bin/activate && python3 conanfile.py --opNav True + run: source .venv/bin/activate && python3 conanfile.py --opNav True --allOptPkg - name: "Run Python Tests" run: | @@ -156,6 +156,7 @@ jobs: - name: "Run Python Tests" run: | source .venv/bin/activate + pip install pytest pytest-xdist cd src && pytest -n auto -m "not ciSkip" @@ -184,11 +185,11 @@ jobs: - name: "Create python virtual env" shell: pwsh run: python -m venv venv - - name: "Install wheel and conan package" + - name: "Install requirements_dev.txt" shell: pwsh run: | venv\Scripts\activate - pip install wheel conan + pip install -r requirements_dev.txt - name: "Add basilisk and cmake path to env path" shell: pwsh run: | @@ -199,7 +200,7 @@ jobs: shell: pwsh run: | venv\Scripts\activate - python conanfile.py --opNav True + python conanfile.py --opNav True --allOptPkg - name: "Run Python Tests" shell: pwsh run: | @@ -237,10 +238,10 @@ jobs: - name: "Create virtual Environment" run: python3 -m venv .venv - - name: "Install wheel and conan package" + - name: "Install requirements_dev.txt" run: | source .venv/bin/activate - pip3 install wheel conan cmake + pip3 install cmake -r requirements_dev.txt - name: "Build basilisk with OpNav" run: source .venv/bin/activate && python3 conanfile.py --opNav True --allOptPkg @@ -284,10 +285,10 @@ jobs: - name: "Create virtual Environment" run: python3 -m venv .venv - - name: "Install wheel and conan package" + - name: "Install requirements_dev.txt" run: | source .venv/bin/activate - pip3 install wheel conan cmake + pip3 install cmake -r requirements_dev.txt - name: "Build basilisk without vizInterface" run: source .venv/bin/activate && python3 conanfile.py --vizInterface False diff --git a/conanfile.py b/conanfile.py index 7f01f209a1..309db948d7 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,7 +6,8 @@ import sys from datetime import datetime -import pkg_resources +import importlib.metadata +from packaging.requirements import Requirement from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps @@ -121,20 +122,15 @@ def system_requirements(self): required = reqFile.read().replace("`", "").split('\n') reqFile.close() pkgList = [x.lower() for x in required] - pkgList += [ - # Also install build system requirements. - # TODO: Read these from the `pyproject.toml` file directly? - # NOTE: These are *NOT* runtime requirements and should *NOT* be in `requirements.txt`! - "conan>=2.0.5", - "setuptools>=70.1.0", - "setuptools-scm>=8.0", - "packaging>=22", - "cmake>=3.26", - ] + + reqFile = open('requirements_dev.txt', 'r') + required = reqFile.read().replace("`", "").split('\n') + reqFile.close() + pkgList += [x.lower() for x in required] checkStr = "Required" if self.options.get_safe("allOptPkg"): - optFile = open('requirements_optional.txt', 'r') + optFile = open('requirements_doc.txt', 'r') optionalPkgs = optFile.read().replace("`", "").split('\n') optFile.close() optionalPkgs = [x.lower() for x in optionalPkgs] @@ -144,15 +140,25 @@ def system_requirements(self): print("\nChecking " + checkStr + " Python packages:") missing_packages = [] for elem in pkgList: + if not elem: # Skip empty or falsy elements + continue + try: - # TODO: pkg_resources is deprecated, but its replacement - # importlib does not provide a way to check for installed - # packages given a version specifier (e.g. "numpy<2")... - # NOTE: pkg_resources stops working if we upgrade "setuptools", - # so check all packages here first, then upgrade below. - pkg_resources.require(elem) - print("Found: " + statusColor + elem + endColor) - except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict): + # Parse the requirement (e.g., "numpy<2") + req = Requirement(elem) + # Get the installed version of the package + installed_version = importlib.metadata.version(req.name) + + # Check if the installed version satisfies the requirement + if req.specifier.contains(installed_version): + print("Found: " + statusColor + elem + endColor) + else: + raise Exception( + f"Version conflict for {req.name}: {installed_version} does not satisfy {req.specifier}") + except importlib.metadata.PackageNotFoundError: + missing_packages.append(elem) + except Exception as e: + print(f"Error: {e}") missing_packages.append(elem) for elem in missing_packages: diff --git a/docs/source/Install.rst b/docs/source/Install.rst index b8533b573f..c91febc6fd 100644 --- a/docs/source/Install.rst +++ b/docs/source/Install.rst @@ -18,7 +18,6 @@ Install Install/installOnWindows Install/installBuild Install/buildExtModules - Install/installOptionalPackages Install/customPython Install/installBuildConan Install/pipInstall diff --git a/docs/source/Install/installBuild.rst b/docs/source/Install/installBuild.rst index f02abf454c..d53d501b7e 100644 --- a/docs/source/Install/installBuild.rst +++ b/docs/source/Install/installBuild.rst @@ -91,7 +91,7 @@ The script accepts the following options to customize this process. * - ``allOptPkg`` - - None - - If flag is set the all optional Basilisk python package depenencies are installed + - If flag is set the Basilisk python package depenencies to build documentation are installed * - ``pathToExternalModules`` - String - Empty @@ -138,8 +138,7 @@ To run all tests execute the following from the project root directory python run_all_test.py -To run only the python test use the following commands. Please see :ref:`installOptionalPackages` on how to -run an optional multi-processing version of ``pytest``. +To run only the python test use the following commands. .. code-block:: console diff --git a/docs/source/Install/installOnLinux.rst b/docs/source/Install/installOnLinux.rst index 0b5d3944cb..bc5b5b95dd 100644 --- a/docs/source/Install/installOnLinux.rst +++ b/docs/source/Install/installOnLinux.rst @@ -109,9 +109,9 @@ Dependencies (venv) $ deactivate -#. Ensure ``wheel`` is installed and install ``conan`` using pip, an example is below:: +#. Ensure all build related pip packages are installed:: - (venv) $ pip3 install wheel conan + (venv) $ pip3 install -r requirements_dev.txt The ``conan`` repositories information is automatically setup by ``conanfile.py``. @@ -124,7 +124,6 @@ Dependencies local in your user directory ``.local`` folder, be sure to add ``~/.local/bin`` to your ``PATH`` variable. -#. `Optional Packages:` The above directions install the Basilisk base software. There are a series of :ref:`optional packages` that enhance this capability. Build Process via Terminal -------------------------- diff --git a/docs/source/Install/installOnMacOS.rst b/docs/source/Install/installOnMacOS.rst index 587d52da57..c91c56f805 100644 --- a/docs/source/Install/installOnMacOS.rst +++ b/docs/source/Install/installOnMacOS.rst @@ -118,17 +118,14 @@ steps work regardless if done within a virtual environment or not. Installing required python support packages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #. Basilisk uses ``conan`` for package managing. In order to do so, users - must ensure ``wheel`` is installed and install ``conan``:: + must first install all build related pip packages using:: - (.venv) $ pip3 install wheel conan + (.venv) $ pip3 install -r requirements_dev.txt The ``conan`` repositories information is automatically setup by ``conanfile.py``. #. The required python packages for Basilisk will be installed automatically when running ``conanfile.py``. -#. `Optional Packages:` The above directions install the Basilisk base software. - There are a series of :ref:`optional packages` that enhance this capability. - Build Project Process via Terminal ---------------------------------- diff --git a/docs/source/Install/installOnWindows.rst b/docs/source/Install/installOnWindows.rst index f1857d35b2..9bb4937f5f 100644 --- a/docs/source/Install/installOnWindows.rst +++ b/docs/source/Install/installOnWindows.rst @@ -124,9 +124,9 @@ Installing required python support packages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #. Basilisk uses conan for package managing. In order to do so, users - must ensure ``wheel`` is installed and install ``conan``:: + must first install all build related pip packages using:: - (venv) $ pip install wheel conan + (venv) $ pip install -r requirements_dev.txt The ``conan`` repositories information is automatically setup by ``conanfile.py``. @@ -137,8 +137,6 @@ Installing required python support packages #. The required python packages for Basilisk will be installed automatically when running ``conanfile.py``. -#. `Optional Packages:` The above directions install the Basilisk base software. - There are a series of :ref:`optional packages` that enhance this capability. Build Project Process via Command line -------------------------------------- diff --git a/docs/source/Install/installOptionalPackages.rst b/docs/source/Install/installOptionalPackages.rst deleted file mode 100644 index f8059c4450..0000000000 --- a/docs/source/Install/installOptionalPackages.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. toctree:: - :hidden: - - - -.. raw:: html - - - -.. _installOptionalPackages: - -Installing Optional Packages -============================ - -This page contains all the optional python packages that can be included to unlock additional Basilisk -features or utilities. For convenience the complete set of optional packages, including any constraints on -acceptable versions, are listed here: - -.. literalinclude:: ../../../requirements_optional.txt - :language: python - -To automatically ensure that the system has all optional packages installed, use the ``allOptPkg`` -flag as discussed in :ref:`configureBuild`. - - -Creating the Sphinx Basilisk Documentation ------------------------------------------- -Go to :ref:`createHtmlDocumentation` to learn what associated python tools are required. -The following python packages must be installed via ``pip``:: - - pip3 install sphinx sphinx_rtd_theme breathe recommonmark docutils - -See the list at the top of this page for what versions of these packages are acceptable. - - -Formatting Code Files using ``pre-commit`` and ``clang-format`` ---------------------------------------------------------------- -If you are developing new code to contribute back to Basilisk it must follow the -:ref:`codingGuidelines`. This requires installing:: - - pip3 install pre-commit clang-format - -The file `CONTRIBUTING.md `__ -explains how to setup and use these code formating tools. diff --git a/docs/source/Support/Developer.rst b/docs/source/Support/Developer.rst index 0fe8f573be..b1720eee3b 100644 --- a/docs/source/Support/Developer.rst +++ b/docs/source/Support/Developer.rst @@ -13,6 +13,7 @@ The following support files help with writing Basilisk modules. Developer/deprecatingCode Developer/makingNewBskModule Developer/addSphinxDoc + Developer/createHtmlDocumentation Developer/bskModuleCheckoutList Developer/UnderstandingBasilisk Developer/migratingBskModuleToBsk2 diff --git a/docs/source/Support/Developer/CodingGuidlines.rst b/docs/source/Support/Developer/CodingGuidlines.rst index 0a489e9b7d..b0d2574474 100644 --- a/docs/source/Support/Developer/CodingGuidlines.rst +++ b/docs/source/Support/Developer/CodingGuidlines.rst @@ -255,3 +255,10 @@ followed by the path to where to generate the report html folder. It is recomme this inside a folder as HTML support folder will be created:: $ pytest --html report/report.html + +Formatting Code Files using ``pre-commit`` and ``clang-format`` +--------------------------------------------------------------- +If you are developing new code to contribute back to Basilisk it must follow the +:ref:`codingGuidelines`. This requires using the ``pre-commit`` and ``clang-format`` +packages. The file `CONTRIBUTING.md `__ +explains how to setup and use these code formating tools. diff --git a/docs/source/Support/Developer/bskModuleCheckoutList.rst b/docs/source/Support/Developer/bskModuleCheckoutList.rst index afaa33af48..b8e5004516 100644 --- a/docs/source/Support/Developer/bskModuleCheckoutList.rst +++ b/docs/source/Support/Developer/bskModuleCheckoutList.rst @@ -1,7 +1,7 @@ .. _bskModuleCheckoutList: -Basilisk Module Checkout List +Basilisk Module Checkout List ============================= This documents contains a series of action items that should be checked @@ -17,7 +17,7 @@ Building Basilisk and Testing - Do a clean build of Basilisk and make sure all code compiles as expected (see :ref:`FAQ ` on how to do a clean build) - From the project root directory, run ``python run_all_test.py`` and ensure all python and C/C++ tests are passing - as expected (see :ref:`installOptionalPackages` for info on installing and running ``pytest``) + as expected Style and Formatting -------------------- @@ -91,4 +91,4 @@ See the :ref:`FAQ ` on how to run generate an html validation report using Update Release Notes -------------------- -Update the :ref:`bskReleaseNotes` at ``/docs/source/Support/User/bskReleaseNotes.rst`` to include information about the new features being added. \ No newline at end of file +Update the :ref:`bskReleaseNotes` at ``/docs/source/Support/User/bskReleaseNotes.rst`` to include information about the new features being added. diff --git a/docs/source/Support/User/createHtmlDocumentation.rst b/docs/source/Support/Developer/createHtmlDocumentation.rst similarity index 93% rename from docs/source/Support/User/createHtmlDocumentation.rst rename to docs/source/Support/Developer/createHtmlDocumentation.rst index 7e02323f13..b1c3269b2b 100644 --- a/docs/source/Support/User/createHtmlDocumentation.rst +++ b/docs/source/Support/Developer/createHtmlDocumentation.rst @@ -7,7 +7,7 @@ Creating the HTML Basilisk Documentation using Sphinx/Doxygen Documentation Description ------------------------- The `Sphinx `__ and `Doxygen `__ software packages provide an elegant method to both include code explanations, definitions and module documentation, but also to create a full HTML based documentation folder for a software project. An online copy of this HTML documentation is hosted at `AVS Basilisk web site `__ with the `Documentation `__ page. - + .. image:: /_images/static/bskHTML.png :align: center @@ -21,7 +21,9 @@ convenient method to install Doxygen by typing in the terminal:: brew install doxygen -See :ref:`installOptionalPackages` to learn what python packages must be installed. +To install the required python packages run the command:: + + pip install -r requirements_doc.txt Making the HTML Documentation Folder ------------------------------------ @@ -29,7 +31,7 @@ First generate the test plots:: cd src - pytest + pytest -n auto Next, in a terminal window switch to the ``docs`` folder:: @@ -48,4 +50,3 @@ To open the HTML index file and view the documentation in the browser use:: To clean out the sphinx generated documents and folder use:: make clean - diff --git a/docs/source/Support/User.rst b/docs/source/Support/User.rst index 7820e36d67..0fd25429d3 100644 --- a/docs/source/Support/User.rst +++ b/docs/source/Support/User.rst @@ -11,9 +11,4 @@ The following support documents are for the Basilisk user who is seeking general User/FAQ User/FAQwindows - User/createHtmlDocumentation User/migratingToBsk2 - - - - diff --git a/docs/source/Support/User/FAQ.rst b/docs/source/Support/User/FAQ.rst index 1a7daa2dc1..415fa66cc4 100644 --- a/docs/source/Support/User/FAQ.rst +++ b/docs/source/Support/User/FAQ.rst @@ -12,7 +12,9 @@ The following Frequency Answer Questions are general and not operating system sp #. How do I run ``pytest`` to ensure all unit and integrated tests still pass - The following response assumes you have the Basilisk soure code. You need to install the python utility ``pytest`` if this is not available on your system. Instructions are found at :ref:`installOptionalPackages`. Next, navigate to the folder ``Basilisk\src`` and run ``pytest`` from there. + The following response assumes you have the Basilisk source code. You ensure the python utility ``pytest``. + It is installed in the setup process using ``requirements_dev.txt``. Next, navigate to the folder ``Basilisk\src`` + and run ``pytest`` from there. #. How can I run ``pytest`` faster? @@ -29,10 +31,10 @@ The following Frequency Answer Questions are general and not operating system sp or replace `8` with either the number of processors (virtual or otherwise) of your host machine, or "auto" to use all available processors. -#. How can I used ``pytest`` to generate a Basilisk validation HTML report? +#. How can I use ``pytest`` to generate a Basilisk validation HTML report? - You will need to install ``pytest-html`` package, see :ref:`installOptionalPackages`. Then you - can do this with:: + You will need to install ``pytest-html`` package which is installed in the setup process using ``requirements_dev.txt``. + Then you can do this with:: python3 -m pytest --report diff --git a/docs/source/Support/User/FAQwindows.rst b/docs/source/Support/User/FAQwindows.rst index a5746e5564..43606b7515 100644 --- a/docs/source/Support/User/FAQwindows.rst +++ b/docs/source/Support/User/FAQwindows.rst @@ -12,7 +12,7 @@ The following Frequency Answer Questions are specific for the Microsoft Windows It is recommended to run the ``pytest-xdist`` version which allows multi-threaded executions using ``pytest -n 8`` - for 8 threads, for example. See :ref:`installOptionalPackages` for more information on installing ``pytest-xdist``. + for 8 threads, for example. This package is installed in the setup process using ``requirements_dev.txt``. #. I have upgraded to Basilisk version 1.8.0 or newer and I'm following the revised build process. However, I'm seeing warnings in the terminal window saying I don't have the correct python packages installed @@ -21,4 +21,4 @@ The following Frequency Answer Questions are specific for the Microsoft Windows You are likely installed ``conan`` using the binary download link from the conan web site. This installs a self-contained binary, including it's own copy of Python. With 1.8.0 and higher it is recommended to avoid installing the conan binary and using ``pip install conan`` instead. This ensures that the conan, - and associated support packages, are installed for the particular version of python that you want to run. \ No newline at end of file + and associated support packages, are installed for the particular version of python that you want to run. diff --git a/docs/source/Support/bskReleaseNotes.rst b/docs/source/Support/bskReleaseNotes.rst index 1dd9dc6a21..5ead0122d7 100644 --- a/docs/source/Support/bskReleaseNotes.rst +++ b/docs/source/Support/bskReleaseNotes.rst @@ -79,6 +79,10 @@ Version |release| the added setters and getters must be used. - Fixed a bug in which the ``MtbEffector.py`` module was not being imported correctly in Python due to lack of ``swig_eigen.i`` include file in ``MtbEffector.i``. +- Cleaned up what python packages are required to build BSK (``requirements_dev.txt``), + to run BSK (``requirements.txt``) and to build BSK documentation (``requirements_doc.txt``). +- The BSK install instructions are updated to ask users to install by first ``pip`` installing build + required packages through ``requirements_dev.txt``. - Update the build process to use ``conan`` version 2.x .. warning:: @@ -542,7 +546,7 @@ Version 2.1.3 (May 25, 2022) - added new :ref:`scenarioAerocapture` which simulates an aerocapture scenario - added new :ref:`hingedBodyLinearProfiler` to provide a panel deployment angular profile - added new :ref:`hingedRigidBodyMotor` to provide panel motor torque control -- added new training videos to :ref:`configureBuild`, :ref:`installOptionalPackages`, :ref:`scenarioBasicOrbit`, +- added new training videos to :ref:`configureBuild`, installOptionalPackages, :ref:`scenarioBasicOrbit`, :ref:`scenarioOrbitManeuver`, :ref:`scenarioOrbitMultiBody`, :ref:`scenarioCustomGravBody` - added support for Vizard 2.1 scripting diff --git a/examples/MonteCarloExamples/scenarioVisualizeMonteCarlo.py b/examples/MonteCarloExamples/scenarioVisualizeMonteCarlo.py index 2e8b9afe8d..c778f96762 100644 --- a/examples/MonteCarloExamples/scenarioVisualizeMonteCarlo.py +++ b/examples/MonteCarloExamples/scenarioVisualizeMonteCarlo.py @@ -64,17 +64,6 @@ This approach allows for smooth interaction with large datasets that would be impractical to plot all at once using traditional plotting libraries. -Configuring a Python Environment For this Script ------------------------------------------------- -To run this script, you need to set up a specific Python environment: - -#. Ensure Basilisk is compiled for the Python environment you are using. -#. Either compile Basilisk with the optional dependencies already installed, - or install them manually using:: - - pip install -r requirements_optional.txt - -This will install Bokeh and other optional dependencies needed for this script. How to Run the Script --------------------- diff --git a/pyproject.toml b/pyproject.toml index a8d6e72246..89bddb0e37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ requires = [ [project] name = 'Basilisk' -dynamic = ["version", "dependencies", "optional-dependencies"] +dynamic = ["version", "dependencies"] requires-python = ">=3.8, <3.12" readme = "README.md" @@ -51,7 +51,3 @@ Basilisk = [ [tool.setuptools.dynamic] version = {file = "docs/source/bskVersion.txt"} dependencies = {file = "requirements.txt"} - -[tool.setuptools.dynamic.optional-dependencies] -# TODO: Group optional requirements appropriately, e.g. "test", "docs" -optional = {file = "requirements_optional.txt"} diff --git a/requirements.txt b/requirements.txt index ab0bd49720..05436dd848 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,9 @@ pandas -matplotlib +matplotlib<3.10.0 numpy colorama tqdm Pillow -pytest -pytest-html -pytest-xdist requests +bokeh +protobuf==5.27.0 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000000..296298b28a --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,12 @@ +wheel +conan>2.0.5 +packaging>=22 +setuptools>=70.1.0 +setuptools-scm>=8.0 + +pytest +pytest-html +pytest-xdist + +pre-commit +clang-format diff --git a/requirements_optional.txt b/requirements_doc.txt similarity index 54% rename from requirements_optional.txt rename to requirements_doc.txt index 8a17e55473..2e8a8fb3cb 100644 --- a/requirements_optional.txt +++ b/requirements_doc.txt @@ -3,8 +3,3 @@ docutils recommonmark sphinx>7.0.0 sphinx_rtd_theme>=3.0.0 -pre-commit -clang-format -bokeh -dask-expr -protobuf==5.27.0