Repository: fusion-energy/paramak (language: python)

Issue:
Adding new component, refactoring reactor to fully seperate volumes
## Proposed changes

Generally this PR is preparing for the upcoming Brep to DAGMC method that is being worked on.
However some additional improvements have been added in
- new component ExtrudeHollowRectangle
- allowing the overlapping points warning to be removed when overlapping points are exspected, this warning was confusing users

## Types of changes

- [x] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] Code refactoring
- [x] Documentation Update (if none of the other choices apply)
- [x] New tests

## Checklist

- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have added necessary documentation (if appropriate)



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci_with_docker_build.yml b/.github/workflows/ci_with_docker_build.yml
index 2b60cad83..4b6445451 100644
--- a/.github/workflows/ci_with_docker_build.yml
+++ b/.github/workflows/ci_with_docker_build.yml
@@ -23,6 +23,8 @@ jobs:
         uses: actions/checkout@v2
 
       - name: Build and test with Docker
+        env:
+          DOCKER_BUILDKIT: 1
         run: |
           docker build -t paramak --build-arg cq_version=2.1 .
           docker run --rm paramak  /bin/bash -c "bash run_tests.sh"
diff --git a/.github/workflows/ci_with_install.yml b/.github/workflows/ci_with_install.yml
index 5ed5259ca..6ed721f8e 100644
--- a/.github/workflows/ci_with_install.yml
+++ b/.github/workflows/ci_with_install.yml
@@ -27,7 +27,7 @@ jobs:
 
       - name: install package
         run: |
-          python setup.py install
+          pip install -e .
 
       - name: Run test_utils
         run: |
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index c909e1674..d187fc551 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -25,27 +25,15 @@ jobs:
       with:
         python-version: '3.x'
 
-    - name: Autobump version
-      run: |
-        # from refs/tags/v1.2.3 get 1.2.3
-        VERSION=$(echo $GITHUB_REF | sed 's#.*/v##')
-        PLACEHOLDER='version="develop"'
-        VERSION_FILE='setup.py'
-        # Grep checks that the placeholder is in the file. If grep doesn't find
-        # the placeholder then it exits with exit code 1 and github actions fails.
-        grep "$PLACEHOLDER" "$VERSION_FILE"
-        sed -i "s@$PLACEHOLDER@version=\"${VERSION}\"@g" "$VERSION_FILE"
-      shell: bash
-
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
-        pip install setuptools wheel twine
+        pip install setuptools wheel build twine
 
     - name: Build and publish
       env:
         TWINE_USERNAME: __token__
         TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
       run: |
