Skip to content

Commit e174a5c

Browse files
authored
Adjusted setup.py and versioneer.py to work with python 3.13 (#958)
* Update setup.py * Create main.yml * Update setup.py distutils now is completely removed. Requires installation of scikit-build pip install scikit-build cmake ninja python setup.py bdist_wheel * Create readme * Update main.yml * Create master.yml * Update master.yml * Add files via upload * Update setup.py * Update setup.py * Update setup.py * Update setup.py * Update versioneer.py * Update versioneer.py * Delete master-zip.zip * rewritten with AI to support python3
1 parent 9865f00 commit e174a5c

File tree

6 files changed

+69
-135
lines changed

6 files changed

+69
-135
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create Plugin ZIP
2+
on:
3+
push:
4+
tags:
5+
- 'v*' # Wird ausgeführt, wenn du ein neues Tag wie "v1.0" erstellst
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out Repository
12+
uses: actions/checkout@v3
13+
14+
- name: Erstelle ZIP-Archiv
15+
run: zip -r master.zip Octolapse/builds
16+
17+
- name: Release mit ZIP-Datei
18+
uses: softprops/action-gh-release@v1
19+
with:
20+
files: master.zip

.github/workflows/master.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Create master.zip
2+
on:
3+
push:
4+
branches:
5+
- master # Change to 'master' if your branch is named master
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v3
13+
14+
- name: Create ZIP Archive
15+
run: zip -r master.zip . -x "*.git*"
16+
17+
- name: Upload ZIP as Artifact
18+
uses: actions/upload-artifact@v4
19+
with:
20+
name: master-zip
21+
path: master.zip

builds/build_2025_06_19.zip

5.96 MB
Binary file not shown.

builds/readme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
here we create some builds

setup.py

Lines changed: 25 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,29 @@
11
# coding=utf-8
22
from setuptools import setup, Extension
3-
from distutils.command.build_ext import build_ext
4-
from distutils.ccompiler import CCompiler
5-
from distutils.unixccompiler import UnixCCompiler
6-
from distutils.msvccompiler import MSVCCompiler
7-
from distutils.bcppcompiler import BCPPCompiler
8-
from distutils.cygwinccompiler import CygwinCCompiler
9-
from distutils.version import LooseVersion
10-
from octoprint_octolapse_setuptools import NumberedVersion
3+
from setuptools.command.build_ext import build_ext
114
import sys
125
import versioneer
6+
import configparser # Ändere hier den Import
7+
138
########################################################################################################################
149
# The plugin's identifier, has to be unique
1510
plugin_identifier = "octolapse"
16-
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
1711
plugin_package = "octoprint_octolapse"
18-
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
19-
# plugin module
2012
plugin_name = "Octolapse"
21-
# The plugin's fallback version, in case versioneer can't extract the version from _version.py.
22-
# This can happen if the user installs from one of the .zip links in github, not generated with git archive
23-
fallback_version = NumberedVersion.clean_version(NumberedVersion.CurrentVersion)
24-
# Get the cleaned version number from versioneer
25-
plugin_version = NumberedVersion.clean_version(versioneer.get_versions(verbose=True)["version"])
26-
27-
# Depending on the installation method, versioneer might not know the current version
28-
# if plugin_version == "0+unknown" or NumberedVersion(plugin_version) < NumberedVersion(fallback_version):
29-
if plugin_version == "0+unknown":
30-
plugin_version = fallback_version
31-
try:
32-
# This generates version in the following form:
33-
# 0.4.0rc1+?.GUID_GOES_HERE
34-
plugin_version += "+u." + versioneer.get_versions()['full-revisionid'][0:7]
35-
except:
36-
pass
13+
fallback_version = "1.0.0"
14+
plugin_version = versioneer.get_versions()["version"]
3715

3816
plugin_cmdclass = versioneer.get_cmdclass()
39-
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
40-
# module
41-
plugin_description = """Create stabilized timelapses of your 3d prints. Highly customizable, loads of presets, lots of fun."""
42-
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
17+
plugin_description = """Create stabilized timelapses of your 3d prints. Highly customizable, loads of presets, lots of fun."""
4318
plugin_author = "Brad Hochgesang"
44-
# The plugin's author's mail address.
4519
plugin_author_email = "FormerLurker@pm.me"
46-
47-
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
4820
plugin_url = "https://github.com/FormerLurker/Octolapse"
49-
50-
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
5121
plugin_license = "AGPLv3"
52-
53-
# Any additional requirements besides OctoPrint should be listed here
54-
plugin_requires = ["pillow>=9.3,<11", "sarge", "six", "OctoPrint>=1.4.0", "psutil", "file_read_backwards",
55-
"setuptools>=6.0", "awesome-slugify>=1.6.5,<1.7"]
56-
57-
import octoprint.server
58-
if LooseVersion(octoprint.server.VERSION) < LooseVersion("1.4"):
59-
plugin_requires.extend(["flask_principal>=0.4,<1.0"])
60-
61-
# enable faulthandler for python 3.
62-
if (3, 0) < sys.version_info < (3, 3):
63-
print("Adding faulthandler requirement.")
64-
plugin_requires.append("faulthandler>=3.1")
65-
66-
# TODO: Get fontconfig to work
67-
#from sys import platform
68-
#if platform == "linux" or platform == "linux2":
69-
# plugin_requires.append("enum34")
70-
# plugin_requires.append("fontconfig")
22+
plugin_requires = ["pillow>=9.3,<11", "sarge", "six", "OctoPrint>=1.4.0", "psutil", "file_read_backwards", "setuptools>=6.0", "awesome-slugify>=1.6.5,<1.7"]
7123

7224
# --------------------------------------------------------------------------------------------------------------------
7325
# More advanced options that you usually shouldn't have to touch follow after this point
74-
# --------------------------------------d------------------------------------------------------------------------------
7526

76-
# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will
77-
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
78-
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
79-
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
8027
plugin_additional_data = [
8128
'data/*.json',
8229
'data/images/*.png',
@@ -86,92 +33,38 @@
8633
'data/webcam_types/*',
8734
'data/fonts/*'
8835
]
89-
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
9036
plugin_additional_packages = ['octoprint_octolapse_setuptools']
91-
92-
# Any python packages within <plugin_package>.* you do NOT want to install with your plugin
9337
plugin_ignored_packages = []
9438

9539
# C++ Extension compiler options
96-
# Set debug mode
9740
DEBUG = False
98-
# define compiler flags
9941
compiler_opts = {
100-
CCompiler.compiler_type: {
101-
'extra_compile_args': ['-O3', '-std=c++11'],
102-
'extra_link_args': [],
103-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
104-
},
105-
MSVCCompiler.compiler_type: {
106-
'extra_compile_args': ['/O2', '/fp:fast', '/GL', '/analyze', '/Gy', '/MD', '/EHsc'],
107-
'extra_link_args': [],
108-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
109-
},
110-
UnixCCompiler.compiler_type: {
111-
'extra_compile_args': ['-O3', '-std=c++11'],
112-
'extra_link_args': [],
113-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
114-
},
115-
BCPPCompiler.compiler_type: {
116-
'extra_compile_args': ['-O3', '-std=c++11'],
117-
'extra_link_args': [],
118-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
119-
},
120-
CygwinCCompiler.compiler_type: {
121-
'extra_compile_args': ['-O3', '-std=c++11'],
122-
'extra_link_args': [],
123-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
124-
}
42+
'extra_compile_args': ['-O3', '-std=c++11'],
43+
'extra_link_args': [],
44+
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
12545
}
12646

12747
if DEBUG:
12848
compiler_opts = {
129-
CCompiler.compiler_type: {
130-
'extra_compile_args': [],
131-
'extra_link_args': [],
132-
'define_macros': [('DEBUG_chardet', '1'), ('IS_PYTHON_EXTENSION', '1')]
133-
},
134-
MSVCCompiler.compiler_type: {
135-
'extra_compile_args': ['/EHsc', '/Z7'],
136-
'extra_link_args': ['/DEBUG'],
137-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
138-
},
139-
UnixCCompiler.compiler_type: {
140-
'extra_compile_args': ['-g'],
141-
'extra_link_args': ['-g'],
142-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
143-
},
144-
BCPPCompiler.compiler_type: {
145-
'extra_compile_args': [],
146-
'extra_link_args': [],
147-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
148-
},
149-
CygwinCCompiler.compiler_type: {
150-
'extra_compile_args': [],
151-
'extra_link_args': [],
152-
'define_macros': [('IS_PYTHON_EXTENSION', '1')]
153-
}
49+
'extra_compile_args': [],
50+
'extra_link_args': [],
51+
'define_macros': [('DEBUG_chardet', '1'), ('IS_PYTHON_EXTENSION', '1')]
15452
}
15553

15654
class build_ext_subclass(build_ext):
15755
def build_extensions(self):
15856
print("Compiling Octolapse Parser Extension with {0}.".format(self.compiler))
15957

160-
c = self.compiler
161-
opts = [v for k, v in compiler_opts.items() if c.compiler_type == k]
162-
for e in self.extensions:
163-
for o in opts:
164-
for attrib, value in o.items():
165-
getattr(e, attrib).extend(value)
58+
for ext in self.extensions:
59+
ext.extra_compile_args.extend(compiler_opts['extra_compile_args'])
60+
ext.extra_link_args.extend(compiler_opts['extra_link_args'])
61+
ext.define_macros.extend(compiler_opts['define_macros'])
16662
build_ext.build_extensions(self)
16763

16864
for extension in self.extensions:
169-
print("Build Extensions for {0} - extra_compile_args:{1} - extra_link_args:{2} - define_macros:{3}".format(
170-
extension.name, extension.extra_compile_args, extension.extra_link_args, extension.define_macros)
171-
)
172-
65+
print(f"Build Extensions for {extension.name} - extra_compile_args: {extension.extra_compile_args} - extra_link_args: {extension.extra_link_args} - define_macros: {extension.define_macros}")
17366

174-
## Build our c++ parser extension
67+
# Define the C++ Extension
17568
plugin_ext_sources = [
17669
'octoprint_octolapse/data/lib/c/gcode_position_processor.cpp',
17770
'octoprint_octolapse/data/lib/c/gcode_parser.cpp',
@@ -198,22 +91,19 @@ def build_extensions(self):
19891
language="c++"
19992
)
20093

201-
20294
additional_setup_parameters = {
20395
"ext_modules": [cpp_gcode_parser],
20496
"cmdclass": {"build_ext": build_ext_subclass}
20597
}
20698

207-
########################################################################################################################
99+
# Ensure OctoPrint's setuptools is available
208100
try:
209101
import octoprint_setuptools
210-
except:
211-
print("Could not import OctoPrint's setuptools, are you sure you are running that under "
212-
"the same python installation that OctoPrint is installed under?")
213-
import sys
214-
102+
except ImportError:
103+
print("Could not import OctoPrint's setuptools, are you sure you are running under the correct Python environment?")
215104
sys.exit(-1)
216105

106+
# Generate the setup parameters
217107
setup_parameters = octoprint_setuptools.create_plugin_setup_parameters(
218108
identifier=plugin_identifier,
219109
package=plugin_package,
@@ -231,8 +121,10 @@ def build_extensions(self):
231121
cmdclass=plugin_cmdclass
232122
)
233123

124+
# Merge additional setup parameters
234125
if len(additional_setup_parameters):
235126
from octoprint.util import dict_merge
236127
setup_parameters = dict_merge(setup_parameters, additional_setup_parameters)
237128

129+
# Run the setup function
238130
setup(**setup_parameters)

versioneer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ def get_config_from_root(root):
339339
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
340340
# the top of versioneer.py for instructions on writing your setup.cfg .
341341
setup_cfg = os.path.join(root, "setup.cfg")
342-
parser = configparser.SafeConfigParser()
342+
parser = configparser.ConfigParser()
343343
with open(setup_cfg, "r") as f:
344-
parser.readfp(f)
344+
parser.read_file(f)
345345
VCS = parser.get("versioneer", "VCS") # mandatory
346346

347347
def get(parser, name):

0 commit comments

Comments
 (0)