Platform independence in pip requirement files [duplicate] - python

This question already has answers here:
Operating-system specific requirements with pip
(2 answers)
Closed 3 years ago.
How can I get platform specific things into a requirements file? Some windows packages are needed instead of their linux counterparts.
WinPExpect vs pexpect
pywin32 isn't needed on linux but is needed by winpexpect
Any idea of how you could deal with that?
I've thought about a small python script that would detect the platform and deal with it by running pip with different platform specific files as well as the "main" requirements file. Seems like maybe it should be simpler.

pip requirements do not allow it.
There is a discusion about this feature in distutils2. See PEP 345 for more metadata information.
More info about distutils2 and metadata: http://packages.python.org/Distutils2/library/distutils2.metadata.html
I don't know the state of PEP 345 and package installers.

Since this comes up first in a stackoverflow search for [python] requirements different platforms allow me to point to this later question's answer and this one's; especially since the distutils2 links in the other answer here are now dead.

Related

Automatic Python version compatability checker? [duplicate]

This question already has answers here:
How do I find out all previous versions of python with which my code is compatible
(4 answers)
How to detect minimum version of python that a script required
(2 answers)
Closed 1 year ago.
I am developing a Python package. It occurred to me that as my codebase changes that it would be useful to be able to automatically check what versions of Python are compatible. In general I could see this being a hard problem, but it seems to me like a naive approach that only looks at core syntax (f-formatting of strings, type hints, etc) to give an estimate of the earliest compatible version would still be useful.
Is there an automatic way to do this?
write tests that use your code from the package
Decide what versions of python you to support
set up continuous integration (CI) that runs your tests on the the those versions of python you support.

How can I force setuptools detect that my package is platform specific? [duplicate]

This question already has answers here:
How to force a python wheel to be platform specific when building it?
(5 answers)
Closed 3 years ago.
I'm working on improving the setup.py script for an open source package that supports various platforms.
On Linux, the package defines a setuptools.Extension for some C code that needs to be built alongside the Python code. This produces a wheel whose name indicates that it is only compatible with a particular version of CPython and a particular OS and hardware architecture.
On macOS, however, it invokes xcodebuild manually, and then includes that framework in eager_resources. Setuptools cannot detect that the resulting wheel is platform-specific, so it gives it a generic filename.
If it's possible to, I'd prefer to have setuptools build the Xcode project for me, but if not, can I somehow tell it that this is platform-specific? I was thinking I could include an empty extension, but that seems hacky.
This is the hacky way:
# Add a dummy extension so setuptools knows this is platform-specific
try:
os.mkdir('build')
except:
pass
open('build/dummy.c', 'w').close()
mod1 = Extension('package._dummy', sources=['build/dummy.c'])
ext_modules.append(mod1)

Python analog for linux "file" command [duplicate]

This question already has an answer here:
Is there a python-equivalent of the unix "file" utility?
(1 answer)
Closed 9 years ago.
I'm looking for file linux command analog made in Python. It should provide information about file type as described in man file. Minimal feature set I'm looking for is to determine if file is raw or text (human-readable) one. Wrapper library will be good suggestion.
I know, I can run file as subprocess and grab it's output to determine file type. But my program is supposed to parse thousands of files and I'm afraid of very long execution time in this case.
you need to check the "magic" byte of the file, and I was about to tell you about:
python-magic
when it occured to me that this question should already have been answered on SO, and it has.
N.B.: I'm not listing pymagic as the other post does, as it did not get any update since 0.1 which looks quite old (even the source website is down).
for OSX:
brew install libmagic
pip install python-magic
python
>>> magic.from_file('test.py')
'Python script, ASCII text executable'

Is it possible to deploy python3 applications as self-executables in Mac, linux and Windows ? how? [duplicate]

This question already has answers here:
Py2exe for Python 3.0
(5 answers)
Closed 9 years ago.
considering another stackoverflow question that was posted at 2009 and tools like py2exe that haven't been updated since 2008, is it possible ?
I am creating an application that saves and retrieves data from an sqlite db and I want to distribute it to my colleagues without having them to install python libraries and execute .py files. The application uses tkinter as a GUI library.
Is that possible in 2013 ?
Yes, it is possible.
You may want to use the tool called cx_Freeze, it creates an executable from a python3 application (including all the libraries it uses), and it does this cross-platform.
The only thing you need to know is that in order to create, let's say a windows executable, you must run cx_Freeze in windows. (same goes for MAC, linux, etc..)
You can read here about the usage of the script.
Good Luck!

How to watch a directory for changes? [duplicate]

This question already has answers here:
Monitoring contents of files/directories? [duplicate]
(5 answers)
Closed 10 years ago.
Could not find anything in python core to do this. Can anyone recommend a library or "battery" to do this? Ideally I would like this to be portable but it's OK if it is available only for Unix (my server).
On Linux, you could be interested in pyinotify
https://github.com/seb-m/pyinotify
Other related libraries:
http://people.gnome.org/~veillard/gamin/python.html
Python FAM interface: http://python-fam.sourceforge.net/
http://gorakhargosh.github.com/watchdog/
I don't think there's something portable for this kind of requirement.
That's too close to the OS IMO.
Otherwise for Linux, there's pynotify.
pyinotify is a binding for Linux inotify kernel filesystem notification subsystem.
Works quite well.
I was just looking for a python package that watches file modifications. Just stumbled upon pywatch and it might just be what you're looking for. It's very simple, but does what I need (fixing pyScss' lack of a watcher).
http://pypi.python.org/pypi/pywatch

Categories