-        python setup.py sdist bdist_wheel
+        python -m build
         twine upload dist/*
diff --git a/.gitignore b/.gitignore
index 8c31f92b7..0d947dbda 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ __pycache__
 venv
 .eggs/
 paramak.egg-info/
+_version.py
 
 # test coverage files
 coverage.xml
diff --git a/Dockerfile b/Dockerfile
index aa4d0c376..34914e835 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -51,15 +51,6 @@ RUN echo installing CadQuery version $cq_version && \
     pip install jupyter-cadquery==2.2.0 && \
     conda clean -afy
 
-# installs dependancies
-COPY requirements.txt requirements.txt
-RUN pip install -r requirements.txt
-
-# installs required packages for dependancies
-COPY requirements-test.txt requirements-test.txt
-RUN pip install -r requirements-test.txt
-
-
 RUN mkdir /home/paramak
 EXPOSE 8888
 WORKDIR /home/paramak
@@ -71,11 +62,13 @@ COPY run_tests.sh run_tests.sh
 COPY paramak paramak/
 COPY examples examples/
 COPY setup.py setup.py
+COPY setup.cfg setup.cfg
+COPY pyproject.toml pyproject.toml
 COPY tests tests/
 COPY README.md README.md
+COPY LICENSE.txt LICENSE.txt
 
-# using setup.py instead of pip due to https://github.com/pypa/pip/issues/5816
-RUN python setup.py install
+RUN --mount=source=.git,target=.git,type=bind pip install --no-cache-dir -e .[tests,docs]
 
 # this helps prevent the kernal failing
 RUN echo "#!/bin/bash\n\njupyter lab --notebook-dir=/home/paramak/examples --port=8888 --no-browser --ip=0.0.0.0 --allow-root" >> docker-cmd.sh
diff --git a/build.sh b/build.sh
index 60a2367c1..8c43946e7 100644
--- a/build.sh
+++ b/build.sh
@@ -1,1 +1,2 @@
-python setup.py install     # Python command to install the script.
\ No newline at end of file
+python3 -m pip install --upgrade build
+python3 -m build
diff --git a/paramak/__init__.py b/paramak/__init__.py
index 6d4a1a332..e808ab174 100644
--- a/paramak/__init__.py
+++ b/paramak/__init__.py
@@ -1,3 +1,16 @@
+try:
+    from importlib.metadata import version, PackageNotFoundError
+except (ModuleNotFoundError, ImportError):
+    from importlib_metadata import version, PackageNotFoundError
+try:
+    __version__ = version("paramak")
+except PackageNotFoundError:
+    from setuptools_scm import get_version
+
+    __version__ = get_version(root="..", relative_to=__file__)
+
+__all__ = ["__version__"]
+
 from .shape import Shape
 from .reactor import Reactor
 from .utils import rotate, extend, distance_between_two_points, diff_between_angles
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..812f1f905
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,10 @@
+[build-system]
+requires = [
+    "setuptools >= 45",
+    "wheel",
+    "setuptools_scm[toml] >= 6.2",
+]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools_scm]
+write_to = "paramak/_version.py"
diff --git a/readthedocs.yml b/readthedocs.yml
index 2da9c2c1e..60b68e77b 100644
--- a/readthedocs.yml
+++ b/readthedocs.yml
@@ -13,11 +13,14 @@ sphinx:
 #   - pdf
 
 # this is not needed if using conda environment
-# python:
-#   version: 3.7
-#   install:
-#     - requirements: requirements.txt
+python:
+  version: 3.8
+  install:
+    - method: pip
+      path: .
+      extra_requirements:
+        - docs
 
 # specify conda environment needed for build
 conda:
-  environment: environment.yml
\ No newline at end of file
+  environment: environment.yml
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index e821a37e8..000000000
--- a/requirements.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-plotly>=5.1.0
-scipy>=1.7.0
-sympy>=1.8
-numpy>=1.21.1
-matplotlib>=3.4.2
-plasmaboundaries>=0.1.8
-jupyter-cadquery>=2.2.0
-
-# tests require additional packages
-pytest-cov>=2.12.1
-pytest-runner>=5.3.1
-nbformat>=5.1.3
-nbconvert>=6.1.0
-
-# Note, cadquery not installed via pip to avoid installing cadquery version 1
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 000000000..56ea260bf
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,49 @@
+[metadata]
+name = paramak
+author = The Paramak Development Team
+author_email = mail@jshimwell.com
+description = Create 3D fusion reactor CAD models based on input parameters
+long_description = file: README.md
+long_description_content_type = text/markdown
+url = https://github.com/fusion-energy/paramak
+license = MIT
+license_file = LICENSE.txt
+classifiers =
+    Natural Language :: English
+    Topic :: Scientific/Engineering
+    Programming Language :: Python :: 3
+    Programming Language :: Python :: 3.6
+    Programming Language :: Python :: 3.7
+    Programming Language :: Python :: 3.8
+    Programming Language :: Python :: 3.9
+    License :: OSI Approved :: MIT License
+    Operating System :: OS Independent
+project_urls =
+    Source = https://github.com/fusion-energy/paramak
+    Tracker = https://github.com/fusion-energy/paramak/issues
+
+[options]
+packages = find:
+python_requires= >=3.6
+install_requires=
+    plotly >= 5.1.0
+    scipy >= 1.7.0
+    sympy >= 1.8
+    numpy >= 1.21.1
+    matplotlib >= 3.4.2
+    plasmaboundaries >= 0.1.8
+    jupyter-client < 7
+    jupyter-cadquery >= 2.2.0
+
+[options.extras_require]
+tests = 
+    pytest >= 5.4.3
+    pytest-cov>=2.12.1
+    pytest-runner>=5.3.1
+    nbformat>=5.1.3
+    nbconvert>=6.1.0
+docs = 
+    sphinx >= 4.1.2
+    sphinx_rtd_theme
+    sphinx_autodoc_typehints
+    sphinxcadquery
diff --git a/setup.py b/setup.py
index 212306131..1abbd068c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,38 +1,4 @@
 import setuptools
 
-with open("README.md", "r") as fh:
-    long_description = fh.read()
-
-setuptools.setup(
-    name="paramak",
-    version="develop",
-    author="The Paramak Development Team",
-    author_email="mail@jshimwell.com",
-    description="Create 3D fusion reactor CAD models based on input parameters",
-    long_description=long_description,
-    long_description_content_type="text/markdown",
-    url="https://github.com/fusion-energy/paramak",
-    packages=setuptools.find_packages(),
-    classifiers=[
-        "Natural Language :: English",
-        "Topic :: Scientific/Engineering",
-        "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.6",
-        "Programming Language :: Python :: 3.7",
-        "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",
-        "License :: OSI Approved :: MIT License",
-        "Operating System :: OS Independent",
-    ],
-    python_requires=">=3.6",
-    install_requires=[
-        "plotly>=5.1.0",
-        "scipy>=1.7.0",
-        "sympy>=1.8",
-        "numpy>=1.21.1",
-        "matplotlib>=3.4.2",
-        "plasmaboundaries>=0.1.8",
-        "jupyter-client<7",
-        "jupyter-cadquery>=2.2.0",
-    ],
-)
+if __name__ == "__main__":
+    setuptools.setup()


Test patch:
diff --git a/.github/workflows/test_demos.yml b/.github/workflows/test_demos.yml
index 5750b3c34..00cc6b54a 100644
--- a/.github/workflows/test_demos.yml
+++ b/.github/workflows/test_demos.yml
@@ -22,7 +22,7 @@ jobs:
 
       - name: Setup paramak
         run: |
-          python3 setup.py develop
+          pip install -e .
 
 
       - name: Run the notebooks shapes
diff --git a/requirements-test.txt b/requirements-test.txt
deleted file mode 100644
index 3e6179f0d..000000000
--- a/requirements-test.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
-pytest-cov>=2.12.1
-pytest-runner>=5.3.1
-nbformat>=5.1.3
-nbconvert>=6.1.0
diff --git a/tests/test_version.py b/tests/test_version.py
new file mode 100644
index 000000000..bc409e94b
--- /dev/null
+++ b/tests/test_version.py
@@ -0,0 +1,16 @@
+import pytest
+import paramak
+
+
+def test_version():
+    """Check that __version__ exists and is correctly formatted"""
+    version = paramak.__version__
+    # Ensure it is given as a string
+    assert isinstance(version, str)
+    # Ensure is has at least three parts -- major, minor and patch -- separated by '.'
+    version_bits = version.split(".")
+    assert len(version_bits) >= 3
+    # Ensure each of the first three parts is convertable to int
+    # (The fourth part, if it exists, may be a development version)
+    for bit in version_bits[:3]:
+        assert bit.isdigit()