Skip to content

Commit

Permalink
added build script support; fixed some poetry parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed Oct 19, 2019
1 parent 3a218f0 commit cd4616f
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 26 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*.workspace.xml

# Prevent generated and test files from being committed
setup.py
requirements.txt
Pipfile
pyflow.lock
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
## v0.1.8
- Fixed a bug in auto-filling name and email in `pyflow init` and `pyflow new`
- Running `pyflow` alone in a directory without a `pyproject.toml` will now no
longer attempt to initialize a project.
longer attempt to initialize a project
- Added support for specifying a build script
- Treat `python_version` on `pypi` as a caret requirement, if specified like `3.6`.
- Improved error messages

## v0.1.7
- Fixed bugs in `path` dependencies
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyflow"
version = "0.1.7"
version = "0.1.8"
authors = ["David O'Connor <david.alan.oconnor@gmail.com>"]
description = "A modern Python installation and dependency manager"
license = "MIT"
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,10 @@ by Steve Dower.
Click the folder-tree icon at the bottom of the pop-out window →
Click the `+` icon at the bottom of the new pop-out window →
Navigate to and select `(projname)/__pypackages__/3.x/lib`
sss
- If using VsCode: `Settings` → search `python extra paths`
- If using VsCode: `Settings` → search `python extra paths`
`Edit in settings.json` → Add or modify the line:
`"python.autoComplete.extraPaths": ["(projname)/__pypackages__/3.7/lib"]`

- Make sure the `pyflow` binary is accessible in your path. If installing
via a `deb`, `msi`, `snap`, `rpm`, or `Cargo`, this should be set up automatically.

