With distutils, "optional" C extension module error is fatal
Hi folks. I'm putting a little time into getting my treap module (like a dict, but always sorted by key) working with distutils. I want it to be able to compile and install the Cython version from an included .c file, or to fall back on a pure python version if that fails. I'm currently using: setup( name='treap', py_modules=[ 'treap', 'py_treap', 'nest', ], # ext_modules=cythonize("pyx_treap.pyx"), ext_modules=[Extension('pyx_treap', ['pyx_treap.c'], optional=True)], # setup_requires=[ # 'Cython' # ], version=version, description='Python implementation of treaps, ) ...plus a few more options to setup that don't seem relevant. If I run python3.6 setup.py build, I get: running build running build_py creating build creating build/lib.linux-x86_64-3.6 copying treap.py -> build/lib.linux-x86_64-3.6 copying py_treap.py -> build/lib.linux-x86_64-3.6 copying nest.py -> build/lib.linux-x86_64-3.6 running build_ext building 'pyx_treap' extension creating build/temp.linux-x86_64-3.6 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.6m -c pyx_treap.c -o build/temp.linux-x86_64-3.6/pyx_treap.o pyx_treap.c:4:10: fatal error: Python.h: No such file or directory #include "Python.h" ^~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 So it seems like despite using Extension('pyx_treap', ['pyx_treap.c'], optional=True), the cython version is not optional. Am I missing something? Why doesn't it just continue with the pure python modules? I realize I could install python3.6-dev or similar to eliminate the error, but I don't want to assume the user knows that. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
'%Y' in strftime() vs. strptime()
Hi list, I've just stumbled upon a strange phaenomenon and I'm wondering if it's a bug. Short and sweet: Python 3.7.3 (default, Oct 7 2019, 12:56:13) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime as d >>> x = d(1, 1, 1) >>> x.strftime("%Y-%m-%d") '1-01-01' >>> d.strptime(x.strftime("%Y-%m-%d"), "%Y-%m-%d") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.7/_strptime.py", line 577, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/usr/lib/python3.7/_strptime.py", line 359, in _strptime (data_string, format)) ValueError: time data '1-01-01' does not match format '%Y-%m-%d' >>> d.strptime("0001-01-01", "%Y-%m-%d") datetime.datetime(1, 1, 1, 0, 0) I.e. for years that are not 4 digits longs, strftime() produces no leading zeros for the '%Y' replacement, but strptime() requires leading zeros. Is this expected behavior? Shouldn't %Y be consistent across both? All the best, Johannes -- https://mail.python.org/mailman/listinfo/python-list
Re: '%Y' in strftime() vs. strptime()
On 12/29/19, Johannes Bauer wrote: > x = d(1, 1, 1) > x.strftime("%Y-%m-%d") > '1-01-01' The default padding depends on the platform strftime. POSIX strftime [1] supports an extension of ISO C that allows specifying the "0" pad character and minimum field width, e.g. "%04Y-%02m-%02d". [1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html -- https://mail.python.org/mailman/listinfo/python-list
name 'sys' is not defined
Deal all, Could you please help me how can I avoid this problem my Jupyter Notebook code was help pls # init a treemix analysis object with some param arguments tmx = ipa.treemix( data=data, imap=imap, minmap=minmap, seed=123456, root="Petronia_petronia", m=2, ) error NameError Traceback (most recent call last) in 6 seed=123456, 7 root="Petronia_petronia", > 8 m=2, 9 ) ~/opt/miniconda3/envs/py3/lib/python3.6/site-packages/ipyrad/analysis/treemix.py in __init__(self, data, name, workdir, imap, minmap, seed, quiet, raise_root_error, binary, *args, **kwargs) 118 119 # others --> 120 self.binary = os.path.join(sys.prefix, "bin", "treemix") 121 self.binary = (binary if binary else self.binary) 122 self.raise_root_error = raise_root_error NameError: name 'sys' is not defined -- https://mail.python.org/mailman/listinfo/python-list
Re: name 'sys' is not defined
On 2019-12-30 7:20 AM, safiq...@gmail.com wrote: Deal all, Could you please help me how can I avoid this problem my Jupyter Notebook code was help pls [snip] NameError: name 'sys' is not defined I know nothing about Jupyter Notebook but somewhere, usually at the top, you have to add this line - import sys HTH Frank Millman -- https://mail.python.org/mailman/listinfo/python-list