diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd93184..7f6faf4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9', '3.10', '3.12'] steps: - name: Checkout repository uses: actions/checkout@v3 @@ -12,12 +15,11 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt pip install -e . pip install -e ".[tests]" diff --git a/README.md b/README.md index bfacd25c..6cee8f18 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,15 @@ If you prefer to avoid conda and use a virtual environment with your favorite py ``` python -m venv tilepy_venv source tilepy_venv/bin/activate -pip3 install --upgrade pip -python -m pip install -r requirements.txt +pip install --upgrade pip +pip install . ``` Requirements of the installation: - The current version of the package **only** runs with `python>=3.9`. Python 3.9 is recommended. Be careful as well with the versions of matplotlib and healpy, they should be the ones explicitly given in the requirements.yml, otherwise conflicts between them when plotting skymaps will arise. - Note that by creating the env from the environment.yml, the libraries and versions needed will be installed automatically. -- Note that every time we made changes to the package, you should update the installation of the package doing ```pip install .``` in the folder where the setup.py is located. The changes will be only applied to the env in which you are working. +- Note that every time we made changes to the package, you should reinstall the package by running ```pip install .``` in the project root directory. The changes will be only applied to the env in which you are working. - The package relies on 'curl' to download the localisation map of the multi-messenger events. In the case you are working in CC-Lyon, the easiest solution is to do```ccenv conda ``` and then follow the instructions given above. diff --git a/cite_dependencies.py b/cite_dependencies.py index e5b31234..47f126a8 100644 --- a/cite_dependencies.py +++ b/cite_dependencies.py @@ -4,6 +4,11 @@ import requests +try: + import tomllib # Python 3.11+ +except ImportError: + import tomli as tomllib # Python 3.9, 3.10 + def get_authors_from_github(repo_path, title, url): headers = { @@ -63,28 +68,24 @@ def write_bibtex_to_file(data): file.write(bibtex_entry) -# Parse requirements.txt for package names and versions -# with open('requirements.txt', 'r') as file: -# lines = file.readlines() -# packages_and_versions = [line for line in lines] +def parse_pyproject_dependencies(file_path="pyproject.toml"): + """Parse dependencies from pyproject.toml""" + packages = [] + with open(file_path, "rb") as f: + data = tomllib.load(f) + # Extract main dependencies + dependencies = data.get("project", {}).get("dependencies", []) + for dep in dependencies: + # Remove any version specifiers and whitespace + package_name = dep.split("[")[0].strip() + if package_name and package_name.lower() != "setuptools": + packages.append(dep) -def parse_requirements(file_path): - packages = [] - with open(file_path, "r") as file: - for line in file: - # Removing any trailing whitespace and comments - package = line.split("#")[0].strip() - if package: # Only add non-empty lines - packages.append(package) return packages -# Usage -file_path = "./requirements.txt" # Replace with your file path -packages = parse_requirements(file_path) -print(packages) - +packages = parse_pyproject_dependencies("./pyproject.toml") print("requirements found: ", packages) # Regex to match GitHub URLs github_pattern = re.compile(r"https?://github\.com/([\w\-]+/[\w\-]+)") diff --git a/pyproject.toml b/pyproject.toml index 4c40c41f..3b188e11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ 'astropy', 'scipy<1.14.0', 'numpy', - 'healpy==1.16.2', + 'healpy>=1.16.2,<2', 'ipython', 'matplotlib<3.9.0', 'MOCpy', @@ -177,6 +177,6 @@ ignore-words-list = """ package = true override-dependencies = [ - 'healpy>=1.17.0', + 'healpy>=1.16.2,<2', "setuptools>=64,<71", ] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 81343d70..00000000 --- a/requirements.txt +++ /dev/null @@ -1,23 +0,0 @@ -astropy -pytz -scipy<1.14.0 -healpy==1.16.2 -tables -ipython -matplotlib<3.9.0 -MOCpy -numpy -pandas -ephem -gdpyc -ligo.skymap>=2.0.0 -fastparquet -skyfield -ipykernel -six -mhealpy>=0.3.0,<0.4 -setuptools -requests -scikit-learn>=1.6.1 -pytest -nbmake