# References
- [PEP 582 - Python local packages directory](https://www.python.org/dev/peps/pep-0582/)
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ links to reflect the latest version.
1. Commit and push the repo
1. Check that CI pipeline passed
1. Run `cargo package` and `cargo publish` (Allows installation via cargo)
1. Run `cargo build --release` on Windows and Linux (to build binaries)
1. Run `cargo build --release` on Windows and Linux (to build standalone binaries)
1. Run `cargo deb` on Ubuntu 16.04 (one built on 18.04
works on 19.04, but not vice-versa)
1. Run `cargo build --release`, then `cargo rpm build` on Centos 7. (This allows easy installation for Red Hat, Fedora, and CentOs
Expand Down
20 changes: 20 additions & 0 deletions pip/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from setuptools import setup, find_packages

with open('README.rst') as f:
readme = f.read()

setup(
name="pflow",
version="0.1.7",
packages=find_packages(),

install_requires=[],

author="David O'Connor",
author_email="david.alan.oconnor@gmail.com",
url='https://github.com/David-OConnor/pyflow',
description="A Python installation and dependency manager",
long_description=readme,
license="MIT",
keywords="packaging, dependencies, install",
)
20 changes: 14 additions & 6 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ setuptools.setup(
// entry_points={{
// "console_scripts": ,
// }},
cfg.readme_filename.unwrap_or_else(|| "README.md".into()),
cfg.readme.unwrap_or_else(|| "README.md".into()),
cfg.name.unwrap_or_else(|| "".into()),
version,
author,
Expand Down Expand Up @@ -195,10 +195,18 @@ pub fn build(

util::set_pythonpath(&[paths.lib.to_owned()]);
println!("🛠️️ Building the package...");
Command::new(paths.bin.join("python"))
.args(&[dummy_setup_fname, "sdist", "bdist_wheel"])
.status()
.expect("Problem building");
// todo: Run build script first, right?
if let Some(build_file) = &cfg.build {
Command::new(paths.bin.join("python"))
.arg(&build_file)
.status()
.expect(&format!("Problem building using {}", build_file));
}

// Command::new(paths.bin.join("python"))
// .args(&[dummy_setup_fname, "sdist", "bdist_wheel"])
// .status()
// .expect("Problem building");

util::print_color("Build complete.", Color::Green);

Expand Down Expand Up @@ -257,7 +265,7 @@ pub mod test {
python_requires: Some(">=3.6".into()),
package_url: Some("https://upload.pypi.org/legacy/".into()),
scripts,
readme_filename: Some("README.md".into()),
readme: Some("README.md".into()),
reqs: vec![
Req::new(
"numpy".into(),
Expand Down
5 changes: 3 additions & 2 deletions src/dep_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,9 @@ fn guess_graph(
d
} else {
util::abort(
"Problem getting dependency data - this is\
likely a bug in the cacheing process. Please try again in a few minutes.",
"Problem getting dependency data - this is \
likely a bug in the cacheing process. Please try again in a few minutes. \
Reqs: {:#?}",
);
unreachable!()
};
Expand Down
4 changes: 3 additions & 1 deletion src/dep_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ impl Constraint {
}

if let Ok(parsed) = Version::from_str(s) {
return Ok(vec![Self::new(ReqType::Exact, parsed)]);
// Note the `Caret` req type; if passed in this format, assuming packages marked
// `3.6` are valid for `3.7+`.
return Ok(vec![Self::new(ReqType::Caret, parsed)]);
}

let s_split = s.split('.');
Expand Down
8 changes: 5 additions & 3 deletions src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ pub struct Pyflow {
pub repository: Option<String>,
pub repo_url: Option<String>,
pub package_url: Option<String>,
pub readme_filename: Option<String>,
pub readme: Option<String>,
pub build: Option<String>,
// pub entry_points: Option<HashMap<String, Vec<String>>>,
pub scripts: Option<HashMap<String, String>>,
pub python_requires: Option<String>,
Expand All @@ -93,13 +94,14 @@ pub struct Poetry {
pub description: Option<String>,
pub license: Option<String>,
pub authors: Option<Vec<String>>,
pub readme: Option<String>,
pub homepage: Option<String>,
pub repository: Option<String>,
pub documentation: Option<String>,
pub keywords: Option<Vec<String>>,
pub readme: Option<String>,
pub build: Option<String>,
pub classifiers: Option<Vec<String>>,
pub packages: Option<Vec<String>>,
pub packages: Option<Vec<HashMap<String, String>>>,
pub include: Option<Vec<String>>,
pub exclude: Option<Vec<String>>,
pub extras: Option<HashMap<String, String>>,
Expand Down
4 changes: 3 additions & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ pub fn download_and_install_package(
if !dist_path.exists() {
util::abort(&format!(
"Problem building {} from source. \
This may occur on WSL if installing to a mounted directory.",
This may occur if a package that requires compiling has no wheels available \
for this OS and this system is missing dependencies required to compile it, \
or if on WSL and installing to a mounted directory.",
name
));
}
Expand Down
20 changes: 16 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Install packages from `pyproject.toml`, `pyflow.lock`, or speficied ones. Exampl
// #[structopt(name = "name")]
// name: String,
// },
/// Change the Python version for this project. eg `pyflow switch 3.7`. Equivalent to setting
/// Change the Python version for this project. eg `pyflow switch 3.8`. Equivalent to setting
/// `py_version` in `pyproject.toml`.
#[structopt(name = "switch")]
Switch {
Expand Down Expand Up @@ -148,7 +148,8 @@ pub struct Config {
repository: Option<String>,
repo_url: Option<String>,
package_url: Option<String>,
readme_filename: Option<String>,
readme: Option<String>,
build: Option<String>, // A python file used to build non-python extensions
// entry_points: HashMap<String, Vec<String>>, // todo option?
scripts: HashMap<String, String>, //todo: put under [tool.pyflow.scripts] ?
// console_scripts: Vec<String>, // We don't parse these; pass them to `setup.py` as-entered.
Expand Down Expand Up @@ -300,7 +301,12 @@ impl Config {
if let Some(v) = po.repository {
result.repository = Some(v);
}

if let Some(v) = po.readme {
result.readme = Some(v);
}
if let Some(v) = po.build {
result.build = Some(v);
}
// todo: Process entry pts, classifiers etc?
if let Some(v) = po.classifiers {
result.classifiers = v;
Expand Down Expand Up @@ -405,7 +411,13 @@ impl Config {
if let Some(v) = pf.keywords {
result.keywords = v;
}
// if let Some(v) = pp.entry_points {
if let Some(v) = pf.readme {
result.readme = Some(v);
}
if let Some(v) = pf.build {
result.build = Some(v);
}
// if let Some(v) = pf.entry_points {
// result.entry_points = v;
// } // todo
if let Some(v) = pf.scripts {
Expand Down

0 comments on commit cd4616f

Please sign in to comment.