I am generating a Python package on RHEL6 (with Python2.6), and trying to deploy it to a RHEL7 server (Python2.7). The package includes scripts generated with entry_points/console_scripts.
However, the generated scripts have the specific python2.6 version in the shebang, as in:
#!/usr/bin/env python2.6
How can I override or disable this so it just generates:
#!/usr/bin/env python
entry_points = {
'console_scripts':[
...
]
},
options = {
'build_scripts': {
'executable': '/usr/bin/env python',
},
},
Related
For whatever reason, Pylance has started to refuse to recognize libraries such as numpy and tcod, even though running the command "pip list" shows that I have installed them on my machine.
This problem began happening two days ago, even though it was fine the day before that.
The error message reads, "Import x could not be resolved Pylance(reportMissingImports)"
Running the command "python -m site" returns the following information:
sys.path = [
'/home/username',
'/usr/lib64/python38.zip',
'/usr/lib64/python3.8',
'/usr/lib64/python3.8/lib-dynload',
'/home/username/.local/lib/python3.8/site-packages',
'/usr/lib64/python3.8/site-packages',
'/usr/lib/python3.8/site-packages',
]
USER_BASE: '/home/username/.local' (exists)
USER_SITE: '/home/username/.local/lib/python3.8/site-packages' (exists)
The problem happens in all of my vscode workspaces.
This is what my settings file in my current workspace looks like:
{
"python.autoComplete.extraPaths": [
"/usr/lib64/python3.8/site-packages",
"/home/username/workspace/python",
"/home/username/.var/app/com.visualstudio.code/data/python/lib/python3.9/site-packages",
"/username/bin/python3.8",
"/home/username",
"/usr/lib64/python38.zip",
"/usr/lib64/python3.8",
"/usr/lib64/python3.8/lib-dynload",
"/home/username/.local/lib/python3.8/site-packages",
"/usr/lib64/python3.8/site-packages",
"/usr/lib/python3.8/site-packages",
"/usr/local/lib64/python3.8/site-packages",
"/var/data/python/bin"
],
"python.defaultInterpreterPath": "/home/python38/python",
"python.analysis.extraPaths": [
"/sur/lib64/python3.8/site-packages",
"/home/username/workspace/python",
"/home/username/.var/app/com.visualstudio.code/data/python/lib/python3.9/site-packages",
"/username/bin/python3.8",
"/home/username",
"/usr/lib64/python38.zip",
"/usr/lib64/python3.8",
"/usr/lib64/python3.8/lib-dynload",
"/home/username/.local/lib/python3.8/site-packages",
"/usr/lib64/python3.8/site-packages",
"/usr/lib/python3.8/site-packages",
"/usr/local/lib64/python3.8/site-packages",
"/var/data/python/bin"
]
}
Here's my current workspace file:
{
"folders": [
{
"path": "."
}
],
"settings": {}
}
Aside from the interpreter available at the default interpreter path, VSCode offers the the following available interpreters:
Python 3.9.7 (Recommended), located at /bin/python
Python 3.9.7, located at /sbin/python
Python 3.9.7, located at /usr/bin/python
Python 3.9.7, located at /usr/sbin/python
I've tried all of them as well as the entry for "python.defaultInterpreterPath" with no luck.
I am learning how to create GTK applications in python and I am using Gnome Builder IDE installed through flatpak.
I wanted to use the python package requests in my application, so I added:
{
"name": "pip-install",
"buildsystem": "simple",
"build-options": {
"build-args": [
"--share=network"
]
},
"build-commands": [
"pip3 install requests"
]
}
To my modules list inside the flatpak .json file of the project.
When I try to build the project I get the following error when the command runs pip:
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/usr/lib/python3.7/site-packages/idna-2.9.dist-info'
One solution would be the dependency being installed on user space, but how to do that?
I've successfully used this snippet before:
{
"name": "requests",
"buildsystem": "simple",
"build-options": {
"build-args": [
"--share=network"
]
},
"build-commands": [
"pip3 install --prefix=/app --no-cache-dir requests"
]
}
The /app directory is writable and the rest of your application should be there as well.
I want to build and deploy a hello world using a homebrewed python + py2app.
Build machine: MacOS X 10.12.6
Target machine: MacOS X 10.11
Following many posts I modified the python.rb formula by setting inside MACOSX_DEPLOYMENT_TARGET=10.10 to insure backward compatibility with older macos kernels.
The build is OK but when I run the application on the target machine it crashes due to an Illegal Instruction 4. Digging a bit further, this crash is raised by calling the python bundled with the application.
Following that post this might be due to the very nature of the homebrewed python that might be built with hardware specific optimization flags. Checking the output of my command
brew install -v --build-from-source python
I do not see any exotic flag but I can confirm that the deployment works when the application is built with a python that does not come from brew (e.g. from www.python.org).
Would you have any idea from where this problem comes from and how to modify the python brew recipe to make it work ?
Here are my codes:
hello.py
#!/usr/bin/env python2.7
if __name__ == "__main__":
print "Hello world"
build.py
import sys
import os
from setuptools import setup
version = "1.0"
APP = ['hello.py']
PLIST = {
u'CFBundleName': u'Hello',
u'CFBundleShortVersionString': version,
u'CFBundleVersion': version,
u'CFBundleIdentifier': u'-',
u'LSApplicationCategoryType': u'public.app-category.science'
}
OPTIONS = {
'argv_emulation': True,
'plist': PLIST,
'bdist_base': './Build/build',
'dist_dir': './Build/dist',
'graph': False,
'xref': False
}
setup(
name="hello",
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app']
)
I'm a beginner in the process of learning how to create a skeleton directory complete with automated tests, install scripts etc. I am a fair ways from understanding all of this process despite the amount of time spent attempting to.
At this point in time all I can do in relation to this is make a source distribution and executable installer for a single module.
The format of my setup.py (using a template provided by my beginners book) for my skeleton project is:
#!/usr/bin/env
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
"description": "asks a question",
"author": "David",
"url": "none",
"download_url": "none",
"author email": "dmt257257#gmail.com",
"version": "0.1",
"install_requires": ["nose"],
"packages": ["ask_main", "tests"],
"scripts": [],
"name": "ask"
}
setup(**config)
However I see the format on python.org as:
#!/usr/bin/env python
from distutils.core import setup
setup(name='Distutils',
version='1.0',
description='Python Distribution Utilities',
author='Greg Ward',
author_email='gward#python.net',
url='https://www.python.org/sigs/distutils-sig/',
packages=['distutils', 'distutils.command'],
)
Can anyone explain why you would use the config method? What is '**' doing in setup(**config)?
I have a medium-size PyQT5 desktop application that has been working fine with py2app. I want to incorporate Esky so that the app can update itself, but the app terminates during startup (before displaying the main window) with a log entry that says "HelloApp Error" (where "HelloApp" is the name of my application).
I've created a small test case that reproduces the problem that is available at https://github.com/markmont/esky-package-question
The test-case app has the following structure:
HelloApp/
HelloApp/
HelloApp.py
helloform
__init__.py
setup.py
setup.py contains:
from esky import bdist_esky
from distutils.core import setup
PY2APP_OPTIONS = {
'argv_emulation': True,
'includes': [ 'sip', 'PyQt5', 'helloform' ],
'qt_plugins': [ '*' ]
}
ESKY_OPTIONS = {
"freezer_module": "py2app",
"freezer_options": PY2APP_OPTIONS,
"includes": [ 'sip', 'PyQt5', 'helloform' ]
}
HelloApp = bdist_esky.Executable( "HelloApp/HelloApp.py", gui_only=True )
setup(
name='HelloApp',
version = "2014060301",
data_files=[],
options = { "bdist_esky": ESKY_OPTIONS },
scripts=[ HelloApp ]
)
HelloApp.py contains the statement from helloform import Form -- this appears to be what is causing the app to fail to start with the error "HelloApp Error", as if I remove that statement and paste in the contents of helloform/init.py the application starts up and works properly.
Also, if I move everything into a single directory and adjust the paths in setup.py, then the problem does not occur -- Esky finds helloform.py (formerly named helloform/init.py), includes it, and the application starts up and works properly:
HelloApp/
HelloApp.py
helloform.py # formerly ./HelloApp/helloform/__init__.py
setup.py
...but putting everything in single directory is not a scalable solution for a medium-to-large application.
There are no error messages in the output of python setup.py bdist_esky when the problem occurs, and I have not found the answer in the Esky documentation or in various examples on the web.
The full error from /var/log/system.log is:
2014-06-03 13:03:07.100 HelloApp[14968]: HelloApp Error
I'm assuming that I'm not using Esky's includes option properly in setup.py, but I've got no clue as to how to fix this -- can anyone help?
Other possibly relevant details: MacOS X 10.9 Mavericks, Python 2.7.6 (local build), qt-5.3.0 opensource, sip 4.16, PyQT 5.3.0 (GPL), py2app 0.8.1 patched to support PyQT5, and the latest version of Esky from GitHub.
Thanks in advance!
I've solved this problem -- the problem was due to my limited knowledge of Python distutils and setuptools. Since things "just worked" with py2app (which was using setuptools), I assumed that the problem was with how Etsy was configured when the problem was really with how I was using distutils.
The problem was that helloworld.py was not being copied into the frozen app.
The solution involved restructuring the files and changing the disutils configuration to explicitly add HelloApp as a package.
New file structure:
HelloApp/
hello.py # formerly HelloApp.py
HelloApp/
__init__.py
helloform.py
setup.py
New setup.cfg:
from esky import bdist_esky
from distutils.core import setup
PY2APP_OPTIONS = {
'argv_emulation': True,
'includes': [ 'sip', 'PyQt5' ],
'qt_plugins': [ '*' ]
}
ESKY_OPTIONS = {
"freezer_module": "py2app",
"freezer_options": PY2APP_OPTIONS,
"includes": [ 'sip', 'PyQt5' ]
}
HelloApp = bdist_esky.Executable( "hello.py", gui_only=True )
setup(
name='hello',
version = "2014060301",
data_files=[],
options = { "bdist_esky": ESKY_OPTIONS },
scripts=[ HelloApp ],
packages=[ 'HelloApp' ],
)