Skip to content

Setup enhancements #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- id: check-docstring-first
- id: check-json
- id: pretty-format-json
args: ['--autofix']
- id: check-toml
- id: mixed-line-ending
args: ['--fix', 'auto']
- id: name-tests-test
args: ['--pytest-test-first']
- id: requirements-txt-fixer
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
65 changes: 42 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,78 @@ git clone --recursive https://github.com/NationalGenomicsInfrastructure/genomics

<details>

<summary>Note on `conda` environments</summary>
<summary>Note on MacOS installations</summary>

#### Create the environment with the correct dependencies
### Fix library issues

If you decide to use a conda environment, create one making sure to use the `conda_requirements.yml` file with the following command:
If you are using MacOS, you might run into some issues with the libraries when running the app.

In case you get the `OSError: cannot load library 'gobject-2.0-0'` error (or similar), install `glib` and `pango` via [Homebrew](https://brew.sh/):

```bash
conda env create -n <env_name> -f conda_requirements.yml
brew install glib
brew install pango
```

where `<env_name>` is the name of the environment you want to create. Then, activate the environment with:
and then symlink the libraries to `/usr/local/lib`:

```bash
conda activate <env_name>
sudo ln -s /opt/homebrew/opt/glib/lib/libgobject-2.0.0.dylib /usr/local/lib/gobject-2.0
sudo ln -s /opt/homebrew/opt/pango/lib/libpango-1.0.dylib /usr/local/lib/pango-1.0
sudo ln -s /opt/homebrew/opt/harfbuzz/lib/libharfbuzz.dylib /usr/local/lib/harfbuzz
sudo ln -s /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib /usr/local/lib/fontconfig-1
sudo ln -s /opt/homebrew/opt/pango/lib/libpangoft2-1.0.dylib /usr/local/lib/pangoft2-1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does one really need to change the /usr/local/lib ? I'm a bit wary when running sudo and touching what looks like system package territory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, saw that this is just moved in the README now. The question remains but maybe it's not targeted towards you but rather @anand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a work-around that I found to the installation issues that I had at the beginning (I added these lines in the README in the first place). However, it is possible that it is an issue related to the specific architecture of my laptop, which is arm64. I can specify in the document that this could be a solution for whoever faces the same issue on the new Macs, but that it is not something that everyone should apply to begin with.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we had some issues when we first introduced these packages actually. They are needed for the pdf generation which is a fairly niche use case that most will not need to test in a developer setting. So I think usually it's fine to run it without these packages which most do I believe. Perhaps splitting them out to it's own installation instruction could be possible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could add a note that you only need to care about these packages not being installed properly on your system if you plan to test the Agreement and Invoicing parts of Genstat?

```

</details>

Install the dependencies and the package (the `pip install -r requirements_dev.txt` can be skipped on a production server)

#### Install via `conda` [recommended]

If you are using `conda`, we recommend creating a new environment using `conda-lock` to ensure that the environment is reproducible across different systems.

**Create the environment using `conda-lock` [recommended]**

To create a new environment using `conda-lock`, first install `conda-lock`, if you haven't already, using one of the [available methods](https://github.com/conda/conda-lock/tree/main?tab=readme-ov-file#installation).

Then, run the following command in the root directory of the repository:

```bash
pip install -r requirements.txt
pip install -r requirements_dev.txt
python setup.py install
conda-lock install --name <env_name>
```

<details>
This will create a new environment with the name `<env_name>` and install all the required dependencies.

<summary>Note on MacOS installations</summary>
<details>

### Fix library issues
<summary>Using default conda [alternative]</summary>

If you are using MacOS, you might run into some issues with the libraries when running the app.
#### Create the environment using `conda`

In case you get the `OSError: cannot load library 'gobject-2.0-0'` error (or similar), install `glib` and `pango` via [Homebrew](https://brew.sh/):
If you prefer to create the environment using `conda` directly, you can use the provided `conda_requirements.yml` file.

```bash
brew install glib
brew install pango
conda env create -n <env_name> -f conda_requirements.yml
```

and then symlink the libraries to `/usr/local/lib`:
where `<env_name>` is the name of the environment you want to create. Then, activate the environment with:

```bash
sudo ln -s /opt/homebrew/opt/glib/lib/libgobject-2.0.0.dylib /usr/local/lib/gobject-2.0
sudo ln -s /opt/homebrew/opt/pango/lib/libpango-1.0.dylib /usr/local/lib/pango-1.0
sudo ln -s /opt/homebrew/opt/harfbuzz/lib/libharfbuzz.dylib /usr/local/lib/harfbuzz
sudo ln -s /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib /usr/local/lib/fontconfig-1
sudo ln -s /opt/homebrew/opt/pango/lib/libpangoft2-1.0.dylib /usr/local/lib/pangoft2-1.0
conda activate <env_name>
```

</details>

#### Install via `pip` [alternative]

Install the dependencies and the package (the `pip install -r requirements_dev.txt` can be skipped on a production server)

```bash
pip install -r requirements.txt
pip install -r requirements_dev.txt
python setup.py install
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is enough anymore. We install pandas through conda, in addition to the packages needed for Agreements and Invoicing.


### Configuration

Expand Down
Loading