mirror of
https://github.com/pypiserver/pypiserver
synced 2024-11-09 16:45:51 +01:00
make pypiserver run on python 3.x
unfortunately the tests do not work, since twill isn't ported yet.
This commit is contained in:
parent
1b2bb1a924
commit
1866a7ad6e
@ -172,7 +172,7 @@ def bad_url(prefix):
|
||||
|
||||
|
||||
def usage():
|
||||
print """pypi-server [OPTIONS] [PACKAGES_DIRECTORY]
|
||||
sys.stdout.write("""pypi-server [OPTIONS] [PACKAGES_DIRECTORY]
|
||||
start PyPI compatible package server serving packages from
|
||||
PACKAGES_DIRECTORY. If PACKAGES_DIRECTORY is not given on the
|
||||
command line, it uses the default ~/packages. pypiserver scans this
|
||||
@ -226,7 +226,7 @@ The following additional options can be specified with -U:
|
||||
allow updating to unstable version (alpha, beta, rc, dev versions)
|
||||
|
||||
Visit http://pypi.python.org/pypi/pypiserver for more information.
|
||||
"""
|
||||
""")
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
@ -262,7 +262,7 @@ def main(argv=None):
|
||||
sys.exit("unknown server %r. choose one of %s" % (v, ", ".join(server_names.keys())))
|
||||
server = v
|
||||
elif k == "--version":
|
||||
print "pypiserver %s" % __version__
|
||||
sys.stdout.write("pypiserver %s\n" % __version__)
|
||||
sys.exit(0)
|
||||
elif k == "-U":
|
||||
command = "update"
|
||||
@ -297,8 +297,7 @@ def main(argv=None):
|
||||
|
||||
server = server or "auto"
|
||||
debug(True)
|
||||
print "This is pypiserver %s serving %r on %s:%s" % (__version__, root, host, port)
|
||||
print
|
||||
sys.stdout.write("This is pypiserver %s serving %r on %s:%s\n\n" % (__version__, root, host, port))
|
||||
run(host=host, port=port, server=server)
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ def find_updates(pkgset, stable_only=True):
|
||||
|
||||
need_update = []
|
||||
|
||||
print "checking %s packages for newer version" % len(pkgname2latest),
|
||||
sys.stdout.write("checking %s packages for newer version\n" % len(pkgname2latest),)
|
||||
for count, (pkgname, file) in enumerate(pkgname2latest.items()):
|
||||
if count % 40 == 0:
|
||||
write("\n")
|
||||
@ -76,21 +76,20 @@ def find_updates(pkgset, stable_only=True):
|
||||
|
||||
no_releases = list(no_releases)
|
||||
no_releases.sort()
|
||||
print "no releases found on pypi for", ", ".join(no_releases)
|
||||
print
|
||||
sys.stdout.write("no releases found on pypi for " + ", ".join(no_releases) + "\n\n")
|
||||
return need_update
|
||||
|
||||
|
||||
def update(pkgset, destdir=None, dry_run=False, stable_only=True):
|
||||
need_update = find_updates(pkgset, stable_only=stable_only)
|
||||
for x in need_update:
|
||||
print "# update", x.pkgname, "from", x.version, "to", x.latest_version
|
||||
sys.stdout.write("# update " + x.pkgname + " from " + x.version + "to" + x.latest_version + "\n")
|
||||
|
||||
cmd = ["pip", "-q", "install", "-i", "http://pypi.python.org/simple",
|
||||
"-d", destdir or os.path.dirname(os.path.join(pkgset.root, x.path)),
|
||||
"%s==%s" % (x.pkgname, x.latest_version)]
|
||||
print " ".join(cmd)
|
||||
print
|
||||
|
||||
sys.stdout.write(" ".join(cmd) + "\n\n")
|
||||
if not dry_run:
|
||||
os.spawnlp(os.P_WAIT, cmd[0], *cmd)
|
||||
|
||||
|
23
setup.py
23
setup.py
@ -1,13 +1,27 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import os
|
||||
from distutils.core import setup
|
||||
import sys, os
|
||||
extrakw = {}
|
||||
|
||||
try:
|
||||
from setuptools import setup
|
||||
extrakw["use_2to3"] = True
|
||||
except ImportError:
|
||||
if sys.version_info >= (3, 0):
|
||||
raise
|
||||
from distutils.core import setup
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
exec("def do_exec(co, loc): exec(co, loc)\n")
|
||||
else:
|
||||
exec("def do_exec(co, loc): exec co in loc\n")
|
||||
|
||||
|
||||
def get_version():
|
||||
d = {}
|
||||
try:
|
||||
execfile("pypiserver/__init__.py", d, d)
|
||||
do_exec(open("pypiserver/__init__.py").read(), d)
|
||||
except (ImportError, RuntimeError):
|
||||
pass
|
||||
return d["__version__"]
|
||||
@ -38,4 +52,5 @@ setup(name="pypiserver",
|
||||
"Programming Language :: Python :: 2.6",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Topic :: Software Development :: Build Tools",
|
||||
"Topic :: System :: Software Distribution"])
|
||||
"Topic :: System :: Software Distribution"],
|
||||
**extrakw)
|
||||
|
Loading…
Reference in New Issue
Block a user