Move requirements to setup.cfg

This commit is contained in:
Tom Hodson 2022-07-18 11:24:27 +01:00
parent 107dae0201
commit 03657e0883
6 changed files with 64 additions and 29 deletions

View File

@ -44,8 +44,8 @@
"│ └── #The Jupyer notebooks that form the main body of this project\n",
"│\n",
"├── pyproject.toml # Machine readable information about the MCFF package\n",
"├── readthedocs.yaml # Tells readthedocs.com how to build the documentation\n",
"├── requirements.txt # What packages MCFF requires\n",
"├── readthedocs.yml # Tells readthedocs.com how to build the documentation\n",
"├── environment.yml # A specification for building a conda environment including all the dependencies\n",
"├── setup.cfg # Machine readable information about the MCFF package\n",
"├── src\n",
"│ └── MCFF # The actual code!\n",
@ -56,7 +56,7 @@
"It's looks pretty intimidating! But let's quickly go through it, at the top level of most projects you'll find on Github and elsewhere you'll find files to do with the project as a whole:\n",
"- `README.md` - An intro to the project\n",
"- `LICENSE` - The software license that governs this project, there are a few standard ones people use.\n",
"- `requirements.txt` or `environment.yaml` (or both) this list what python packages the project needs in a standard format\n",
"- `environment.yaml` (or both) this list what python packages the project needs in a standard format\n",
"- `CITATION.cff` This is the new standard way to describe how a work should be cited, v useful for academic software.\n",
"\n",
"Then below that you will usually have directories breaking the project up into main categories, here I have `code/` and `learning/` but it would be more typical to have what is in `code` at the top level.\n",
@ -73,7 +73,7 @@
"from MCFF import mcmc #once we've written this that is!\n",
"```\n",
"\n",
"`pyproject.toml` and `setup.cfg` are the current way to describe the metadat about a python package like how it should be installed and who the author is etc, but typically you just copy the standard layouts and build from there. The empty `__init__.py` file flags that this folder is a python module.\n",
"`pyproject.toml` and `setup.cfg` are the current way to describe the metadata about a python package like how it should be installed and who the author is etc, but typically you just copy the standard layouts and build from there. The empty `__init__.py` file flags that this folder is a python module.\n",
"\n",
"pyproject.toml:\n",
"```\n",
@ -94,28 +94,42 @@
"\n",
"setup.cfg\n",
"```\n",
"[metadata]\n",
"name = MCFF\n",
"version = 0.0.1\n",
"author = Tom Hodson\n",
"author_email = tch14@ic.ac.uk\n",
"description = A small example package\n",
"long_description = file: README.md\n",
"long_description_content_type = text/markdown\n",
"url = None\n",
"url = https://github.com/TomHodson/MCMC_for_fun_and_profit\n",
"classifiers =\n",
" Programming Language :: Python :: 3\n",
" License :: OSI Approved :: MIT License\n",
" License :: OSI Approved :: The 3-Clause BSD License\n",
" Operating System :: OS Independent\n",
"\n",
"[options]\n",
"package_dir = \n",
"package_dir =\n",
" = src\n",
"packages = find:\n",
"python_requires = >=3.6\n",
"install_requires =\n",
" numpy == 1.21 \n",
" scipy == 1.7\n",
" matplotlib == 3.5\n",
" numba == 0.55\n",
" ipykernel == 6.9 # Allows this conda environment to show up automatically in Jupyter Lab\n",
" watermark == 2.3 # Generates a summary of package version for use inside Jupyter Notebooks\n",
"\n",
"[options.packages.find]\n",
"where = src\n",
"dev = \n",
" pytest == 7.1 # Testing\n",
" pytest-cov == 3.0 # For Coverage testing\n",
" hypothesis == 6.29 # Property based testing\n",
" pre-commit == 2.20\n",
" \n",
"docs = \n",
" sphinx == 5.0 # For building the documentation\n",
" myst-nb == 0.16 \n",
"```\n",
"Phew, that was a lot. Python packaging has been evolving a lot over the years and the consequence is there is a lot of out of date advice and there are many other ways to do this. You're best bet to figure out what the current best practice is is to consult offical sources like python.org"
]
@ -127,9 +141,9 @@
"source": [
"Once all that is setup, cd to the `code/` folder and install the module using:\n",
"```bash\n",
"pip install --editable .\n",
"pip install --editable \".[dev,docs]\"\n",
"```\n",
"The dot means we should install MCFF from the current directory and `--editable` means to do it as an editable package so that we can edit the files in MCFF and not have to reinstall. This is really useful for development. "
"The dot means we should install MCFF from the current directory and `--editable` means to do it as an editable package so that we can edit the files in MCFF and not have to reinstall. This is really useful for development. `[dev,docs]` means we also want to install the packages that are needed to do development of this repository and to build the documentation, boths those things will become relevant later!"
]
},
{

View File

@ -1,2 +0,0 @@
sphinx
myst-nb

View File

@ -6,15 +6,28 @@ channels:
dependencies:
- python=3.9
- pytest=7.1
- pytest-cov=3.0
- ipykernel=6.9
# Core packages
- numpy=1.21
- scipy=1.7
- matplotlib=3.5
- numba=0.55
- pre-commit=2.20
- hypothesis=6.29
- ipykernel=6.9 # Allows this conda environment to show up automatically in Jupyter Lab
- watermark=2.3 # Generates a summary of package version for use inside Jupyter Notebooks
# Testing
- pytest=7.1 # Testing
- pytest-cov=3.0 # For Coverage testing
- hypothesis=6.29 # Property based testing
# Development
- pre-commit=2.20 # For running black and other tools before commits
# Documentation
- sphinx=5.0 # For building the documentation
- myst-nb=0.16 # Allows sphinx to include Jupyter Notebooks
# Installing MCFF itself
- pip=21.2
- pip:
- --editable . #install MCFF from the local repository using pip and do it in editable mode

View File

@ -19,10 +19,9 @@ sphinx:
# formats:
# - pdf
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: docs/requirements.txt
- method: pip
path: .
install:
- method: pip
path: .
extra_requirements:
- docs

View File

@ -1,5 +0,0 @@
ipykernel
numpy
scipy
matplotlib
numba

View File

@ -17,6 +17,22 @@ package_dir =
= src
packages = find:
python_requires = >=3.6
install_requires =
numpy == 1.21
scipy == 1.7
matplotlib == 3.5
numba == 0.55
ipykernel == 6.9 # Allows this conda environment to show up automatically in Jupyter Lab
watermark == 2.3 # Generates a summary of package version for use inside Jupyter Notebooks
[options.packages.find]
where = src
dev =
pytest == 7.1 # Testing
pytest-cov == 3.0 # For Coverage testing
hypothesis == 6.29 # Property based testing
pre-commit == 2.20
docs =
sphinx == 5.0 # For building the documentation
myst-nb == 0.16