Skip to content

Commit

Permalink
add: implementation of the requirements.txt file.
Browse files Browse the repository at this point in the history
  • Loading branch information
seballgeyer committed Jul 24, 2024
1 parent 59c04f8 commit a8bcf60
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-cicd-units.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install boto3 click hatanaka matplotlib numpy pandas plotext==4.2 plotly pymongo pytest scipy tqdm unlzw3 typing_extensions
pip install -r requirements.txt

This comment has been minimized.

Copy link
@treefern

treefern Jul 24, 2024

Collaborator

I'd suggest installing gnssanalysis itself, in order to get the dependencies installed via setup.py. Specifically:

Remove the version line used for published builds. Forget about filling in the version, we don't need it here:
sed -i "/{{VERSION_PLACEHOLDER}}/d" setup.py

Install, leveraging setup.py:
pip install .

All the other junk I wrote becomes redundant at that point (sorry for the runaround).

- name: Run tests
run: |
python -m unittest discover -s tests -v
14 changes: 14 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
boto3
click
hatanaka
matplotlib
numpy
pandas
plotext==4.2
plotly
pymongo
pytest
scipy
tqdm
unlzw3
typing_extensions
18 changes: 2 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Read the contents of README file
this_directory = Path(__file__).parent
readme_text = (this_directory / "README.md").read_text()
requirements = (this_directory / "requirements.txt").read_text().splitlines()

This comment has been minimized.

Copy link
@treefern

treefern Jul 24, 2024

Collaborator

The hackyness I alluded to was mostly around comments. I'm still not sure parsing requirements.txt into a list of packages, rather than passing it to a tool is advisable, but if we take this route, I'd amend the reader to:

requirements_lines = (this_directory / "requirements.txt").read_text().splitlines()
requirements_lines = [line.strip() for line in requirements_lines if not line.strip().startswith("#")]  # Remove full comment lines. Strip spaces from all other lines.
requirements = [line.split("#")[0].strip() for line in requirements_lines]  # Try to remove comments and comment preceding spaces from ends of lines.

This comment has been minimized.

Copy link
@treefern

treefern Jul 24, 2024

Collaborator

Reading a bit further, I think moving the requirements list into requirements.txt (particularly while keeping setup.py) might be a step backwards.

In any case for the tests we should probably just be installing gnssanalysis (therefore implicitly installing its requirements) rather than installing the requirements explicitly.

If doing so is problematic with setup.py, we could add add a requirements.txt that simply has the effect of installing .

This is all superseded. See my comment on the test pipeline.


setuptools.setup(
include_package_data=True,
Expand All @@ -14,22 +15,7 @@
author_email="GNSSAnalysis@ga.gov.au",
package_data={"gnssanalysis": ["py.typed"]},
packages=setuptools.find_packages(),
install_requires=[
"boto3",
"click",
"hatanaka",
"matplotlib",
"numpy",
"pandas",
"plotext==4.2",
"plotly",
"pymongo",
"pytest",
"scipy",
"tqdm",
"unlzw3",
"typing_extensions",
],
install_requires=requirements,
entry_points={
"console_scripts": [
"diffutil = gnssanalysis:gn_utils.diffutil",
Expand Down

0 comments on commit a8bcf60

Please sign in to comment.