Check-in [d275f1986b]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add crude Python bdist_wheel generation method. Only tested with singular packages. Hack to relocate single module scripts into pkgname subdir + stub __init__.py. Otherwise relies on -s src or -s dir file relocation. Would require more complete `setup.py` creation to package anything more useful. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | trunk |
| Files: | files | file ages | folders |
| SHA1: |
d275f1986b573406767b4d8aac35d0f3 |
| User & Date: | mario 2015-05-05 12:07:38 |
Context
|
2015-05-05
| ||
| 12:07 | Add crude Python bdist_wheel generation method. Only tested with singular packages. Hack to relocate single module scripts into pkgname subdir + stub __init__.py. Otherwise relies on -s src or -s dir file relocation. Would require more complete `setup.py` creation to package anything more useful. Leaf check-in: d275f1986b user: mario tags: trunk | |
| 12:05 | Update notes, no longer using custom etcfiles() scanning; default to --config-files list. check-in: 2a6b544a7a user: mario tags: trunk | |
Changes
Added lib/fpm/package/pip.rb.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# encoding: utf-8
# api: fpm
# title: pip/python package
# description: Generates a setup.py for packaging Python modules
# version: 0.1
#
# Just generates a bland "setup.py" for all files assembled per
# input modules.
#
# Counterpart to `-s python` module. Will probably be merged later.
#
require "erb"
#require "backports" # gem backports
require "fpm/package"
#require "fpm/package/dir"
require "fpm/util"
#require "fileutils"
require "json"
# Output only
class FPM::Package::Pip < FPM::Package
# Run bdist_wheel
def output(output_path)
output_check(output_path)
pipfn = File.absolute_path(output_path)
# Let setuptools/wheel build it
::Dir::chdir(staging_path) do
basedir()
stubs()
attrs()
setup_py()
edit_file("setup.py") if attributes[:edit?]
safesystem("python", "setup.py", "bdist_wheel", "-d", build_path)
end
# Find and move output package
files = ::Dir.glob(build_path+"/*.whl")
if files.length() != 1
logger.error("More than one output file!", files)
else
safesystem("mv", files[0], ".")
logger.warn("Output filename", {:files => File.basename(files[0])})
end
end # def output
# Make package basedir if none exists
def basedir()
if not File.exists?(name)
safesystem("mkdir", name)
`mv * #{name}`
end
end
# split some attributes
def attrs()
if maintainer =~ /<?(\S+?@\S+(?<!>))>?/
@author_email = $1
else
@author_email = 'nobody@example.org'
end
@author = maintainer.sub(/\s*\S+@\S+/, '')
if not @author.length()
@author = @author_email.sub(/@.+/, "")
end
end
# setup_py
def setup_py()
if not File.exists?("setup.py")
File.open("setup.py", "w") do |f|
f.write template("pip.erb").result(binding)
end
end
if not File.exists?("setup.cfg")
File.open("setup.cfg", "w") do |f|
f.write "[bdist_wheel]\nuniversal=1\n"
end
end
end
# empty files
def stubs()
for fn in ["README.rst", "README.txt", "MANIFEST.in", "setup.cfg", name+"/__init__.py"]
if not File.exists?(fn)
File.open(fn, "w") do |f|
f.write ""
end
end
end
end
end # class FPM::Package::Pip
|
Added templates/pip.erb.
> > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# encoding: utf-8
# type: wrapper
# description: fpm/xpm -t pip generated setup.py
from setuptools import setup
setup(
name="<%= name %>",
version="<%= version %>",
author="<%= @author %>",
author_email="<%= @author_email %>",
packages=["<%= name %>"],
# include_package_data=True,
url="<%= url %>",
license="<%= license %>",
description=<%= (description or "").split("\n")[0].to_json %>,
long_description=<%= (description).to_json %>,
install_requires=<%= dependencies.collect { |e| e.sub(/\W.*$/, "") }.to_json %>,
)
|