Comments (6)
I found that you can still get this to work with services but it is missing in the documentation. I will see if I can add it to the migration document.
myservice = Target(
script="myservice.py"
)
freeze(
console = [myservice],
version_info={'version':'1.0.0'}
)
from py2exe.
@caesimsol As you noted the feature does not work, it probably never worked properly with Python 3.x, and was officially dropped two major versions before. There is no workaround to build directly a COM server from py2exe
, I am sure you can find some workaround to build a service starting from a console binary.
@mbokil Thanks for the workaround but, with this you would just build a console binary. Creating a service still requires extra work that has to be carried out manually with other tools. Therefore, I would advice not to add this in the documentation of py2exe
.
from py2exe.
@albertosottile I think you might have misread the posters question. They wanted to know if the freeze API supports building a console based service. It clearly does support this feature I used it just the other day and then packaged up my project using Inno Setup and distributed the service to client Windows systems. I suggest keeping an example of building a console service like I listed above. It was hard to figure out how to do it with the freeze API but it definitely works. Thanks for you work on this project. I deployed my Windows service to 56K machines in our company. Zero reported defects.
from py2exe.
I am sorry, but I do not understand. What you are building is a console application, a binary that you can run from the terminal. What @caesimsol is asking for, and what the old service
argument was doing is generating a Windows Service directly. py2exe
does not support this anymore. However, you can of course build a console exe and pack it/deploy it as a service manually or with other tools, e.g. NSSM.
Freezing a console application is of course supported and, I think, well documented in the freeze
API documentation https://github.com/py2exe/py2exe/blob/master/docs/py2exe.freeze.md . I am not sure in what your example differs from the existing documentation.
Thanks for you work on this project. I deployed my Windows service to 56K machines in our company. Zero reported defects.
Stories like these are always appreciated, Thank you for having reported this here.
from py2exe.
I have to comment that with this definition in Python 3.10:
setup(
data_files = Mydata_files,
name='LimitLS',
description = 'LIMIT License Server 2023',
version=version_string,
maintainer='CAE Simulation & Solutions GmbH',
author='Michael Lindner, Svetoslav Inkolov',
options={"py2exe": {"compressed": 1,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
# "dll_excludes": dll_excludes_win_10,
"bundle_files": 3,
"dist_dir": "service",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
zipfile = 'limit_server.dll',
version_info={'version':version_string,
'description':'LIMIT License Server 2023',
'product_name':'LimitLS',
'copyright':'© CAE Simulation & Solutions GmbH'},
#windows=[{
#console=[{
service=[{
'modules':'server'#,
#'icon_resources':[(1, 'icon.ico')]
}]
)
I got an service file named "server.exe" as a console module with a zipfile 'limit_server.dll' and it works perfectly fine.
The service was then installed with:
@echo off
set LLSDIR=%~dp0
service\server.exe -install
sc config LimitLS start= auto
In Python 3.11 this is unfortunately not possible anymore :'-(
from py2exe.
I just wanted to add that in Python 3.10 it was possible to set up or assign a value to the service parameter:
def patch_distutils():
import distutils.dist
import distutils.core
import distutils.command
import sys
from . import distutils_buildexe
class Distribution(distutils.dist.Distribution):
def __init__(self, attrs):
self.ctypes_com_server = attrs.pop("ctypes_com_server", [])
self.com_server = attrs.pop("com_server", [])
self.service = attrs.pop("service", [])
self.windows = attrs.pop("windows", [])
self.console = attrs.pop("console", [])
self.isapi = attrs.pop("isapi", [])
self.zipfile = attrs.pop("zipfile", "library.zip")
distutils.dist.Distribution.__init__(self, attrs)
distutils.core.Distribution = Distribution
distutils.command.__all__.append('py2exe')
sys.modules['distutils.command.py2exe'] = distutils_buildexe
and in the Python 3.11 py2exe variant it is not possible anymore to assign anything to the service parameter:
console_targets = runtime.fixup_targets(console, "script")
for target in console_targets:
target.exe_type = "console_exe"
windows_targets = runtime.fixup_targets(windows, "script")
for target in windows_targets:
target.exe_type = "windows_exe"
# support the old dictionary structure with a global 'py2exe' key
if 'py2exe' in options:
options = options['py2exe']
runtime_options = Namespace(
compress = options.get("compressed", 0),
unbuffered = options.get("unbuffered", 0),
optimize = options.get("optimize", 0),
includes = options.get("includes", []),
excludes = options.get("excludes", []),
packages = options.get("packages", []),
dll_excludes = options.get("dll_excludes", []),
bundle_files = options.get("bundle_files", 3),
script = console_targets + windows_targets,
service = [],
com_servers = [],
destdir = options.get("dist_dir", "dist"),
libname = zipfile,
verbose = options.get("verbose", 0),
report = False,
summary = False,
data_files = data_files,
version_info = {},
)
from py2exe.
Related Issues (20)
- pythoncom and pywintypes module import issue HOT 8
- Can't install HOT 4
- setuptools / pkg_resources now also needs `platformdirs` HOT 7
- setuptools >= 67: pyparsing has been removed from pkg_resources HOT 4
- Packages with .libs directories result in don't work HOT 6
- Link on the py2exe wiki page does not go anywhere HOT 2
- Missing LICENSE in wheels HOT 4
- AssertionError with Python embeddable package HOT 1
- Py_OptimizeFlag not set correctly during Python initialization
- OSError: [WinError 87] The parameter is incorrect. HOT 2
- PYTHONPATH module location HOT 1
- Exe is created by doesn't run (opens then closes)
- Simple pygame example tries to lookup files inside of `library.zip` HOT 1
- Support Python 3.12 HOT 23
- Impossible to specify different version info for each of the binaries with the new freeze API. HOT 3
- pynput import break the file HOT 1
- PYTHONIOENCODING is ignored
- pendulum package doesn't initialize when unpacking from zipfile
- add version for python 3.12 too
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py2exe.