From db5c574dc664e39a317ba034260e1b4f19fe03d2 Mon Sep 17 00:00:00 2001 From: Mohamed Nasser Date: Thu, 22 Aug 2024 23:09:44 +0300 Subject: [PATCH] remove req.txt, manage.py and added poetry installation --- README.md | 41 +++++++------------------- manage.py | 77 ------------------------------------------------ requirements.txt | 17 ----------- 3 files changed, 11 insertions(+), 124 deletions(-) delete mode 100755 manage.py delete mode 100755 requirements.txt diff --git a/README.md b/README.md index ed95449..b0f14da 100755 --- a/README.md +++ b/README.md @@ -35,41 +35,23 @@ We welcome contributions to OSIPI! To contribute, follow these steps: ## Development Setup -There are two ways to set up your development environment for this project. You can choose the one that suits you best. +We used poetry to manage the dependencies for this project. -### Option 1: Using venv and requirements.txt +### Using Poetry -1. Clone the repository to your local machine. -2. Navigate to the project directory. -3. Create a virtual environment using `venv` by running the following command: +1. If you don't have Poetry installed, you can install it using pip: ```bash - python -m venv venv + pip install poetry ``` -4. Activate the virtual environment: - - - On Windows, run: - - ```bash - .\venv\Scripts\activate - ``` - - - On Unix or MacOS, run: - - ```bash - source venv/bin/activate - ``` - -5. Install the required packages from `requirements.txt`: + Or, if you're using a Unix-based system, you can install it using the following command: ```bash - pip install -r requirements.txt + curl -sSL https://install.python-poetry.org | python3 - ``` -### Option 2: Using Poetry - -1. If you don't have Poetry installed, you can install it by following the instructions on the [official Poetry website](https://python-poetry.org/docs/#installation). + For more information on installing Poetry, see the [official documentation](https://python-poetry.org/docs/) 2. Clone the repository to your local machine. 3. Navigate to the project directory. 4. Install the project dependencies with Poetry: @@ -100,11 +82,10 @@ There are two ways to set up your development environment for this project. You ```bash pre-commit run --all-files ``` - -After this, `pre-commit` will automatically run the hooks each time you commit changes to the project. If any of the hooks fail, -you'll need to fix the issues and then try committing your changes again. - -Also some of hooks are auto fixed if you see file was modified after running `pre-commit run --all-files` then you can add the changes and commit again. +**NOTE:** +- Next times you commit changes, `pre-commit` will run the hooks automatically. +- Some of hooks automatically fix/format your files to specific standards. If you see that some of your files have been changed after a commit, don't worry! It's just `pre-commit` doing its job. + Add the changes and commit them again. For more details on how to contribute, visit the [Developer Guide](https://osipi.github.io/pypi/contribution/#making-a-pull-request-pr-to-the-osipi-package). #### As mentioned before, this project is still in the early stages of development. If you'd like to contribute by adding functionality, we recommend opening an issue first to discuss your proposed functionality and the best ways to implement it. diff --git a/manage.py b/manage.py deleted file mode 100755 index 405dada..0000000 --- a/manage.py +++ /dev/null @@ -1,77 +0,0 @@ -import logging -import os -import subprocess -import sys -import venv - -# logging root configuration -logging.basicConfig( - level=logging.INFO, - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", -) - - -def set_debug_mode(debug_mode): - if debug_mode: - logging.getLogger().setLevel(logging.DEBUG) - else: - logging.getLogger().setLevel(logging.INFO) - - -def distribute(): - """Create new version on PyPI. - - IMPORTANT! First increment your version number in pyproject.toml: - Increment the MAJOR version - when you make incompatible API changes. - Increment the MINOR version when you add functionality - in a backwards compatible manner. - Increment the PATCH version when you make backwards - compatible bug fixes. You need: PyPI username and password. You need to type in the PyPI - password rather than copy-pasting. - - """ - create_venv() - install() - - os.system(activate() + " && " + "pip install --upgrade build") - os.system(activate() + " && " + "python -m build") - os.system(activate() + " && " + "pip install --upgrade twine") - os.system(activate() + " && " + "twine upload dist/*") - - -def create_venv(): - venv_dir = os.path.join(os.getcwd(), ".venv") - if not os.path.exists(venv_dir): - logging.info("Creating virtual environment...") - try: - python_executable = "python3" if sys.platform != "win32" else "python" - subprocess.check_call([python_executable, "-m", "venv", venv_dir]) - logging.info("Virtual environment created successfully.") - except subprocess.CalledProcessError as e: - logging.error(f"Failed to create virtual environment: {e}") - else: - logging.info("Virtual environment already exists.") - - -def activate(): - """Active virtual environment.""" - - venv_dir = os.path.join(os.getcwd(), ".venv") - os.makedirs(venv_dir, exist_ok=True) - venv.create(venv_dir, with_pip=True) - windows = (sys.platform == "win32") or (sys.platform == "win64") or (os.name == "nt") - if windows: - return os.path.join(venv_dir, "Scripts", "activate") - else: # MacOS and Linux - return '. "' + os.path.join(venv_dir, "bin", "activate") - - -def install(): - """Install requirements to a virtual environment.""" - - logging.info("Installing requirements...") - os.system(activate() + " && " + "py -m pip install -r requirements.txt") - - -if __name__ == "__main__": - # install() - set_debug_mode(debug_mode=True) - distribute() diff --git a/requirements.txt b/requirements.txt deleted file mode 100755 index 6083259..0000000 --- a/requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ -osipi -numpy==1.23.0 -scipy==1.13.1 -matplotlib==3.9.0 -requests==2.32.3 -flake8==7.0.0 -pre-commit==3.7.1 -pytest==8.2.2 -pytest-cov==5.0.0 -autodocsumm==0.2.12 -docutils==0.21.2 -myst-parser==3.0.1 -rstcheck[sphinx]==6.2.1 -mkdocs==1.6.0 -mkdocs-material[imaging]==9.5.27 -mkdocs-gallery==0.10.1 -mkdocstrings[crystal,python]==0.25.1