我的存储库包含我自己的 python 模块和它的依赖项之一的子模块,它有自己的 setup.py。
我想在安装我自己的库时调用依赖项的 setupy.py,这怎么可能?
我的第一次尝试:
$ tree
.
??? dependency
? ??? setup.py
??? mylib
??? setup.py
$ cat mylib/setup.py
from setuptools import setup
setup(
name='mylib',
install_requires= ["../dependency"]
# ...
)
$ cd mylib && python setup.py install
error in arbalet_core setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'../depen'"
Run Code Online (Sandbox Code Playgroud)
但是install_requires不接受路径。
我的第二次尝试是使用dependency_links=["../dependency"]withinstall_requires=["dependency"]但是 Pypi 中已经存在同名的依赖项,因此 setuptools 尝试使用该版本而不是我的版本。
什么是正确/最干净的方法?
我使用一个单独的线程pygame.event.get()在 Ubuntu 上调用了很长时间,没有任何问题。但是 MacOS 会抛出异常'NSInternalInconsistencyException', reason: 'nextEventMatchingMask should only be called from the Main Thread!';和 Windows 报告窗口(Not answering)在正常执行几秒钟后,我假设有相同的解释,这意味着 Linux 与其他操作系统不同,可以容忍这种软件设计。
是否有任何解决方法可以在单独的线程中保持清空事件队列,或者这是否基本上意味着 python 2.7 上的 pygame 1.9.1 根本无法以这种方式工作?
我知道 GUI 事件通常在主线程中处理,但我的 Python 库旨在与 ipython 一起使用。根据设计,主线程,即用户的 ipython 单元可能不执行任何操作或 CPU 贪婪的循环,因此它无法处理pygame.event.get().
我使用带有 setuptools 的命名空间在两个不同的存储库中分发相同的模块。我们的目标是获得mymodule.one和mymodule.two安装,知道的内容one和two来自不同的回购协议。但这看起来像是两个setup.py互相扫过的内容。
??? repo1
? ??? mymodule
? ? ??? __init__.py
? ? ??? one
? ? ??? __init__.py
? ??? setup.py
??? repo2
??? mymodule
? ??? __init__.py
? ??? two
? ??? __init__.py
??? setup.py
Run Code Online (Sandbox Code Playgroud)
命名空间具有__init__.py以下内容:
test$ cat repo1/mymodule/__init__.py
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
test$ cat repo2/mymodule/__init__.py
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
Run Code Online (Sandbox Code Playgroud)
该setup.py声明相同的名称:
test$ cat repo1/setup.py
#!/usr/bin/env …Run Code Online (Sandbox Code Playgroud) 我无法理解为什么我的SIGINT从未被下面的代码所捕获.
#!/usr/bin/env python
from threading import Thread
from time import sleep
import signal
class MyThread(Thread):
def __init__(self):
Thread.__init__(self)
self.running = True
def stop(self):
self.running = False
def run(self):
while self.running:
for i in range(500):
col = i**i
print col
sleep(0.01)
global threads
threads = []
for w in range(150):
threads.append(MyThread())
def stop(s, f):
for t in threads:
t.stop()
signal.signal(signal.SIGINT, stop)
for t in threads:
t.start()
for t in threads:
t.join()
Run Code Online (Sandbox Code Playgroud)
要清理这段代码,我更喜欢尝试/除了join()并在异常情况下关闭所有线程,这会有用吗?
python ×4
setuptools ×2
dependencies ×1
distutils ×1
events ×1
ipython ×1
namespaces ×1
pygame ×1
python-3.x ×1
setup.py ×1
sigint ×1