Skip to content

Commit

Permalink
Merge pull request #871 from AVSLab/feature/requirements_update
Browse files Browse the repository at this point in the history
Clean up requirements.txt file(s)
  • Loading branch information
schaubh authored Dec 15, 2024
2 parents 50184a6 + e91a741 commit d00375e
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 139 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull-request-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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: |
Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
46 changes: 26 additions & 20 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion docs/source/Install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Install
Install/installOnWindows
Install/installBuild
Install/buildExtModules
Install/installOptionalPackages
Install/customPython
Install/installBuildConan
Install/pipInstall
5 changes: 2 additions & 3 deletions docs/source/Install/installBuild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions docs/source/Install/installOnLinux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand All @@ -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<installOptionalPackages>` that enhance this capability.

Build Process via Terminal
--------------------------
Expand Down
7 changes: 2 additions & 5 deletions docs/source/Install/installOnMacOS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<installOptionalPackages>` that enhance this capability.

Build Project Process via Terminal
----------------------------------

Expand Down
6 changes: 2 additions & 4 deletions docs/source/Install/installOnWindows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand All @@ -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<installOptionalPackages>` that enhance this capability.

Build Project Process via Command line
--------------------------------------
Expand Down
44 changes: 0 additions & 44 deletions docs/source/Install/installOptionalPackages.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/source/Support/Developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/source/Support/Developer/CodingGuidlines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/AVSLab/basilisk/blob/develop/CONTRIBUTING.md>`__
explains how to setup and use these code formating tools.
6 changes: 3 additions & 3 deletions docs/source/Support/Developer/bskModuleCheckoutList.rst
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <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
--------------------
Expand Down Expand Up @@ -91,4 +91,4 @@ See the :ref:`FAQ <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.
Update the :ref:`bskReleaseNotes` at ``/docs/source/Support/User/bskReleaseNotes.rst`` to include information about the new features being added.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Creating the HTML Basilisk Documentation using Sphinx/Doxygen
Documentation Description
-------------------------
The `Sphinx <https://pypi.org/project/Sphinx/>`__ and `Doxygen <http://doxygen.nl>`__ 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 <http://hanspeterschaub.info/bskMain.html>`__ with the `Documentation <http://hanspeterschaub.info/bskHtml/index.html>`__ page.

.. image:: /_images/static/bskHTML.png
:align: center

Expand All @@ -21,15 +21,17 @@ 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
------------------------------------
First generate the test plots::

cd src

pytest
pytest -n auto

Next, in a terminal window switch to the ``docs`` folder::

Expand All @@ -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

5 changes: 0 additions & 5 deletions docs/source/Support/User.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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




Loading

0 comments on commit d00375e

Please sign in to comment.