Skip to content
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

Issue15: move from setup.py to pyproject.toml #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# References:
Copy link

Choose a reason for hiding this comment

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

Nice! Can you also update Makefile?

Copy link

Choose a reason for hiding this comment

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

Patch to start with:

diff --git a/Makefile b/Makefile
index 8149166..75e6645 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@ WORKBENCH_TRANSLATION_CONTEXT = cool
 MAINTAINER = me
 EMAIL = me@foobar.com
 URL = https://foobar.com/me/coolWB
+VERSION = 0.0.0
 DESCRIPTION = The cool WB creates cool parametric objects
 DEPENDENCIES_LIST = []
 
@@ -25,7 +26,8 @@ replace_strings:
 	sed -i 's/workbench_starterkit/$(WORKBENCH_DIR_NAME)/g' freecad/workbench_starterkit/init_gui.py
 	sed -i 's/workbench_starterkit/$(WORKBENCH_DIR_NAME)/g' freecad/workbench_starterkit/resources/translations/update_translation.sh
 	sed -i 's/workbench_starterkit/$(WORKBENCH_DIR_NAME)/g' freecad/workbench_starterkit/resources/translations/workbench_starterkit_es-ES.ts
-	sed -i 's/workbench_starterkit/$(WORKBENCH_DIR_NAME)/g' setup.py
+	sed -i "s/__version__ = .*/__version__ = \'$(VERSION)\'/g" freecad/workbench_starterkit/version.py
+	sed -i 's/workbench_starterkit/$(WORKBENCH_DIR_NAME)/g' pyproject.toml
 	@# Rename workbench class name
 	sed -i 's/TemplateWorkbench/$(WORKBENCH_CLASS_NAME)/g' freecad/workbench_starterkit/init_gui.py
 	@# Rename workbench class properties
@@ -39,12 +41,12 @@ replace_strings:
 	sed -i 's/starterkit/$(WORKBENCH_TRANSLATION_CONTEXT)/g' freecad/workbench_starterkit/resources/translations/workbench_starterkit_es-ES.ts
 	@# Rename workbench directory
 	mv freecad/workbench_starterkit freecad/$(WORKBENCH_DIR_NAME)
-	@# Update setup.py file
-	sed -i 's/looooo/$(MAINTAINER)/g' setup.py
-	sed -i 's/sppedflyer@gmail.com/$(EMAIL)/g' setup.py
-	sed -i 's|https://github.com/FreeCAD/Workbench-Starterkit|$(URL)|g' setup.py
-	sed -i 's/template for a freecad extensions\, installable with pip/$(DESCRIPTION)/g' setup.py
-	sed -i "s/\['numpy'\]/$(DEPENDENCIES_LIST)/g" setup.py
+	@# Update pyproject.toml file
+	sed -i 's/looooo/$(MAINTAINER)/g' pyproject.toml
+	sed -i 's/sppedflyer@gmail.com/$(EMAIL)/g' pyproject.toml
+	sed -i 's|https://github.com/FreeCAD/freecad.workbench_starterkit|$(URL)|g' pyproject.toml
+	sed -i 's/template for a freecad extensions\, installable with pip/$(DESCRIPTION)/g' pyproject.toml
+	sed -i "s/\[\"numpy\"\]/$(DEPENDENCIES_LIST)/g" pyproject.toml
 
 self-destruction:
 	echo "Remove Makefile"

# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
# https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages
# https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "freecad.workbench_starterkit"
dynamic = ["version"]
description = "template for a freecad extensions, installable with pip"
readme = "README.md"
license = {file = "LICENSE"}
maintainers = [
{name = "looooo", email = "sppedflyer@gmail.com"},
]
requires-python = ">=3.8"
dependencies = ["numpy"]

[project.urls]
source = "https://github.com/FreeCAD/freecad.workbench_starterkit"

[tool.setuptools]
packages = ["freecad", "freecad.workbench_starterkit"]
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "freecad.workbench_starterkit.__version__"}
29 changes: 10 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
from setuptools import setup
import os
# from freecad.workbench_starterkit.version import __version__
# name: this is the name of the distribution.
# Packages using the same name here cannot be installed together
"""
We keep this file to support legacy builds and editable installs,
while keeping all configuration in pyproject.toml

References:

version_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
"freecad", "workbench_starterkit", "version.py")
with open(version_path) as fp:
exec(fp.read())
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
"""

from setuptools import setup

setup(name='freecad.workbench_starterkit',
version=str(__version__),
packages=['freecad',
'freecad.workbench_starterkit'],
maintainer="looooo",
maintainer_email="sppedflyer@gmail.com",
url="https://github.com/FreeCAD/Workbench-Starterkit",
description="template for a freecad extensions, installable with pip",
install_requires=['numpy'], # should be satisfied by FreeCAD's system dependencies already
include_package_data=True)
setup()