diff --git a/collective_effects_installation_tutorial.txt b/collective_effects_installation_tutorial.txt deleted file mode 100644 index 60fd245..0000000 --- a/collective_effects_installation_tutorial.txt +++ /dev/null @@ -1,48 +0,0 @@ -1) Install eveything that will be needed: - - - sudo apt update - - sudo apt install python3-pip - - sudo pip3 install matplotlib scipy sh pandas tk notebook mpmath numexpr - - sudo apt-get install git python3-tk texlive-latex-base \ - texlive-latex-extra texlive-fonts-recommended dvipng cm-super - -2) Create links pip-sirius and python-sirius to pip3 and python3, respectvely: - - - cd /usr/bin - - ls -la pip* - - sudo ln -s pip3 pip-sirius - - - cd /usr/bin - - ls -la python* - - sudo ln -s python3 python-sirius - -3) Create an SSH key to clone the git repositories. - If a key already exists, skip to the next step: - - - cd .ssh - - ssh-keygen - - cat id_rsa.pub - - Copy the generated key and paste it in the "SSH and GPG keys" - from GitHub settings - -4) Clone the required repositories: - - - git clone git@github.com:lnls-fac/collective_effects - - git clone git@github.com:lnls-fac/mathphys - -5) Install mathphys: - - - cd mathphys - - make develop-install - -6) Install the package: - - - cd collective_effects/pycolleff - - make develop-install - -7) Check if everything is working properly: - - - ems-wake-analysis.py --help - - If the help message appears, the packages were correctly installed. diff --git a/cppcolleff/Makefile b/cppcolleff/Makefile index cf9e905..ee8e753 100644 --- a/cppcolleff/Makefile +++ b/cppcolleff/Makefile @@ -185,7 +185,7 @@ install: clean install-cpp install-py uninstall: uninstall-cpp uninstall-py -develop-install-py: develop-uninstall-py all +develop-install-py: clean develop-uninstall-py all $(MAKE) develop-install -C $(PYTHON_PACKAGE_DIR) develop-uninstall-py: diff --git a/cppcolleff/python_package/LICENSE b/cppcolleff/python_package/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/cppcolleff/python_package/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/cppcolleff/python_package/Makefile b/cppcolleff/python_package/Makefile index e43381f..1cda037 100644 --- a/cppcolleff/python_package/Makefile +++ b/cppcolleff/python_package/Makefile @@ -61,8 +61,6 @@ uninstall: develop-install: develop-uninstall all $(PIP) install --no-deps -e ./ -# known issue: It will fail to uninstall scripts -# if they were installed in develop mode develop-uninstall: $(PIP) uninstall -y $(PACKAGE) diff --git a/cppcolleff/python_package/README.md b/cppcolleff/python_package/README.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/cppcolleff/python_package/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/cppcolleff/python_package/VERSION b/cppcolleff/python_package/VERSION deleted file mode 100644 index 8acdd82..0000000 --- a/cppcolleff/python_package/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.1 diff --git a/cppcolleff/python_package/VERSION b/cppcolleff/python_package/VERSION new file mode 120000 index 0000000..6ff19de --- /dev/null +++ b/cppcolleff/python_package/VERSION @@ -0,0 +1 @@ +../VERSION \ No newline at end of file diff --git a/cppcolleff/python_package/pyproject.toml b/cppcolleff/python_package/pyproject.toml new file mode 100644 index 0000000..c8cbaf9 --- /dev/null +++ b/cppcolleff/python_package/pyproject.toml @@ -0,0 +1,72 @@ +[build-system] +requires = ["setuptools>=44"] +build-backend = "setuptools.build_meta" + +[project] +name = "cppcolleff" +authors = [{ name = "lnls-fac" } ] +maintainers = [ + {name = "Fernando H. de Sá", email = "fernandohds564@gmail.com"} +] +description = "Collective effects calculation package" +readme = "README.md" +dynamic = ["version", "dependencies"] +requires-python = ">=3.6" +classifiers = [ + "Intended Audience :: Science/Research", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", +] +keywords = ["SIRIUS", "python", "Collective Effects", "Accelerator Physics"] + +license = "GPL-3.0" +license-files= [ "LICENSE", ] + +[project.urls] +Homepage = "https://github.com/lnls-fac/collective-effects" +Download = "https://github.com/lnls-fac/collective-effects" +Repository = "https://github.com/lnls-fac/collective-effects.git" +Issues = "https://github.com/lnls-fac/collective-effects/issues" + +# --- Setuptools specific configurations --- +[tool.setuptools] +include-package-data = true + +[tool.setuptools.dynamic] +version = { file = "VERSION" } +dependencies = { file = "requirements.txt" } + +[tool.setuptools.package-data] +cppcolleff = ["_cppcolleff.so", "VERSION"] + +# --- linter and formatter configurations --- +[tool.ruff] +select = [ + "W", "E", "A", "B", "C90", "D", "I002", "N", "F", "G", "ARG", "S", "NPY"] +ignore = [ + "D203", "D204", "D213", "D215", "D400", "D401", "D404", "D406", "D407", + "D408", "D409", "D413", "E203", "E226"] +ignore-init-module-imports = true +preview = true +line-length = 79 +fix = true + +[tool.ruff.extend-per-file-ignores] +"__init__.py" = ["F401", "F821"] + +[tool.ruff.format] +skip-magic-trailing-comma = true + +[tool.ruff.lint.isort] +split-on-trailing-comma = false +combine-as-imports = true + +[tool.isort] +split_on_trailing_comma = false +combine_as_imports = true +combine_star = true +multi_line_output = "HANGING_INDENT" +order_by_type = false + +[tool.black] +line-length = 79 diff --git a/cppcolleff/python_package/requirements.txt b/cppcolleff/python_package/requirements.txt new file mode 100644 index 0000000..6cd2ba9 --- /dev/null +++ b/cppcolleff/python_package/requirements.txt @@ -0,0 +1,3 @@ +numpy>=1.18 +scipy>=1.5 +matplotlib>=3.3 diff --git a/cppcolleff/python_package/setup.py b/cppcolleff/python_package/setup.py index b76dc9f..a8fb6b2 100644 --- a/cppcolleff/python_package/setup.py +++ b/cppcolleff/python_package/setup.py @@ -1,15 +1,30 @@ #!/usr/bin/env python3 +import pathlib + from setuptools import setup -with open('VERSION','r') as _f: + +def get_abs_path(relative): + """.""" + return str(pathlib.Path(__file__).parent / relative) + + +with open(get_abs_path("README.md"), "r") as _f: + _long_description = _f.read().strip() + +with open(get_abs_path("VERSION"), "r") as _f: __version__ = _f.read().strip() +with open(get_abs_path("requirements.txt"), "r") as _f: + _requirements = _f.read().strip().split("\n") + setup( name='cppcolleff', version=__version__, author='lnls-fac', description='cppcolleff python package', + long_description=_long_description, url='https://github.com/lnls-fac/collective_effects', download_url='https://github.com/lnls-fac/collective_effects', classifiers=[ @@ -18,6 +33,7 @@ 'Topic :: Scientific/Engineering' ], packages=['cppcolleff'], + install_requires=_requirements, package_data={'cppcolleff': ['_cppcolleff.so', 'VERSION']}, zip_safe=False ) diff --git a/pycolleff/INSTALL b/pycolleff/INSTALL deleted file mode 100644 index b57f309..0000000 --- a/pycolleff/INSTALL +++ /dev/null @@ -1,34 +0,0 @@ -INSTALL - pycolleff -================= - -This package can be installed using setuptools (>=16.0). There is no automatic -dependency checking, so read the list below and ensure necessary dependencies -are available. Developed and tested with Python 3 (3.4). - - -REQUIREMENTS -============ - -- numpy 1.18 (>=1.18.2) -- scipy 1.5 (>=1.5.0) -- matplotlib 3.3 (>=3.3.0) -- pandas 1.1 (>=1.1.0) -- mpmath 1.1 (>=1.1.0) -- sh 1.12 (>=1.12) -- numexpr 2.7 (>=2.7.1) -- mathphys 0.6 (>=0.6.0) -- tk - -INSTALLATION -============ - -To install to a default Python directory, run - - make install - -To install a development version, with a link to the local package files in the -default Python directory, run - - make develop-install - -Details and further options can be found in setuptools documentation. diff --git a/pycolleff/Makefile b/pycolleff/Makefile index 24d10ad..35fbcea 100644 --- a/pycolleff/Makefile +++ b/pycolleff/Makefile @@ -16,8 +16,6 @@ uninstall: develop-install: develop-uninstall $(PIP) install --no-deps -e ./ -# known issue: It will fail to uninstall scripts -# if they were installed in develop mode develop-uninstall: $(PIP) uninstall -y $(PACKAGE) @@ -25,7 +23,7 @@ test: pytest tests/ dist: ## Build setuptools dist - python setup.py sdist bdist_wheel + python -m build distupload: ## Upload package dist to PyPi python -m twine upload --verbose dist/* diff --git a/pycolleff/README.md b/pycolleff/README.md index c59210c..c11a760 100644 --- a/pycolleff/README.md +++ b/pycolleff/README.md @@ -1,4 +1,2 @@ # pycolleff Python module for impedances and instability analysis in electron storage rings. - -For installation instructions, read INSTALL. diff --git a/pycolleff/pyproject.toml b/pycolleff/pyproject.toml new file mode 100644 index 0000000..4ad0f3a --- /dev/null +++ b/pycolleff/pyproject.toml @@ -0,0 +1,80 @@ +[build-system] +requires = ["setuptools>=44"] +build-backend = "setuptools.build_meta" + +[project] +name = "pycolleff" +authors = [{ name = "lnls-fac" } ] +maintainers = [ + {name = "Fernando H. de Sá", email = "fernandohds564@gmail.com"}, + {name = "Murilo Barbosa Alves", email= "alvesb.murilo@gmail.com"} +] +description = "Client Applications for Sirius" +readme = "README.md" +dynamic = ["version", "dependencies"] +requires-python = ">=3.6" +classifiers = [ + "Intended Audience :: Science/Research", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", +] +keywords = ["SIRIUS", "python", "Collective Effects", "Accelerator Physics"] + +license = "MIT" +license-files= [ "LICENSE", ] + +[project.urls] +Homepage = "https://github.com/lnls-fac/collective-effects" +Download = "https://github.com/lnls-fac/collective-effects" +Repository = "https://github.com/lnls-fac/collective-effects.git" +Issues = "https://github.com/lnls-fac/collective-effects/issues" + +# --- Setuptools specific configurations --- +[tool.setuptools] +include-package-data = true +# NOTE: This is not the standard way of defining scripts. +# Once we abandon phython3.6 and the setup.py file, we should +# consider using the table [project.scripts], defining valid entrypoints. +script-files = [ + 'scripts/ems-wake-analysis.py', + 'scripts/echo2d_submit.py', +] + +[tool.setuptools.dynamic] +version = { file = "VERSION" } +dependencies = { file = "requirements.txt" } + +[tool.setuptools.package-data] +pycolleff = ["VERSION"] + +# --- linter and formatter configurations --- +[tool.ruff] +select = [ + "W", "E", "A", "B", "C90", "D", "I002", "N", "F", "G", "ARG", "S", "NPY"] +ignore = [ + "D203", "D204", "D213", "D215", "D400", "D401", "D404", "D406", "D407", + "D408", "D409", "D413", "E203", "E226"] +ignore-init-module-imports = true +preview = true +line-length = 79 +fix = true + +[tool.ruff.extend-per-file-ignores] +"__init__.py" = ["F401", "F821"] + +[tool.ruff.format] +skip-magic-trailing-comma = true + +[tool.ruff.lint.isort] +split-on-trailing-comma = false +combine-as-imports = true + +[tool.isort] +split_on_trailing_comma = false +combine_as_imports = true +combine_star = true +multi_line_output = "HANGING_INDENT" +order_by_type = false + +[tool.black] +line-length = 79 diff --git a/pycolleff/scripts/echo2d_submit.py b/pycolleff/scripts/echo2d_submit.py index 0d1dbc0..3b36cb2 100755 --- a/pycolleff/scripts/echo2d_submit.py +++ b/pycolleff/scripts/echo2d_submit.py @@ -1,7 +1,8 @@ -#!/usr/bin/env python-sirius +#!/usr/bin/env python3 import argparse import subprocess as sp + import psutil as psu diff --git a/pycolleff/scripts/ems-wake-analysis.py b/pycolleff/scripts/ems-wake-analysis.py index 56c4324..59d4fd1 100755 --- a/pycolleff/scripts/ems-wake-analysis.py +++ b/pycolleff/scripts/ems-wake-analysis.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python-sirius +#!/usr/bin/env python3 import optparse import os diff --git a/pycolleff/setup.py b/pycolleff/setup.py index 29e249f..e1b9256 100755 --- a/pycolleff/setup.py +++ b/pycolleff/setup.py @@ -1,11 +1,13 @@ #!/usr/bin/env python3 -import pkg_resources +import pathlib + from setuptools import find_packages, setup def get_abs_path(relative): - return pkg_resources.resource_filename(__name__, relative) + """.""" + return str(pathlib.Path(__file__).parent / relative) with open(get_abs_path("README.md"), "r") as _f: @@ -17,10 +19,6 @@ def get_abs_path(relative): with open(get_abs_path("requirements.txt"), "r") as _f: _requirements = _f.read().strip().split("\n") - -with open('VERSION', 'r') as _f: - __version__ = _f.read().strip() - setup( name='pycolleff', version=__version__,